diff --git a/include/clFFT.h b/include/clFFT.h index e1f46aa3a8cf74c95fc28de16594d9817b354739..5eb803d2275bed1a4d0e664b0fb35a02fcf5d370 100644 --- a/include/clFFT.h +++ b/include/clFFT.h @@ -194,6 +194,8 @@ cl_int clFFT_1DTwistPlannar(clFFT_Plan Plan, cl_command_queue queue, cl_mem arra void clFFT_DumpPlan( clFFT_Plan plan, FILE *file); +cl_int clFFT_GetSize(clFFT_Plan Plan, size_t* workSize, cl_uint batchSize); + #ifdef __cplusplus } #endif diff --git a/src/fft_setup.cpp b/src/fft_setup.cpp index 942e852e92ece8ca78ac9e1ba95c90d7be2e9c73..b014ea7e9326e8db48c6c5bb0130eb65e503134e 100644 --- a/src/fft_setup.cpp +++ b/src/fft_setup.cpp @@ -526,3 +526,25 @@ void clFFT_DumpPlan( clFFT_Plan Plan, FILE *file) } fprintf(out, "%s\n", plan->kernel_string->c_str()); } + +cl_int +clFFT_GetSize(clFFT_Plan Plan, size_t* workSize, cl_uint batchSize) +{ + if ( workSize == NULL ) { + return CL_INVALID_VALUE; + } + cl_fft_plan *plan = (cl_fft_plan *) Plan; + *workSize = 0; + // from precomputeSinCosLUTs() called in clFFT_CreatePlanAdv() + if (plan->twiddleMethod == clFFT_TaylorLUT || plan->twiddleMethod == clFFT_BigLUT) { + *workSize += ( plan->N1 + plan->N2 ) * 2 * sizeof(float); + } + // Additional alloc's from allocateTemporaryBufferInterleaved(), called in clFFT_ExecuteInterleaved() + // or allocateTemporaryBufferPlannar() called in clFFT_ExecutePlannar() + if(plan->temp_buffer_needed) { + size_t tmpLength = plan->n.x * plan->n.y * plan->n.z * batchSize * 2 * sizeof(cl_float); + *workSize += tmpLength; + } + + return CL_SUCCESS; +}