我正努力为FFTW业务取得更好的性能。因此,我决定使用智慧文件来创建计划,但问题是它不能从智慧文件(导出智慧文件)加载计划。我试图将智慧导出到一个文件中,然后在下一个程序运行时将它加载回智慧文件,但是函数总是对任何文件名返回0(即使是不存在的文件名)。我也尝试过从字符串加载它,但是它也不起作用。
这里似乎有类似的问题,但没有人回答,或者问题在别的地方。这是图书馆的错误,还是我做错了什么?
编辑仅用于演示,并查看导出函数是否真正有效:下面的代码显示了使用用于内容导入的文件从字符串加载智慧的操作(仅显示该文件中的内容可用):
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输出如下:
(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)
)因此,如上面所示,导出函数似乎有效,但导入它(如FFTW教程中所示)似乎没有效果(该程序仍然试图使用FFTW_PATIENT选项创建一个新计划,大约需要5分钟。
发布于 2016-06-17 15:19:19
我一直有这个问题,直到我注意到我正在使用函数void fftw_set_timelimit(double seconds)来限制整个计划创建时间。在此时间限制下生成的智慧无法加载,而禁用时间限制时生成的智慧则可以加载。即使没有超过时限,情况似乎也是如此。
由于您的代码已被编辑,我不确定这是否适用于您的特定问题,但其他人可能会发现这是有用的。
发布于 2015-07-02 21:40:04
根据FFTW文件
智慧是自动用于任何大小,它是适用的,只要规划师旗帜不是更多的“耐心”,与那些智慧被创造出来。
换句话说,如果您想要导入使用FFTW_PATIENT标志创建计划的智慧,则必须将智慧导出到具有相同大小并使用FFTW_PATIENT或FFTW_EXHAUSTIVE标志创建的计划。
然后,首先提前制定一个计划,然后用以下方式输出智慧:
// Might as well use FFTW_EXHAUSTIVE if we can afford it ahead of time
fftw_plan plan = fftw_plan_dft_r2c_1d(N, in, out, FFTW_EXHAUSTIVE);
fftw_export_wisdom_to_filename("WisdomFile.txt");最后,输出的智慧可以导入并用于:
if (!fftw_import_wisdom_from_filename("WisdomFile.txt"))
{
std::cout << "Warning: could not import wisdom file" << std::endl;
}
// plan can now be created with any flags less or equal to
// FFTW_EXHAUSTIVE used for the exported wisdom.
fftw_plan plan = fftw_plan_dft_r2c_1d(N, in, out, FFTW_PATIENT);https://stackoverflow.com/questions/31137672
复制相似问题