@@ -126,3 +126,63 @@ class interop_handle {
126126 };
127127 qA.submit(cgH);
128128```
129+
130+ This example calls the clFFT library from SYCL using the `interop_task`:
131+ ```cpp
132+ #include <stdlib.h>
133+ #include <CL/sycl.hpp>
134+
135+ /* No need to explicitely include the OpenCL headers */
136+ #include <clFFT.h>
137+
138+ int main( void )
139+ {
140+ size_t N = 16;
141+
142+ cl::sycl::queue device_queue;
143+ cl::sycl::buffer<float> X(range<1>(N * 2));
144+
145+ /* Setup clFFT. */
146+ clfftSetupData fftSetup;
147+ err = clfftInitSetupData(&fftSetup);
148+ err = clfftSetup(&fftSetup);
149+
150+ device_queue.submit([=](codeplay::handler& cgh) {
151+ auto X_accessor = X.get_access<access::mode::read_write>(cgh);
152+ h.interop_task([=](codeplay::interop_handle &handle) {
153+ /* FFT library realted declarations */
154+ clfftPlanHandle planHandle;
155+ size_t clLengths[1] = {N};
156+
157+ /* Create a default plan for a complex FFT. */
158+ err = clfftCreateDefaultPlan(&planHandle, handle.get_context(), CLFFT_1D, clLengths);
159+
160+ /* Set plan parameters. */
161+ err = clfftSetPlanPrecision(planHandle, CLFFT_SINGLE);
162+ err = clfftSetLayout(planHandle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED);
163+ err = clfftSetResultLocation(planHandle, CLFFT_INPLACE);
164+
165+ /* Bake the plan. */
166+ err = clfftBakePlan(planHandle, 1, &queue, NULL, NULL);
167+
168+ /* Execute the plan. */
169+ cl_command_queue queue = handle.get_queue();
170+ cl_mem X_mem = handle.get_buffer(X_accessor);
171+ err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD,
172+ 1, &queue, 0, NULL, NULL,
173+ &X_mem, NULL, NULL);
174+
175+ /* Wait for calculations to be finished. */
176+ err = clFinish(queue);
177+
178+ /* Release the plan. */
179+ err = clfftDestroyPlan( &planHandle );
180+ });
181+ });
182+
183+ /* Release clFFT library. */
184+ clfftTeardown( );
185+
186+ return 0;
187+ }
188+ ```
0 commit comments