Compilation errors when FFTW is not available
I tried to compile a fresh copy of SWIFT on my new laptop and ran into some compilation issues.
With ./configure
, the compilation fails on target swift_mpi
. That makes sense, since there is no MPI library, which is also correctly detected by ./configure
. Why do we attempt to compile swift_mpi
if no MPI library was detected?
With ./configure --disable-mpi
, I get the following errors from the power spectrum code:
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include/hdf5/serial -fopenmp -O3 -fomit-frame-pointer -malign-double -fstrict-aliasing -ffast-math -funroll-loops -march=core2 -mavx512vbmi -pthread -Wall -Wextra -Wno-unused-parameter -Wshadow -Werror -Wstrict-prototypes -MT libswiftsim_la-power_spectrum.lo -MD -MP -MF .deps/libswiftsim_la-power_spectrum.Tpo -c -o libswiftsim_la-power_spectrum.lo `test -f 'power_spectrum.c' || echo './'`power_spectrum.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include/hdf5/serial -fopenmp -O3 -fomit-frame-pointer -malign-double -fstrict-aliasing -ffast-math -funroll-loops -march=core2 -mavx512vbmi -pthread -Wall -Wextra -Wno-unused-parameter -Wshadow -Werror -Wstrict-prototypes -MT libswiftsim_la-power_spectrum.lo -MD -MP -MF .deps/libswiftsim_la-power_spectrum.Tpo -c power_spectrum.c -o libswiftsim_la-power_spectrum.o
In file included from power_spectrum.c:34:
power_spectrum.h:113:33: error: unknown type name ‘FILE’
113 | FILE* stream);
| ^~~~
power_spectrum.h:24:1: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
23 | #include <config.h>
+++ |+#include <stdio.h>
24 |
power_spectrum.h:114:67: error: unknown type name ‘FILE’
114 | void power_spectrum_struct_restore(struct power_spectrum_data* p, FILE* stream);
| ^~~~
power_spectrum.h:114:67: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
power_spectrum.c: In function ‘power_init’:
power_spectrum.c:196:16: error: implicit declaration of function ‘fftw_alloc_real’ [-Werror=implicit-function-declaration]
196 | p->powgrid = fftw_alloc_real(Ngrid * Ngrid * (Ngrid + 2));
| ^~~~~~~~~~~~~~~
power_spectrum.c:196:14: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
196 | p->powgrid = fftw_alloc_real(Ngrid * Ngrid * (Ngrid + 2));
| ^
power_spectrum.c:198:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
198 | p->powgridft = (fftw_complex*)p->powgrid;
| ^~~~~~~~~
| powgrid
power_spectrum.c:198:19: error: ‘fftw_complex’ undeclared (first use in this function)
198 | p->powgridft = (fftw_complex*)p->powgrid;
| ^~~~~~~~~~~~
power_spectrum.c:198:19: note: each undeclared identifier is reported only once for each function it appears in
power_spectrum.c:198:32: error: expected expression before ‘)’ token
198 | p->powgridft = (fftw_complex*)p->powgrid;
| ^
power_spectrum.c:200:4: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow’
200 | p->fftplanpow = fftw_plan_dft_r2c_3d(Ngrid, Ngrid, Ngrid, p->powgrid,
| ^~
power_spectrum.c:200:19: error: implicit declaration of function ‘fftw_plan_dft_r2c_3d’ [-Werror=implicit-function-declaration]
200 | p->fftplanpow = fftw_plan_dft_r2c_3d(Ngrid, Ngrid, Ngrid, p->powgrid,
| ^~~~~~~~~~~~~~~~~~~~
power_spectrum.c:201:43: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
201 | p->powgridft, FFTW_MEASURE);
| ^~~~~~~~~
| powgrid
power_spectrum.c:201:54: error: ‘FFTW_MEASURE’ undeclared (first use in this function)
201 | p->powgridft, FFTW_MEASURE);
| ^~~~~~~~~~~~
power_spectrum.c:203:3: error: implicit declaration of function ‘fftw_free’ [-Werror=implicit-function-declaration]
203 | fftw_free(p->powgrid);
| ^~~~~~~~~
power_spectrum.c:205:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
205 | p->powgridft = NULL;
| ^~~~~~~~~
| powgrid
power_spectrum.c:210:15: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
210 | p->powgrid2 = fftw_alloc_real(Ngrid * Ngrid * (Ngrid + 2));
| ^
power_spectrum.c:212:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
212 | p->powgridft2 = (fftw_complex*)p->powgrid2;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:212:33: error: expected expression before ‘)’ token
212 | p->powgridft2 = (fftw_complex*)p->powgrid2;
| ^
power_spectrum.c:214:4: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow2’
214 | p->fftplanpow2 = fftw_plan_dft_r2c_3d(Ngrid, Ngrid, Ngrid, p->powgrid2,
| ^~
power_spectrum.c:215:44: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
215 | p->powgridft2, FFTW_MEASURE);
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:219:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
219 | p->powgridft2 = NULL;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c: At top level:
power_spectrum.c:271:3: error: unknown type name ‘fftw_complex’
271 | fftw_complex* powgridft;
| ^~~~~~~~~~~~
power_spectrum.c:272:3: error: unknown type name ‘fftw_complex’
272 | fftw_complex* powgridft2;
| ^~~~~~~~~~~~
power_spectrum.c: In function ‘pow_from_grid_mapper’:
power_spectrum.c:832:3: error: unknown type name ‘fftw_complex’
832 | fftw_complex* restrict powgridft = data->powgridft;
| ^~~~~~~~~~~~
power_spectrum.c:833:3: error: unknown type name ‘fftw_complex’
833 | fftw_complex* restrict powgridft2 = data->powgridft2;
| ^~~~~~~~~~~~
power_spectrum.c:846:25: error: ‘fftw_complex’ undeclared (first use in this function)
846 | const int xi_start = (fftw_complex*)map_data - powgridft;
| ^~~~~~~~~~~~
power_spectrum.c:846:38: error: expected expression before ‘)’ token
846 | const int xi_start = (fftw_complex*)map_data - powgridft;
| ^
power_spectrum.c:894:43: error: subscripted value is neither array nor pointer nor vector
894 | (powgridft[index][0] * powgridft2[index][0] +
| ^
power_spectrum.c:894:66: error: subscripted value is neither array nor pointer nor vector
894 | (powgridft[index][0] * powgridft2[index][0] +
| ^
power_spectrum.c:895:43: error: subscripted value is neither array nor pointer nor vector
895 | powgridft[index][1] * powgridft2[index][1]));
| ^
power_spectrum.c:895:66: error: subscripted value is neither array nor pointer nor vector
895 | powgridft[index][1] * powgridft2[index][1]));
| ^
power_spectrum.c: In function ‘power_spectrum’:
power_spectrum.c:1015:21: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
1015 | pow_data->powgrid = fftw_alloc_real(Ngrid2 * (Ngrid + 2));
| ^
power_spectrum.c:1018:13: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1018 | pow_data->powgridft = (fftw_complex*)pow_data->powgrid;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1018:26: error: ‘fftw_complex’ undeclared (first use in this function)
1018 | pow_data->powgridft = (fftw_complex*)pow_data->powgrid;
| ^~~~~~~~~~~~
power_spectrum.c:1018:39: error: expected expression before ‘)’ token
1018 | pow_data->powgridft = (fftw_complex*)pow_data->powgrid;
| ^
power_spectrum.c:1020:24: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
1020 | pow_data->powgrid2 = fftw_alloc_real(Ngrid2 * (Ngrid + 2));
| ^
power_spectrum.c:1023:15: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1023 | pow_data->powgridft2 = (fftw_complex*)pow_data->powgrid2;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1023:42: error: expected expression before ‘)’ token
1023 | pow_data->powgridft2 = (fftw_complex*)pow_data->powgrid2;
| ^
power_spectrum.c:1026:15: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1026 | pow_data->powgridft2 = pow_data->powgridft;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1026:38: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1026 | pow_data->powgridft2 = pow_data->powgridft;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1135:36: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1135 | powmapdata.powgridft = pow_data->powgridft;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1136:37: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1136 | powmapdata.powgridft2 = pow_data->powgridft2;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1241:7: error: implicit declaration of function ‘fftw_execute_dft_r2c’ [-Werror=implicit-function-declaration]
1241 | fftw_execute_dft_r2c(pow_data->fftplanpow, pow_data->powgrid,
| ^~~~~~~~~~~~~~~~~~~~
power_spectrum.c:1241:36: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow’
1241 | fftw_execute_dft_r2c(pow_data->fftplanpow, pow_data->powgrid,
| ^~
power_spectrum.c:1242:38: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1242 | pow_data->powgridft);
| ^~~~~~~~~
| powgrid
power_spectrum.c:1244:38: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow2’
1244 | fftw_execute_dft_r2c(pow_data->fftplanpow2, pow_data->powgrid2,
| ^~
power_spectrum.c:1245:40: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1245 | pow_data->powgridft2);
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1247:40: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1247 | powmapdata.powgridft = pow_data->powgridft;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1248:41: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1248 | powmapdata.powgridft2 = pow_data->powgridft2;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1256:40: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1256 | pow_from_grid_mapper(pow_data->powgridft, Ngrid, &powmapdata);
| ^~~~~~~~~
| powgrid
power_spectrum.c:1258:60: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1258 | threadpool_map(tp, pow_from_grid_mapper, pow_data->powgridft, Ngrid,
| ^~~~~~~~~
| powgrid
power_spectrum.c:1351:13: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1351 | pow_data->powgridft2 = NULL;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1355:13: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1355 | pow_data->powgridft = NULL;
| ^~~~~~~~~
| powgrid
power_spectrum.c: In function ‘power_clean’:
power_spectrum.c:1381:3: error: implicit declaration of function ‘fftw_destroy_plan’ [-Werror=implicit-function-declaration]
1381 | fftw_destroy_plan(pow_data->fftplanpow);
| ^~~~~~~~~~~~~~~~~
power_spectrum.c:1381:29: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow’
1381 | fftw_destroy_plan(pow_data->fftplanpow);
| ^~
power_spectrum.c:1382:29: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow2’
1382 | fftw_destroy_plan(pow_data->fftplanpow2);
| ^~
power_spectrum.c: In function ‘power_spectrum_struct_restore’:
power_spectrum.c:1444:14: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
1444 | p->powgrid = fftw_alloc_real(Ngrid * Ngrid * (Ngrid + 2));
| ^
power_spectrum.c:1446:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1446 | p->powgridft = (fftw_complex*)p->powgrid;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1446:19: error: ‘fftw_complex’ undeclared (first use in this function)
1446 | p->powgridft = (fftw_complex*)p->powgrid;
| ^~~~~~~~~~~~
power_spectrum.c:1446:32: error: expected expression before ‘)’ token
1446 | p->powgridft = (fftw_complex*)p->powgrid;
| ^
power_spectrum.c:1448:4: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow’
1448 | p->fftplanpow = fftw_plan_dft_r2c_3d(Ngrid, Ngrid, Ngrid, p->powgrid,
| ^~
power_spectrum.c:1449:43: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1449 | p->powgridft, FFTW_MEASURE);
| ^~~~~~~~~
| powgrid
power_spectrum.c:1449:54: error: ‘FFTW_MEASURE’ undeclared (first use in this function)
1449 | p->powgridft, FFTW_MEASURE);
| ^~~~~~~~~~~~
power_spectrum.c:1453:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft’; did you mean ‘powgrid’?
1453 | p->powgridft = NULL;
| ^~~~~~~~~
| powgrid
power_spectrum.c:1458:15: error: assignment to ‘double *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
1458 | p->powgrid2 = fftw_alloc_real(Ngrid * Ngrid * (Ngrid + 2));
| ^
power_spectrum.c:1460:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1460 | p->powgridft2 = (fftw_complex*)p->powgrid2;
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1460:33: error: expected expression before ‘)’ token
1460 | p->powgridft2 = (fftw_complex*)p->powgrid2;
| ^
power_spectrum.c:1462:4: error: ‘struct power_spectrum_data’ has no member named ‘fftplanpow2’
1462 | p->fftplanpow2 = fftw_plan_dft_r2c_3d(Ngrid, Ngrid, Ngrid, p->powgrid2,
| ^~
power_spectrum.c:1463:44: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1463 | p->powgridft2, FFTW_MEASURE);
| ^~~~~~~~~~
| powgrid2
power_spectrum.c:1467:6: error: ‘struct power_spectrum_data’ has no member named ‘powgridft2’; did you mean ‘powgrid2’?
1467 | p->powgridft2 = NULL;
| ^~~~~~~~~~
| powgrid2
cc1: all warnings being treated as errors
The first one seems to be a missing #include <stdio.h>
in power_spectrum.h
. The second is more problematic: the power spectrum code uses FFTW function calls without checking HAVE_FFTW
.