MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / runR2C_FFT_WithCallback

Function runR2C_FFT_WithCallback

src/callback-client/callback-client.cpp:110–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109template < typename T >
110void runR2C_FFT_WithCallback(std::auto_ptr< clfftSetupData > setupData, cl_context context, cl_command_queue commandQueue,
111 size_t* inlengths, clfftDim dim, clfftPrecision precision,
112 size_t batchSize, size_t vectorLength, size_t fftLength, cl_uint profile_count)
113{
114 cl_int status = 0;
115
116 //input/output allocation sizes
117 size_t in_size_of_buffers = fftLength * sizeof(uint24_t);
118 size_t out_size_of_buffers = fftLength * sizeof( T );
119
120 uint24_t *input24bitData = (uint24_t*)malloc(in_size_of_buffers);
121
122 //Initialize Data
123 srand(1);
124 for (size_t idx = 0; idx < fftLength; ++idx)
125 {
126 int randomVal = (int)rand();
127
128 input24bitData[idx][0] = (randomVal >> 16) & 0xFF;
129 input24bitData[idx][1] = (randomVal >> 8) & 0xFF;
130 input24bitData[idx][2] = randomVal & 0xFF;
131 }
132
133 //input data buffer
134 cl_mem infftbuffer = ::clCreateBuffer( context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, in_size_of_buffers, (void*)input24bitData, &status);
135 OPENCL_V_THROW( status, "Creating Buffer ( ::clCreateBuffer(infftbuffer) )" );
136
137 //out-place transform.
138 cl_mem outfftbuffer = ::clCreateBuffer( context, CL_MEM_READ_WRITE, out_size_of_buffers, NULL, &status);
139 OPENCL_V_THROW( status, "Creating Buffer ( ::clCreateBuffer(oufftbuffer) )" );
140
141 //clFFT initializations
142
143 // FFT state
144 clfftResultLocation place = CLFFT_OUTOFPLACE;
145 clfftLayout inLayout = CLFFT_REAL;
146 clfftLayout outLayout = CLFFT_HERMITIAN_INTERLEAVED;
147
148 clfftPlanHandle plan_handle;
149 OPENCL_V_THROW( clfftSetup( setupData.get( ) ), "clfftSetup failed" );
150 OPENCL_V_THROW( clfftCreateDefaultPlan( &plan_handle, context, dim, inlengths ), "clfftCreateDefaultPlan failed" );
151
152 //Precallback setup
153 char* precallbackstr = STRINGIFY(ConvertToFloat);
154
155 //Postcallback setup
156 char* postcallbackstr = STRINGIFY(MagnitudeExtraction);
157
158 //Register the callback
159 OPENCL_V_THROW (clfftSetPlanCallback(plan_handle, "convert24To32bit", precallbackstr, 0, PRECALLBACK, NULL, 0), "clFFTSetPlanCallback failed");
160 OPENCL_V_THROW (clfftSetPlanCallback(plan_handle, "extractMagnitude", postcallbackstr, 0, POSTCALLBACK, NULL, 0), "clFFTSetPlanCallback failed");
161
162 // Default plan creates a plan that expects an inPlace transform with interleaved complex numbers
163 OPENCL_V_THROW( clfftSetResultLocation( plan_handle, place ), "clfftSetResultLocation failed" );
164 OPENCL_V_THROW( clfftSetLayout( plan_handle, inLayout, outLayout ), "clfftSetLayout failed" );
165 OPENCL_V_THROW( clfftSetPlanBatchSize( plan_handle, batchSize ), "clfftSetPlanBatchSize failed" );
166 OPENCL_V_THROW( clfftSetPlanPrecision( plan_handle, precision ), "clfftSetPlanPrecision failed" );
167 OPENCL_V_THROW( clfftSetPlanDistance( plan_handle, BATCH_LENGTH + 2, (BATCH_LENGTH/2 + 1)), "clfftSetPlanDistance failed" );

Callers

nothing calls this directly

Calls 15

clfftSetupFunction · 0.85
clfftCreateDefaultPlanFunction · 0.85
clfftSetPlanCallbackFunction · 0.85
clfftSetResultLocationFunction · 0.85
clfftSetLayoutFunction · 0.85
clfftSetPlanBatchSizeFunction · 0.85
clfftSetPlanPrecisionFunction · 0.85
clfftSetPlanDistanceFunction · 0.85
clfftBakePlanFunction · 0.85
clfftGetTmpBufSizeFunction · 0.85
clfftEnqueueTransformFunction · 0.85
get_R2C_fftwf_outputFunction · 0.85

Tested by

no test coverage detected