| 531 | |
| 532 | |
| 533 | clfftStatus FFTAction::enqueue(clfftPlanHandle plHandle, |
| 534 | clfftDirection dir, |
| 535 | cl_uint numQueuesAndEvents, |
| 536 | cl_command_queue* commQueues, |
| 537 | cl_uint numWaitEvents, |
| 538 | const cl_event* waitEvents, |
| 539 | cl_event* outEvents, |
| 540 | cl_mem* clInputBuffers, |
| 541 | cl_mem* clOutputBuffers) |
| 542 | { |
| 543 | FFTRepo & fftRepo = FFTRepo::getInstance(); |
| 544 | |
| 545 | std::vector< cl_mem > inputBuff; |
| 546 | std::vector< cl_mem > outputBuff; |
| 547 | |
| 548 | |
| 549 | clfftStatus status = selectBufferArguments(this->plan, |
| 550 | clInputBuffers, clOutputBuffers, |
| 551 | inputBuff, outputBuff); |
| 552 | |
| 553 | if (status != CLFFT_SUCCESS) |
| 554 | { |
| 555 | return status; |
| 556 | } |
| 557 | |
| 558 | // TODO: In the case of length == 1, FFT is a trivial NOP, but we still need to apply the forward and backwards tranforms |
| 559 | // TODO: Are map lookups expensive to call here? We can cache a pointer to the cl_program/cl_kernel in the plan |
| 560 | |
| 561 | // Translate the user plan into the structure that we use to map plans to clPrograms |
| 562 | |
| 563 | cl_program prog; |
| 564 | cl_kernel kern; |
| 565 | lockRAII* kernelLock; |
| 566 | OPENCL_V( fftRepo.getclProgram( this->getGenerator(), this->getSignatureData(), prog, this->plan->bakeDevice, this->plan->context ), _T( "fftRepo.getclProgram failed" ) ); |
| 567 | OPENCL_V( fftRepo.getclKernel( prog, dir, kern, kernelLock), _T( "fftRepo.getclKernels failed" ) ); |
| 568 | |
| 569 | scopedLock sLock(*kernelLock, _T("FFTAction::enqueue")); |
| 570 | |
| 571 | cl_uint uarg = 0; |
| 572 | if (!this->plan->transflag && !(this->plan->gen == Copy)) |
| 573 | { |
| 574 | // ::clSetKernelArg() is not thread safe, according to the openCL spec for the same cl_kernel object |
| 575 | // TODO: Need to verify that two different plans (which would get through our lock above) with exactly the same |
| 576 | // parameters would NOT share the same cl_kernel objects |
| 577 | |
| 578 | /* constant buffer */ |
| 579 | OPENCL_V( clSetKernelArg( kern, uarg++, sizeof( cl_mem ), (void*)&this->plan->const_buffer ), _T( "clSetKernelArg failed" ) ); |
| 580 | } |
| 581 | |
| 582 | // Input buffer(s) |
| 583 | // Input may be 1 buffer (CLFFT_COMPLEX_INTERLEAVED) |
| 584 | // or 2 buffers (CLFFT_COMPLEX_PLANAR) |
| 585 | |
| 586 | for (size_t i = 0; i < inputBuff.size(); ++i) |
| 587 | { |
| 588 | OPENCL_V( clSetKernelArg( kern, uarg++, sizeof( cl_mem ), (void*)&inputBuff[i] ), _T( "clSetKernelArg failed" ) ); |
| 589 | } |
| 590 | // Output buffer(s) |
no test coverage detected