diff --git a/driver/tests/demo/kernel.bin b/driver/tests/demo/kernel.bin index 2b8280da..aea7c061 100755 Binary files a/driver/tests/demo/kernel.bin and b/driver/tests/demo/kernel.bin differ diff --git a/driver/tests/demo/kernel.elf b/driver/tests/demo/kernel.elf index 852f887b..d91b509c 100755 Binary files a/driver/tests/demo/kernel.elf and b/driver/tests/demo/kernel.elf differ diff --git a/runtime/include/vx_spawn.h b/runtime/include/vx_spawn.h index 5acbfecc..d2f2cfd4 100644 --- a/runtime/include/vx_spawn.h +++ b/runtime/include/vx_spawn.h @@ -12,25 +12,6 @@ typedef void (*func_t)(void *); void vx_spawn_warps(int num_warps, int num_threads, func_t func_ptr , void * args); -struct context_t { - uint32_t num_groups[3]; - uint32_t global_offset[3]; - uint32_t local_size[3]; - char * printf_buffer; - uint32_t *printf_buffer_position; - uint32_t printf_buffer_capacity; - uint32_t work_dim; -}; - -/* The default work-group function prototype as generated by Workgroup.cc. */ -typedef void (*vx_pocl_workgroup_func) (const void * /* args */, - const struct context_t * /* context */, - uint32_t /* group_x */, - uint32_t /* group_y */, - uint32_t /* group_z */); - -void pocl_spawn(struct context_t * ctx, vx_pocl_workgroup_func pfn, const void * args); - #ifdef __cplusplus } #endif diff --git a/runtime/src/vx_spawn.c b/runtime/src/vx_spawn.c index 3461da34..a215d1b3 100644 --- a/runtime/src/vx_spawn.c +++ b/runtime/src/vx_spawn.c @@ -6,16 +6,20 @@ extern "C" { #endif -func_t global_function_pointer; -void * global_argument_struct; -int global_num_threads; +typedef struct { + func_t function; + void * arguments; + int nthreads; +} spawn_t; + +spawn_t* g_spawn = NULL; void spawn_warp_runonce() { // active all threads - vx_tmc(global_num_threads); + vx_tmc(g_spawn->nthreads); // call user routine - global_function_pointer(global_argument_struct); + g_spawn->function(g_spawn->arguments); // resume single-thread execution on exit int wid = vx_warp_id(); @@ -23,55 +27,16 @@ void spawn_warp_runonce() { vx_tmc(tmask); } -void vx_spawn_warps(int numWarps, int numThreads, func_t func_ptr, void * args) { - global_function_pointer = func_ptr; - global_argument_struct = args; - global_num_threads = numThreads; - if (numWarps > 1) { - vx_wspawn(numWarps, (unsigned)spawn_warp_runonce); +void vx_spawn_warps(int num_warps, int num_threads, func_t func_ptr , void * args) { + spawn_t spawn = { func_ptr, args, num_threads }; + g_spawn = &spawn; + + if (num_warps > 1) { + vx_wspawn(num_warps, (unsigned)spawn_warp_runonce); } spawn_warp_runonce(); } -int pocl_threads; -struct context_t * pocl_ctx; -vx_pocl_workgroup_func pocl_pfn; -const void * pocl_args; - -void pocl_spawn_warp_runonce() { - // active all threads - vx_tmc(pocl_threads); - - int x = vx_thread_id(); - int y = vx_warp_gid(); - - // call kernel routine - (pocl_pfn)(pocl_args, pocl_ctx, x, y, 0); - - // resume single-thread execution on exit - int wid = vx_warp_id(); - unsigned tmask = (0 == wid) ? 0x1 : 0x0; - vx_tmc(tmask); -} - -void pocl_spawn(struct context_t * ctx, vx_pocl_workgroup_func pfn, const void * args) { - if (ctx->num_groups[2] > 1) { - printf("ERROR: pocl_spawn doesn't support Z dimension yet!\n"); - return; - } - - pocl_threads = ctx->num_groups[0]; - pocl_ctx = ctx; - pocl_pfn = pfn; - pocl_args = args; - - if (ctx->num_groups[1] > 1) { - vx_wspawn(ctx->num_groups[1], (unsigned)&pocl_spawn_warp_runonce); - } - - pocl_spawn_warp_runonce(); -} - #ifdef __cplusplus } #endif \ No newline at end of file