我正在尝试在opencl上使用2d网格和块。关于简单但在OpenCl上的cuda,它是如此令人困惑。我尝试使用2x2网格,每个块都有4x4线程,:
size_t **global_item_size2 = malloc (2 * sizeof(size_t *) + (2 * (2 * sizeof(size_t))));
size_t **local_item_size2 = malloc (4 * sizeof(size_t *) + (4 * (4 * sizeof(size_t))));
clEnqueueNDRangeKernel(commandQueue, myKernel, 2, NULL, (size_t*)&*global_item_size2, (size_t*)&*local_item_size2, 0, NULL, &event);
它编译,但当我试图运行时,我正在
错误@ clEnqueueNDRangeKernel:CL_INVALID_WORK_GROUP_SIZE
如何在OpenCl上使用2d块和2d网格?
答案 0 :(得分:3)
你应该这样做:(在纯C中更新)
//Create the size holders
size_t * global = (size_t*) malloc(sizeof(size_t)*2);
size_t * local = (size_t*) malloc(sizeof(size_t)*2);
//Set the size
global[0] = 8; global[1] = 8;
local [0] = 4; local [1] = 4;
//Run
clEnqueueNDRangeKernel(commandQueue, myKernel, 2, NULL, global, local, 0, NULL, &event);
//Clean the size holders
free(global);
free(local);
此外,您的概念是错误的:
因此它应该是8x8全局,4x4本地,给它2x2工作组。
8x8(全局)= 4x4(本地)* 2x2(组)