minor update

This commit is contained in:
Blaise Tine 2020-06-27 15:34:59 -04:00
parent 8a306de02d
commit bc75147921
4 changed files with 15 additions and 69 deletions

Binary file not shown.

Binary file not shown.

View file

@ -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

View file

@ -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