0

我尝试为 oclVectorAdd 示例计时。我使用 clGetProfilingInfo,GPU 计时器来记录内核执行所花费的时间。时间以毫秒为单位计算。但是输出很奇怪。代码和输出如下:

    cl_ulong start,end;
cl_event event_ker_x;
ciErr1 = clEnqueueNDRangeKernel(cqCommandQueue, ckKernel, 1, NULL, &szGlobalWorkSize, &szLocalWorkSize, 0, NULL, &event_ker_x);
shrLog("clEnqueueNDRangeKernel (VectorAdd)...\n");
if (ciErr1 != CL_SUCCESS)
{
    shrLog("Error in clEnqueueNDRangeKernel, Line %u in file %s !!!\n\n", __LINE__, __FILE__);
    Cleanup(argc, argv, EXIT_FAILURE);
}
clGetEventProfilingInfo(event_ker_x, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, NULL);
clGetEventProfilingInfo(event_ker_x, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, NULL);
float ker_x_time= (end-start) * 1.0e-6f;
shrLog("kernel execution time is : %f\n", ker_x_time);
clEnqueueNDRangeKernel (VectorAdd)...
kernel execution time is : 18446744027136.000000
clEnqueueReadBuffer (Dst)...
4

1 回答 1

0

看起来你和这个人有类似的问题:定时间隔总是计算为零

在 OpenCL 中,clEnqueueNDRangeKernel将内核排队运行,但不一定立即执行内核。要使用事件分析您的内核,请尝试在 . 之后检查执行时间clEnqueueReadBufferclFinish(..)clEnqueueNDKernelRange.

于 2013-07-25T16:36:31.673 回答