我是opencl的新手,我遇到了一个奇怪的问题!我有一个还原内核,我重复了几次!问题是,当我分析内核的执行时,经过的时间(排队->结束)几乎相同并且有点增加,但是当我在“C++”代码中测量经过的时间时,执行“clEnqueueNDRangeKernel”行的时间会增加速度很快!!我已经附上了分析的代码和输出!:震惊:
// execute the kernel
globalWorkSize[0] = this->reduction_NumBlocks * this->reduction_NumThreads;
localWorkSize[0] = this->reduction_NumThreads;
//Start Time
ttt.start();
clErrNum = clEnqueueNDRangeKernel(clCommandQueue, kernelReduction, 1, 0,
globalWorkSize, localWorkSize, 0, NULL, &timing_event);
// check if kernel execution generated an error
oclCheckError(clErrNum, CL_SUCCESS);
clFinish(clCommandQueue);
ttt.stop();
//Check Elapsed Time
clGetEventProfilingInfo(timing_event, CL_PROFILING_COMMAND_QUEUED,
sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(timing_event, CL_PROFILING_COMMAND_END,
sizeof(time_end), &time_end, NULL);
cout<<"ElapseTime(Execute):"<<(time_end - time_start)/1000<<"us\tTTT:" <<ttt.getElapsedTimeInMicroSec()<<endl;
这是输出:
GeForce GTX 550 Ti
Device Timer Resolution:1000ns
GpuExecutionTime:160us C++ElapsedTime:177
GpuExecutionTime:156us C++ElapsedTime:167
GpuExecutionTime:156us C++ElapsedTime:166
GpuExecutionTime:189us C++ElapsedTime:242
GpuExecutionTime:158us C++ElapsedTime:215
...
GpuExecutionTime:156us C++ElapsedTime:253
GpuExecutionTime:162us C++ElapsedTime:261
GpuExecutionTime:157us C++ElapsedTime:262
GpuExecutionTime:156us C++ElapsedTime:254
GpuExecutionTime:157us C++ElapsedTime:254
GpuExecutionTime:160us C++ElapsedTime:261
GpuExecutionTime:167us C++ElapsedTime:279
GpuExecutionTime:157us C++ElapsedTime:264
...
GpuExecutionTime:159us C++ElapsedTime:263
GpuExecutionTime:157us C++ElapsedTime:261
GpuExecutionTime:157us C++ElapsedTime:260
GpuExecutionTime:157us C++ElapsedTime:263
GpuExecutionTime:264us C++ElapsedTime:384
...
GpuExecutionTime:156us C++ElapsedTime:304
GpuExecutionTime:161us C++ElapsedTime:314
GpuExecutionTime:157us C++ElapsedTime:308
GpuExecutionTime:160us C++ElapsedTime:305
GpuExecutionTime:158us C++ElapsedTime:311
GpuExecutionTime:156us C++ElapsedTime:308
GpuExecutionTime:157us C++ElapsedTime:312
...
GpuExecutionTime:157us C++ElapsedTime:326
GpuExecutionTime:158us C++ElapsedTime:326
GpuExecutionTime:159us C++ElapsedTime:330
GpuExecutionTime:158us C++ElapsedTime:328
GpuExecutionTime:158us C++ElapsedTime:335
任何形式的帮助表示赞赏。
PS输入和其他相关变量的大小是固定的!