runtime test update
This commit is contained in:
@@ -15,7 +15,7 @@ SRCS = util.cpp args.cpp mem.cpp pipeline.cpp warp.cpp core.cpp decode.cpp execu
|
|||||||
|
|
||||||
# Debugigng
|
# Debugigng
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CXXFLAGS += -DDEBUG_LEVEL=3
|
CXXFLAGS += -DDEBUG_LEVEL=$(DEBUG)
|
||||||
else
|
else
|
||||||
CXXFLAGS += -DNDEBUG
|
CXXFLAGS += -DNDEBUG
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -818,9 +818,10 @@ void Warp::execute(const Instr &instr, Pipeline *pipeline) {
|
|||||||
case 0: {
|
case 0: {
|
||||||
// TMC
|
// TMC
|
||||||
tmask_.reset();
|
tmask_.reset();
|
||||||
for (size_t i = 0; i < tmask_.size(); ++i) {
|
for (int i = 0; i < num_threads; ++i) {
|
||||||
tmask_[i] = rsdata[0] & (1 << i);
|
tmask_[i] = rsdata[0] & (1 << i);
|
||||||
}
|
}
|
||||||
|
D(3, "*** TMC " << tmask_);
|
||||||
active_ = tmask_.any();
|
active_ = tmask_.any();
|
||||||
pipeline->stall_warp = true;
|
pipeline->stall_warp = true;
|
||||||
runOnce = true;
|
runOnce = true;
|
||||||
@@ -859,7 +860,7 @@ void Warp::execute(const Instr &instr, Pipeline *pipeline) {
|
|||||||
for (int i = 0; i < num_threads; ++i) DPN(3, e.tmask[num_threads-i-1]);
|
for (int i = 0; i < num_threads; ++i) DPN(3, e.tmask[num_threads-i-1]);
|
||||||
DPN(3, ", PC=0x" << std::hex << e.PC << "\n");
|
DPN(3, ", PC=0x" << std::hex << e.PC << "\n");
|
||||||
} else {
|
} else {
|
||||||
D(3, "*** Unanimous pred: r" << rsrc0 << ", val: " << rsdata[0]);
|
D(3, "*** Unanimous pred");
|
||||||
DomStackEntry e(tmask_);
|
DomStackEntry e(tmask_);
|
||||||
e.unanimous = true;
|
e.unanimous = true;
|
||||||
domStack_.push(e);
|
domStack_.push(e);
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
int main() {
|
int main() {
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
|
||||||
vx_printf("Simple Test\n");
|
|
||||||
|
|
||||||
errors += test_global_memory();
|
errors += test_global_memory();
|
||||||
|
|
||||||
errors += test_stack_memory();
|
errors += test_stack_memory();
|
||||||
@@ -20,6 +18,8 @@ int main() {
|
|||||||
|
|
||||||
errors += test_spawn_tasks();
|
errors += test_spawn_tasks();
|
||||||
|
|
||||||
|
errors += test_tmask();
|
||||||
|
|
||||||
if (0 == errors) {
|
if (0 == errors) {
|
||||||
vx_printf("Passed!\n");
|
vx_printf("Passed!\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <vx_intrinsics.h>
|
#include <vx_intrinsics.h>
|
||||||
#include <vx_print.h>
|
#include <vx_print.h>
|
||||||
#include <vx_spawn.h>
|
#include <vx_spawn.h>
|
||||||
|
|
||||||
int check_error(const int* buffer, int size) {
|
int __attribute__ ((noinline)) check_error(const int* buffer, int size) {
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
int value = buffer[i];
|
int value = buffer[i];
|
||||||
@@ -19,15 +20,21 @@ int check_error(const int* buffer, int size) {
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __attribute__ ((noinline)) make_select_tmask(int tid) {
|
||||||
|
return (1 << tid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int __attribute__ ((noinline)) make_full_tmask(int num_threads) {
|
||||||
|
return (1 << num_threads) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define GLOBAL_MEM_SZ 8
|
#define GLOBAL_MEM_SZ 8
|
||||||
int global_buffer[GLOBAL_MEM_SZ];
|
int global_buffer[GLOBAL_MEM_SZ];
|
||||||
|
|
||||||
int test_global_memory() {
|
int test_global_memory() {
|
||||||
int errors = 0;
|
vx_printf("Global Memory Test\n");
|
||||||
|
|
||||||
vx_printf("Global Memory test\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < GLOBAL_MEM_SZ; i++) {
|
for (int i = 0; i < GLOBAL_MEM_SZ; i++) {
|
||||||
global_buffer[i] = 65 + i;
|
global_buffer[i] = 65 + i;
|
||||||
@@ -39,11 +46,10 @@ int test_global_memory() {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int test_stack_memory() {
|
int test_stack_memory() {
|
||||||
|
vx_printf("Stack Memory Test\n");
|
||||||
|
|
||||||
static const int STACK_MEM_SZ = 8;
|
static const int STACK_MEM_SZ = 8;
|
||||||
int stack_buffer[STACK_MEM_SZ];
|
int stack_buffer[STACK_MEM_SZ];
|
||||||
int errors = 0;
|
|
||||||
|
|
||||||
vx_printf("Stack Memory test\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < STACK_MEM_SZ; i++) {
|
for (int i = 0; i < STACK_MEM_SZ; i++) {
|
||||||
stack_buffer[i] = 65 + i;
|
stack_buffer[i] = 65 + i;
|
||||||
@@ -57,9 +63,8 @@ int test_stack_memory() {
|
|||||||
int test_shared_memory() {
|
int test_shared_memory() {
|
||||||
static const int SHARED_MEM_SZ = 8;
|
static const int SHARED_MEM_SZ = 8;
|
||||||
int* shared_buffer = (int*)(SMEM_BASE_ADDR-(SMEM_SIZE-SHARED_MEM_SZ-4));
|
int* shared_buffer = (int*)(SMEM_BASE_ADDR-(SMEM_SIZE-SHARED_MEM_SZ-4));
|
||||||
int errors = 0;
|
|
||||||
|
|
||||||
vx_printf("Shared Memory test\n");
|
vx_printf("Shared Memory Test\n");
|
||||||
|
|
||||||
for (int i = 0; i < SHARED_MEM_SZ; i++) {
|
for (int i = 0; i < SHARED_MEM_SZ; i++) {
|
||||||
shared_buffer[i] = 65 + i;
|
shared_buffer[i] = 65 + i;
|
||||||
@@ -70,24 +75,28 @@ int test_shared_memory() {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int tmc_buffer[NUM_THREADS];
|
int tmc_buffer[8];
|
||||||
|
|
||||||
int test_tmc() {
|
void __attribute__ ((noinline)) do_tmc() {
|
||||||
int errors = 0;
|
|
||||||
|
|
||||||
vx_printf("Thread mask test\n");
|
|
||||||
|
|
||||||
vx_tmc(NUM_THREADS);
|
|
||||||
unsigned tid = vx_thread_id();
|
unsigned tid = vx_thread_id();
|
||||||
tmc_buffer[tid] = 65 + tid;
|
tmc_buffer[tid] = 65 + tid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_tmc() {
|
||||||
|
vx_printf("TMC Test\n");
|
||||||
|
|
||||||
|
int num_threads = std::min(vx_num_threads(), 8);
|
||||||
|
int tmask = make_full_tmask(num_threads);
|
||||||
|
vx_tmc(tmask);
|
||||||
|
do_tmc();
|
||||||
vx_tmc(1);
|
vx_tmc(1);
|
||||||
|
|
||||||
return check_error(tmc_buffer, NUM_THREADS);
|
return check_error(tmc_buffer, num_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int wspawn_buffer[NUM_WARPS];
|
int wspawn_buffer[8];
|
||||||
|
|
||||||
void simple_kernel() {
|
void simple_kernel() {
|
||||||
unsigned wid = vx_warp_id();
|
unsigned wid = vx_warp_id();
|
||||||
@@ -96,53 +105,53 @@ void simple_kernel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int test_wsapwn() {
|
int test_wsapwn() {
|
||||||
vx_printf("test_wspawn\n");
|
vx_printf("Wspawn Test\n");
|
||||||
vx_wspawn(NUM_WARPS, simple_kernel);
|
int num_warps = std::min(vx_num_warps(), 8);
|
||||||
|
vx_wspawn(num_warps, simple_kernel);
|
||||||
simple_kernel();
|
simple_kernel();
|
||||||
|
|
||||||
return check_error(wspawn_buffer, NUM_WARPS);
|
return check_error(wspawn_buffer, num_warps);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define DIV_BUF_SZ ((NUM_THREADS > 4) ? 4 : NUM_THREADS)
|
int dvg_buffer[4];
|
||||||
int div_buffer[DIV_BUF_SZ];
|
|
||||||
|
|
||||||
int test_divergence() {
|
void __attribute__ ((noinline)) do_divergence() {
|
||||||
int errors = 0;
|
|
||||||
|
|
||||||
vx_printf("Control divergence test\n");
|
|
||||||
|
|
||||||
vx_tmc(DIV_BUF_SZ);
|
|
||||||
|
|
||||||
unsigned tid = vx_thread_id();
|
unsigned tid = vx_thread_id();
|
||||||
|
|
||||||
bool b = tid < 2;
|
__if (tid < 2) {
|
||||||
__if (b) {
|
__if (tid < 1) {
|
||||||
bool c = tid < 1;
|
dvg_buffer[tid] = 65;
|
||||||
__if (c) {
|
|
||||||
div_buffer[tid] = 65;
|
|
||||||
}
|
}
|
||||||
__else {
|
__else {
|
||||||
div_buffer[tid] = 66;
|
dvg_buffer[tid] = 66;
|
||||||
}
|
}
|
||||||
__endif
|
__endif
|
||||||
}
|
}
|
||||||
__else {
|
__else {
|
||||||
bool c = tid < 3;
|
__if (tid < 3) {
|
||||||
__if (c) {
|
dvg_buffer[tid] = 67;
|
||||||
div_buffer[tid] = 67;
|
|
||||||
}
|
}
|
||||||
__else {
|
__else {
|
||||||
div_buffer[tid] = 68;
|
dvg_buffer[tid] = 68;
|
||||||
}
|
}
|
||||||
__endif
|
__endif
|
||||||
}
|
}
|
||||||
__endif
|
__endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_divergence() {
|
||||||
|
vx_printf("Control Divergence Test\n");
|
||||||
|
|
||||||
|
int num_threads = std::min(vx_num_threads(), 4);
|
||||||
|
int tmask = make_full_tmask(num_threads);
|
||||||
|
vx_tmc(tmask);
|
||||||
|
do_divergence();
|
||||||
vx_tmc(1);
|
vx_tmc(1);
|
||||||
|
|
||||||
return check_error(div_buffer, DIV_BUF_SZ);
|
return check_error(dvg_buffer, num_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -162,14 +171,12 @@ void st_kernel(int task_id, void * arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int test_spawn_tasks() {
|
int test_spawn_tasks() {
|
||||||
int error = 0;
|
vx_printf("SpawnTasks Test\n");
|
||||||
|
|
||||||
st_args_t arg;
|
st_args_t arg;
|
||||||
arg.src = st_buffer_src;
|
arg.src = st_buffer_src;
|
||||||
arg.dst = st_buffer_dst;
|
arg.dst = st_buffer_dst;
|
||||||
|
|
||||||
vx_printf("spawning %d tasks\n", ST_BUF_SZ);
|
|
||||||
|
|
||||||
for (int i = 0; i < ST_BUF_SZ; i++) {
|
for (int i = 0; i < ST_BUF_SZ; i++) {
|
||||||
st_buffer_src[i] = 65 + i;
|
st_buffer_src[i] = 65 + i;
|
||||||
}
|
}
|
||||||
@@ -177,4 +184,36 @@ int test_spawn_tasks() {
|
|||||||
vx_spawn_tasks(ST_BUF_SZ, st_kernel, &arg);
|
vx_spawn_tasks(ST_BUF_SZ, st_kernel, &arg);
|
||||||
|
|
||||||
return check_error(st_buffer_dst, ST_BUF_SZ);
|
return check_error(st_buffer_dst, ST_BUF_SZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int tmask_buffer[8];
|
||||||
|
|
||||||
|
int __attribute__ ((noinline)) do_tmask() {
|
||||||
|
int tid = vx_thread_id();
|
||||||
|
int tmask = make_select_tmask(tid);
|
||||||
|
int cur_tmask = vx_thread_mask();
|
||||||
|
tmask_buffer[tid] = (cur_tmask == tmask) ? (65 + tid) : 0;
|
||||||
|
return tid + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_tmask() {
|
||||||
|
vx_printf("Thread Mask Test\n");
|
||||||
|
|
||||||
|
// activate all thread to populate shared variables
|
||||||
|
vx_tmc(-1);
|
||||||
|
|
||||||
|
int num_threads = std::min(vx_num_threads(), 8);
|
||||||
|
int tid = 0;
|
||||||
|
|
||||||
|
l_start:
|
||||||
|
int tmask = make_select_tmask(tid);
|
||||||
|
vx_tmc(tmask);
|
||||||
|
tid = do_tmask();
|
||||||
|
if (tid < num_threads)
|
||||||
|
goto l_start;
|
||||||
|
vx_tmc(1);
|
||||||
|
|
||||||
|
return check_error(tmask_buffer, num_threads);
|
||||||
}
|
}
|
||||||
@@ -15,4 +15,6 @@ int test_wsapwn();
|
|||||||
|
|
||||||
int test_spawn_tasks();
|
int test_spawn_tasks();
|
||||||
|
|
||||||
|
int test_tmask();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user