-
Notifications
You must be signed in to change notification settings - Fork 0
/
wisdom.c
126 lines (109 loc) · 3.52 KB
/
wisdom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* @file wisdom.c
*/
#include "CommandLineInterface/CLIcore.h"
errno_t import_wisdom()
{
FILE *fp;
char wisdom_file_single[STRINGMAXLEN_FULLFILENAME];
char wisdom_file_double[STRINGMAXLEN_FULLFILENAME];
#ifdef FFTWMT
WRITE_FULLFILENAME(wisdom_file_single,
"%s/fftwf_mt_wisdom.dat",
FFTCONFIGDIR);
WRITE_FULLFILENAME(wisdom_file_double,
"%s/fftw_mt_wisdom.dat",
FFTCONFIGDIR);
#endif
#ifndef FFTWMT
WRITE_FULLFILENAME(wisdom_file_single, "%s/fftwf_wisdom.dat", FFTCONFIGDIR);
WRITE_FULLFILENAME(wisdom_file_double, "%s/fftw_wisdom.dat", FFTCONFIGDIR);
#endif
int nowisdomWarning = 0;
if((fp = fopen(wisdom_file_single, "r")) == NULL)
{
nowisdomWarning = 1;
/*
n = snprintf(
warnmessg,
SBUFFERSIZE,
"No single precision wisdom file in %s\n FFTs will not be optimized,"
" and may run slower than if a wisdom file is used\n type \"initfft\""
" to create the wisdom file (this will take time)",
wisdom_file_single);
if(n >= SBUFFERSIZE)
PRINT_ERROR("Attempted to write string buffer with too many characters");
PRINT_WARNING(warnmessg);
*/
}
else
{
if(fftwf_import_wisdom_from_file(fp) == 0)
{
PRINT_ERROR("Error reading wisdom");
}
fclose(fp);
}
if((fp = fopen(wisdom_file_double, "r")) == NULL)
{
nowisdomWarning = 1;
/* n = snprintf(
warnmessg,
SBUFFERSIZE,
"No double precision wisdom file in %s\n FFTs will not be optimized,"
" and may run slower than if a wisdom file is used\n type \"initfft\""
" to create the wisdom file (this will take time)",
wisdom_file_double);
if(n >= SBUFFERSIZE)
PRINT_ERROR("Attempted to write string buffer with too many characters");
PRINT_WARNING(warnmessg);*/
}
else
{
if(fftw_import_wisdom_from_file(fp) == 0)
{
PRINT_ERROR("Error reading wisdom");
}
fclose(fp);
}
if(nowisdomWarning == 1)
{
printf(" [no fftw wisdom file, run initfft to create in %s]\n",
FFTCONFIGDIR);
}
return RETURN_SUCCESS;
}
errno_t export_wisdom()
{
FILE *fp;
char wisdom_file_single[STRINGMAXLEN_FULLFILENAME];
char wisdom_file_double[STRINGMAXLEN_FULLFILENAME];
EXECUTE_SYSTEM_COMMAND("mkdir -p %s", FFTCONFIGDIR);
#ifdef FFTWMT
WRITE_FULLFILENAME(wisdom_file_single,
"%s/fftwf_mt_wisdom.dat",
FFTCONFIGDIR);
WRITE_FULLFILENAME(wisdom_file_double,
"%s/fftw_mt_wisdom.dat",
FFTCONFIGDIR);
#endif
#ifndef FFTWMT
WRITE_FULLFILENAME(wisdom_file_single, "%s/fftwf_wisdom.dat", FFTCONFIGDIR);
WRITE_FULLFILENAME(wisdom_file_double, "%s/fftw_wisdom.dat", FFTCONFIGDIR);
#endif
if((fp = fopen(wisdom_file_single, "w")) == NULL)
{
PRINT_ERROR("Error creating wisdom file \"%s\"", wisdom_file_single);
abort();
}
fftwf_export_wisdom_to_file(fp);
fclose(fp);
if((fp = fopen(wisdom_file_double, "w")) == NULL)
{
PRINT_ERROR("Error creating wisdom file \"%s\"", wisdom_file_double);
abort();
}
fftw_export_wisdom_to_file(fp);
fclose(fp);
return RETURN_SUCCESS;
}