Skip to content

Commit

Permalink
opencl: add functionality to query CL_KERNEL_WORK_GROUP_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
upegelow committed Apr 6, 2012
1 parent b0b4cd7 commit fbfe645
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/dlopencl.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ int dt_dlopencl_init(const char *name, dt_dlopencl_t **ocl)
success = success && dt_gmodule_symbol(module, "clGetEventProfilingInfo", (void (**)(void))&d->symbols->dt_clGetEventProfilingInfo); success = success && dt_gmodule_symbol(module, "clGetEventProfilingInfo", (void (**)(void))&d->symbols->dt_clGetEventProfilingInfo);
success = success && dt_gmodule_symbol(module, "clGetKernelInfo", (void (**)(void))&d->symbols->dt_clGetKernelInfo); success = success && dt_gmodule_symbol(module, "clGetKernelInfo", (void (**)(void))&d->symbols->dt_clGetKernelInfo);
success = success && dt_gmodule_symbol(module, "clEnqueueBarrier", (void (**)(void))&d->symbols->dt_clEnqueueBarrier); success = success && dt_gmodule_symbol(module, "clEnqueueBarrier", (void (**)(void))&d->symbols->dt_clEnqueueBarrier);
success = success && dt_gmodule_symbol(module, "clGetKernelWorkGroupInfo", (void (**)(void))&d->symbols->dt_clGetKernelWorkGroupInfo);


if (!success) dt_print(DT_DEBUG_OPENCL, "[opencl_init] could not load all required symbols from library\n"); if (!success) dt_print(DT_DEBUG_OPENCL, "[opencl_init] could not load all required symbols from library\n");
d->have_opencl = success; d->have_opencl = success;
Expand Down
9 changes: 9 additions & 0 deletions src/common/opencl.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -498,6 +498,15 @@ int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgr
} }




int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize)
{
dt_opencl_t *cl = darktable.opencl;
if(!cl->inited || dev < 0) return -1;
if(kernel < 0 || kernel >= DT_OPENCL_MAX_KERNELS) return -1;

return (cl->dlocl->symbols->dt_clGetKernelWorkGroupInfo)(cl->dev[dev].kernel[kernel], cl->dev[dev].devid, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), kernelworkgroupsize, NULL);
}



int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg) int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
{ {
Expand Down
7 changes: 7 additions & 0 deletions src/common/opencl.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes);
/** return max size per dimension in sizes[3] and max total size in workgroupsize */ /** return max size per dimension in sizes[3] and max total size in workgroupsize */
int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize, unsigned long *localmemsize); int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize, unsigned long *localmemsize);


/** return max workgroup size for a specifc kernel */
int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize);

/** attach arg. */ /** attach arg. */
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg); int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg);


Expand Down Expand Up @@ -262,6 +265,10 @@ static inline int dt_opencl_get_work_group_limits(const int dev, size_t *sizes,
{ {
return -1; return -1;
} }
static inline int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize)
{
return -1;
}
static inline int dt_opencl_set_kernel_arg(const int dev, const int kernel, const size_t size, const void *arg) static inline int dt_opencl_set_kernel_arg(const int dev, const int kernel, const size_t size, const void *arg)
{ {
return -1; return -1;
Expand Down

0 comments on commit fbfe645

Please sign in to comment.