我编写了一个 OpenCL 程序并像这样执行我的内核
Loop for MultipleGPU{
clEnqueueNDRangeKernel(commandQueues[i], kernel[i], 1, null,
global_work_size, local_work_size, 0, new cl_event[]{userEvent}, events[i]);
clFlush(commandQueues[i]);
}
long before = System.nanoTime();
// Set UserEvent = Complete so all kernel can start executing
clSetUserEventStatus(userEvent, CL_COMPLETE);
// Wait until the work is finished on all command queues
clWaitForEvents(events.length, events);
long after = System.nanoTime();
float totalDurationMs = (after - before) / 1e6f;
...profiling each events with CL_PROFILING_COMMAND_START and CL_PROFILING_COMMAND_END...
userEvent 确保内核同时运行。资料来源:[Reima 的回答]:我如何知道内核是否同时执行?.
我从一个带有 2 Tesla K20M GPU 的系统中得到了这个结果:
Total duration :37.800076ms
Duration on device 1 of 2: 38.037186
Duration on device 2 of 2: 37.85744
有人可以向我解释为什么 Start-End Profile Time 比总持续时间长吗?
谢谢你