I am trying to achieve better performance for FFTW operations. For that reason I decided to use wisdom files for plan creation, but the problem is that it can't load the plans from wisdom files (exporting wisdoms works well). I tried to export the wisdom to a file and on the next program run to load it backthe wisdom file, but the function always returns 0 for any filename (even for non existing ones). I also tried it with loading from a string but it doesn't work either.
There seem to be similar questions asked here, but none of them are answered or the problem was somewhere else. So is this a bug from the library, or am I doing something wrong?
EDIT Only for demonstration and to see if the export functions really work: The code below shows the operation for loading the wisdom from a string using a file for content import (only to show that the content is available in the file):
FILE * pfile;
vector<char> buffer;
pfile=fopen("WisdomFile.txt","r");
if(pfile==0)
cout<<"Could not open file"<<endl;
else
cout<<"Could open file successfully"<<endl;
long length;
if(pfile)
{
fseek(pfile,0,SEEK_END);
length=ftell(pfile);
fseek(pfile,0,SEEK_SET);
buffer.assign(length+1,'\0'); //allocate space with the same length as the file
int n=fread(&buffer[0],1,length,pfile); //read whole file to the buffer
assert(n==length);
fclose(pfile);
}
string show_wisdom(buffer);
cout<<show_wisdom<<endl; //content could be read
int ret=fftwf_import_wisdom_from_string(reinterpret_cast<const char*>(&buffer[0])); // returns 0 for every filename
buffer.clear();
//... further FFTW code trying to use `FFTW_PATIENT | FFTW_USE_WISDOM_ONLY` ->but never uses the wisdom file
The output is the following:
(fftw-3.3.4 fftwf_wisdom #xbedb7e38 #x1ac524dc #x7a69378e #x21629161
(fftwf_codelet_t2_8 3 #x11048 #x11048 #x0 #xa75017ef #xb6eb4747 #x4bef8a59 #xb03d9427)
(fftwf_dft_thr_vrank_geq1_register 1 #x11048 #x11048 #x0 #x27a0c32d #x4e3441f9 #xb3fb3f2d #x90ae8374)
(fftwf_dft_vrank_geq1_register 0 #x11048 #x11048 #x0 #x9be02645 #x53c7643d #xf6cf9608 #xed5460b7)
(fftwf_dft_r2hc_register 0 #x11048 #x11048 #x0 #x52a71bc4 #x3c83e70d #x942dd977 #xf047f7e9)
(fftwf_codelet_n1_64 0 #x11448 #x11448 #x0 #x11559ac4 #xea86db86 #xad6ae8e4 #x97f477c6)
(fftwf_codelet_t1_16 0 #x11048 #x11048 #x0 #x8811820f #xea00b698 #x861ae7ed #x109ec45a)
(fftwf_rdft_rank0_register 2 #x11048 #x11048 #x0 #x0095ff64 #x86e47338 #x76e9cf55 #x6cde6434)
(fftwf_codelet_t1_16 1 #x11048 #x11048 #x0 #x29eda2bf #x97038fb2 #x0eddb089 #xafc2b57e)
(fftwf_dft_indirect_register 0 #x11048 #x11048 #x0 #x1bea55f5 #x48417896 #x04bc4c58 #x571ce0b9)
(fftwf_dft_thr_vrank_geq1_register 0 #x11048 #x11048 #x0 #x7b53c8cd #xda17faa2 #x220c1322 #x7c207bbd)
)
So as shown above the exporting functions seem to work, but importing it as shown in the FFTW tutorial does not seem to have an effect (the program still tries to create a new plan with the FFTW_PATIENT option which takes about 5 minutes.
I was having this issue until I noticed that I was using the function void fftw_set_timelimit(double seconds)
to limit the total plan creation time. Wisdom generated with this time limit in place couldn't be loaded whereas that generated with the time limit disabled could be loaded. This seems to be the case even if the time limit isn't exceeded.
As your code has been edited, I am unsure if this applies to your specific problem, however others may find this useful.