是否可以使用clGetEventProfilingInfo函数来获取clEnqueueWriteBuffer函数所花费的时间。我尝试使用它,我得到了CL_PROFILING_COMMAND_START和CL_PROFILING_COMMAND_END相同的值。我想知道这是因为我的代码中有些错误,还是因为分析不适用于clEnqueueWriteBuffer。
我的代码段是:
//写入输入缓冲区
clEnqueueWriteBuffer(queue [0],buf_A,CL_TRUE,0,PARTITION_SIZE * sizeof(int),input_A +(PARTITION_SIZE * j),0,NULL,& eventList [0]);
checkErr(cl_err," clEnqueueWriteBuffer:buf_A");
clWaitForEvents(1, eventList);
clGetEventProfilingInfo(eventList[0], CL_PROFILING_COMMAND_QUEUED, sizeof(time_start_queued), &time_start_queued, NULL);
clGetEventProfilingInfo(eventList[0], CL_PROFILING_COMMAND_START, sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(eventList[0], CL_PROFILING_COMMAND_END, sizeof(time_end), &time_end, NULL);
total_time = ((double)time_end - time_start)/1000000;
total_time_queued = ((double)time_end - time_start_queued)/1000000;
final_time_data += total_time;
final_time_queued_data += total_time_queued;
cout<<"\nTime: "<<final_time_data<<" "<<final_time_queued_data;
我得到的输出是:
时间:0 0.288444
由于返回的值为0,我假设它无法找到数据传输所需的时间。