clMathLibraries / clFFT

a software library containing FFT functions written in OpenCL
Apache License 2.0
619 stars 192 forks source link

'clfftEnqueueTransform' input parameter outEvent,Event time erroe. #248

Open SuDong1999 opened 10 months ago

SuDong1999 commented 10 months ago

Set "event" as the parameter of the output event of the "clfftEnqueueTransform" function, and use "clWaitForEvents" to wait for the event to complete, and use "event" to calculate the Fourier transform time 1. The code is as follows: int PC1D::fft(cl_mem& src, cl_mem& dst) { cl_event event; clfftEnqueueTransform(_separatePlan, CLFFT_FORWARD, 1, &_commandQue, 0, NULL, &event, &src, &dst, NULL);

//统计计算行时间
_err = clWaitForEvents(1, &event);
if (_err != CL_SUCCESS) { PRINT_ERROR(_err); }
cl_ulong startTime, endTime;
_err = clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &startTime, NULL);
if (_err != CL_SUCCESS) { PRINT_ERROR(_err); }
_err = clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &endTime, NULL);
if (_err != CL_SUCCESS) { PRINT_ERROR(_err); }
_fftTime += endTime - startTime;
return 0;

} The second method: Use the clFinish function to wait for the command queue to complete execution, and get the time of the system timer before and after execution, giving time 2.The code is as follows: clFinish(_commandQue); tic(0); fft(_receipt,_receipt); clFinish(_commandQue); toc(0, "Total time: "); It is found that time 2 is 6 or 7 times that of time 1. What is the cause of this?