AnsweredAssumed Answered

Different results between clAmdFft and fftw.

Question asked by msft on Jun 23, 2013
Latest reply on Aug 21, 2013 by msft

I have different results between clAmdFft and fftw.


System:

REDION HD7750

Ubuntu 12.04 LTS

clAmdFft-1.10.321.tar.gz


Code:

int main()

{

        OpenCLInit();

        static const size_t N = 32;

        fftw_complex* inputData = (fftw_complex*)fftw_malloc(sizeof(double)*2*N);

        fftw_complex* fftw_fourierData = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*N);

        fftw_plan c2c_fftw = fftw_plan_dft_1d((int)N, (fftw_complex*) inputData,(fftw_complex*) fftw_fourierData, FFTW_FORWARD,FFTW_ESTIMATE);

        for (size_t x = 0; x < N; ++x)

        {

                inputData[x][0] = x;

                inputData[x][1] = x;

        }

        fftw_execute(c2c_fftw);

        printf("fftw   %.15e %.15e \n",fftw_fourierData[1][0],fftw_fourierData[1][1]);

        clAmdFftStatus status;

        EFailedStep failedStep;

        clAmdFftPlanHandle c2c = clAMD_plan_c2c_1d(m_context,N,1,&m_cmdQueue,&status,&failedStep);

        cl_int clstatus;

        cl::Buffer inputBuffer(m_context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,sizeof(double)*2*N,inputData, &clstatus);

        cl::Buffer fourierBuffer(m_context, CL_MEM_READ_WRITE | CL_MEM_HOST_READ_ONLY, N*sizeof(fftw_complex), NULL, &clstatus);

        status = clAmdFftEnqueueTransform(c2c, CLFFT_FORWARD,1,&m_cmdQueue(),0,NULL,NULL, &inputBuffer(),&fourierBuffer(), NULL);

                // Read result from device to host.

        fftw_complex fourierData[N];

        clstatus = m_cmdQueue.enqueueReadBuffer(fourierBuffer,CL_TRUE,0,sizeof(fourierData),fourierData);

        printf("AmdFft %.15e %.15e \n",fourierData[1][0],fourierData[1][1]);

        fftw_destroy_plan(c2c_fftw);

        clAmdFftDestroyPlan(&c2c);

        clAmdFftTeardown();

        fftw_free(inputData);

        fftw_free(fftw_fourierData);

        return 0;

}

 

Result:

fftw   -1.784507262017418e+02 1.464507262017418e+02

AmdFft -1.784507251938066e+02 1.464507243160278e+02

 

Thank you,

Attachments

Outcomes