1

This snippet of code reads in a bit of unformatted, double precision data, and returns a real FFTW on it:

#include <stdio.h>
#include <fftw3.h>

#include <fcntl.h>
#include <unistd.h>

int main() {

   int i, fdin;
   int count=128;
   static fftw_plan fplan=0;
   double alldata[2][count];

   fdin = open("rand_walk.dat", O_RDONLY);
   read(fdin, alldata[0], sizeof(double)*count);

   fplan = fftw_plan_r2r_1d(count, alldata[0],
                            alldata[1], FFTW_R2HC, FFTW_ESTIMATE);
   fftw_execute_r2r(fplan, alldata[0], alldata[1]);

   printf("%lf\n",alldata[0][0]);
   printf("%lf\n",alldata[1][10]);

   return 0;

}

It works just fine when compiled under GNU or Cray. When compiled under Intel, it runs without any error message, but the output array (alldata[1])is filled with zeros. Apparently, there is something about FFTW3 with Intel that I don't understand. Anyone know what that might be? BTW, switching to FFTW2 is not an option on the platform I have to work on.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
  • 1
    Please start with proper error handling. Are you sure the input file is opened properly? You never check it. – Eugene Sh. Apr 26 '21 at 15:11
  • @EugeneSh. I am trying to keep the displayed code as short as possible, as I have often been asked to to. FWIW, I have tested and the file opens and reads correctly. – bob.sacamento Apr 26 '21 at 15:28
  • 2
    That's fine, but you should make sure the code presented is not introducing issues the original code does not have. Unfortunately we can't "believe" something that is not explicitly present in the code, and it is not personal but based on the experience of numerous other questions. Also this should be a [mcve], that is if you claim *(`alldata[1]`)is filled with zeros* then please show the code which is showing this array being all zeros. – Eugene Sh. Apr 26 '21 at 15:34
  • For a minimal example, just hardcode an array. It's trivial that a non-zero input must have a non-zero output, so just setting `alldata[0][0] = 1.0;` is sufficient. – MSalters May 06 '21 at 09:45
  • @bob.sacamento - any chance you ever got to the bottom of this issue? I believe I'm having a similar [issue here](https://github.com/msummersgill/RfCWT#mkl-compatibility) – Matt Summersgill Jul 28 '23 at 22:25
  • @MattSummersgill Sorry. I just moved on to other projects. Don't remember if I solved it ever. – bob.sacamento Aug 06 '23 at 01:16

1 Answers1

1

I have tried with

#include <stdio.h>
#include <fftw3.h>

#include <fcntl.h>
#include <unistd.h>

int main() {

   int i, fdin;
   int count=2;
   static fftw_plan fplan=0;
   double alldata[2][2]={1,1,1,1};
 fplan = fftw_plan_r2r_1d(count, alldata[0],
                            alldata[1], FFTW_R2HC, FFTW_ESTIMATE);
   fftw_execute_r2r(fplan, alldata[0], alldata[1]);

   printf("%lf\n",alldata[0][0]);
   printf("%lf\n",alldata[1][0]);

   return 0;

}

and compiled with the command: icpc -mkl -I"${MKLROOT}/include/fftw" sample.cpp and got 1.0 and 1.0. as the result.