| 28 | using std::vector; |
| 29 | |
| 30 | clfftStatus clfftEnqueueTransform( |
| 31 | clfftPlanHandle plHandle, |
| 32 | clfftDirection dir, |
| 33 | cl_uint numQueuesAndEvents, |
| 34 | cl_command_queue* commQueues, |
| 35 | cl_uint numWaitEvents, |
| 36 | const cl_event* waitEvents, |
| 37 | cl_event* outEvents, |
| 38 | cl_mem* clInputBuffers, |
| 39 | cl_mem* clOutputBuffers, |
| 40 | cl_mem clTmpBuffers |
| 41 | ) |
| 42 | { |
| 43 | cl_int status = CLFFT_SUCCESS; |
| 44 | |
| 45 | // We do not currently support multiple command queues, which is necessary to support multi-gpu operations |
| 46 | if( numQueuesAndEvents > 1 ) |
| 47 | { |
| 48 | return CLFFT_NOTIMPLEMENTED; |
| 49 | } |
| 50 | |
| 51 | FFTRepo& fftRepo = FFTRepo::getInstance( ); |
| 52 | FFTPlan* fftPlan = NULL; |
| 53 | lockRAII* planLock = NULL; |
| 54 | |
| 55 | // At this point, the user wants to enqueue a plan to execute. We lock the plan down now, such that |
| 56 | // after we finish baking the plan (if the user did not do that explicitely before), the plan cannot |
| 57 | // change again through the action of other thread before we enqueue this plan for execution. |
| 58 | OPENCL_V( fftRepo.getPlan( plHandle, fftPlan, planLock ), _T( "fftRepo.getPlan failed" ) ); |
| 59 | scopedLock sLock( *planLock, _T( "clfftGetPlanBatchSize" ) ); |
| 60 | |
| 61 | if( fftPlan->baked == false ) |
| 62 | { |
| 63 | OPENCL_V( clfftBakePlan( plHandle, numQueuesAndEvents, commQueues, NULL, NULL ), _T( "Failed to bake plan" ) ); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | // get the device information |
| 68 | cl_device_id q_device; |
| 69 | clGetCommandQueueInfo(*commQueues, CL_QUEUE_DEVICE, sizeof(cl_device_id), &q_device, NULL); |
| 70 | |
| 71 | // verify if the current device is the same as the one used for baking the plan |
| 72 | if(q_device != fftPlan->bakeDevice) |
| 73 | return CLFFT_DEVICE_MISMATCH; |
| 74 | |
| 75 | |
| 76 | if (fftPlan->inputLayout == CLFFT_REAL) dir = CLFFT_FORWARD; |
| 77 | else if (fftPlan->outputLayout == CLFFT_REAL) dir = CLFFT_BACKWARD; |
| 78 | |
| 79 | |
| 80 | // we do not check the user provided buffer at this release |
| 81 | cl_mem localIntBuffer = clTmpBuffers; |
| 82 | |
| 83 | if( clTmpBuffers == NULL && fftPlan->tmpBufSize > 0 && fftPlan->intBuffer == NULL) |
| 84 | { |
| 85 | // create the intermediate buffers |
| 86 | // The intermediate buffer is always interleave and packed |
| 87 | // For outofplace operation, we have the choice not to create intermediate buffer |