2 Replies Latest reply on Nov 28, 2012 3:16 AM by tim.dahmen

    confusion about correct use of CLFFT_BACKWARD


      I am trying to build a filter in frequency space. The general plan ist:


      - perform a forward FFT

      - do my stuff

      - perform a back FFT


      I am using a 2D transform with the layout input: CLFFT_REAL output CLFFT_HERMITIAN_PLANAR. So I pass 1 input buffer (with the image) to the forward transform plus 2 output buffers, because I use CLFFT_OUTOFPLACE. After the executing, the two output buffers contain my real and imaginary result. The call looks like this:


      cl_mem inputHandle = ...;

      cl_mem outputHandle[2] = ...;

      clAmdFftEnqueueTransform( kernelPlan, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &inputHandle, &outputHandle[0], NULL );


      So far so good. Works nice.


      Now I want to convert them back to a nice real image using CLFFT_BACKWARD. I understand I can either generate a new plan or reuse the old one, just using CLFFT_BACKWARD. What I am slightly confused about is: if I use the backward direction, what is the definition of input and output? Currently I first swap input and output, and then try to call the kernel like this:


      cl_mem newInputHandle[2];

      newInputHandle[0] = outputHandle[0];

      newInputHandle[1] = outputHandle[1];

      cl_mem newOutputHandle = inputHandle;


      clAmdFftEnqueueTransform( kernelPlan, CLFFT_BACKWARD, 1, &queue, 0, NULL, NULL, &newOutputHandle, &newInputHandle[0], NULL );


      And then hope that the result (real numbers of real space) are in the output Buffer. Instead, the kernel crashes. Did I miss something?