Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencl 为什么调用clEnqueueTask 3次会导致任务执行10次?_Opencl - Fatal编程技术网

Opencl 为什么调用clEnqueueTask 3次会导致任务执行10次?

Opencl 为什么调用clEnqueueTask 3次会导致任务执行10次?,opencl,Opencl,我在OpenCL中创建了一个简单的内核: __kernel void test(int x){ printf("test\n"); }; 我在一个非常简单的程序中调用它: int main(){ cl_int err; cl_int i = 0; cl_kernel testKernel; CL cl = initCL(1,(const char*[2]){"kernel.c"}); testKernel = clCreateKernel(cl.

我在OpenCL中创建了一个简单的内核:

__kernel void test(int x){
    printf("test\n");
};
我在一个非常简单的程序中调用它:

int main(){
    cl_int err;
    cl_int i = 0;
    cl_kernel testKernel;
    CL cl = initCL(1,(const char*[2]){"kernel.c"});
    testKernel = clCreateKernel(cl.program, "test", &err);
    clSetKernelArg(testKernel, 0, sizeof(cl_int), &i); 
    clEnqueueTask(cl.queue,testKernel,0,NULL,NULL);
    clEnqueueTask(cl.queue,testKernel,0,NULL,NULL);
    clEnqueueTask(cl.queue,testKernel,0,NULL,NULL);
    clFinish(cl.queue);
    return 0;
};
我本来希望测试打印3次,但该程序的输出是:

test
test
test
test
test
test
test
test
test
test

为什么?

你的工作小组有多大?@BrianCain:这是一项任务,而不是一个范围。所以没有工作组大小。你的硬件是什么?Macbook Pro视网膜2014。。。这是GeForce 750N,对吧。如果你有Nvidia Visual Profiler,收集应用程序时间线&看,内核发布的确切ND大小是多少。