| 1 |
Libsharp is configured, compiled and installed using GNU autotools. |
| 2 |
|
| 3 |
If you have cloned the libsharp repository, you have to run |
| 4 |
"autoreconf -i" before starting the configuration, which requires several |
| 5 |
GNU developer tools to be available on your system. |
| 6 |
|
| 7 |
When using a release tarball, configuration is done via |
| 8 |
|
| 9 |
[CC=...] [CFLAGS=...] ./configure |
| 10 |
|
| 11 |
The following sections briefly describe possible choices for compilers and |
| 12 |
flags. |
| 13 |
|
| 14 |
|
| 15 |
Fast math |
| 16 |
--------- |
| 17 |
|
| 18 |
Specifying "-ffast-math" is important for all compilers, since it allows the |
| 19 |
compiler to fuse multiplications and additions into FMA instructions, which is |
| 20 |
forbidden by the C99 standard. Since FMAs are a central aspect of the algorithm, |
| 21 |
they are needed for optimum performance. |
| 22 |
|
| 23 |
If you are calling libsharp from other code which requires strict adherence |
| 24 |
to the C99 standard, you should still be able to compile libsharp with |
| 25 |
"-ffast-math" without any problems. |
| 26 |
|
| 27 |
|
| 28 |
Runtime CPU selection with gcc |
| 29 |
------------------------------ |
| 30 |
|
| 31 |
When using a recent gcc (6.0 and newer) or a recent clang (successfully tested |
| 32 |
with versions 6 and 7) on an x86_64 platform, the build machinery can compile |
| 33 |
the time-critical functions for several different architectures (SSE2, AVX, |
| 34 |
AVX2, FMA3, FMA4, AVX512F), and the appropriate implementation will be selected |
| 35 |
at runtime. |
| 36 |
This feature is enabled automatically by the configure script on x86_64 |
| 37 |
platforms. If it fails, please use the "--disable-multiarch" flag in the |
| 38 |
configure invocation. |
| 39 |
If this feature is enabled, please do _not_ specify "-march=native" or |
| 40 |
"-mtarget=avx" or similar! |
| 41 |
If you are compiling libsharp for a particular target CPU only, or if you are |
| 42 |
using a different compiler, however, "-march-native" should be used. The |
| 43 |
resulting binary will most likely not run on other computers, though. |
| 44 |
|
| 45 |
|
| 46 |
OpenMP |
| 47 |
------ |
| 48 |
|
| 49 |
OpenMP should be switched on for maximum performance, and at runtime |
| 50 |
OMP_NUM_THREADS should be set to the number of hardware threads (not physical |
| 51 |
cores) of the system. |
| 52 |
(Usually this is already the default setting when OMP_NUM_THREADS is not |
| 53 |
specified.) |
| 54 |
|
| 55 |
|
| 56 |
MPI |
| 57 |
--- |
| 58 |
|
| 59 |
MPI support is enabled by using the MPI compiler (typically "mpicc") _and_ |
| 60 |
adding the flag "-DUSE_MPI". |
| 61 |
When using MPI and OpenMP simultaneously, the product of MPI tasks per node |
| 62 |
and OMP_NUM_THREADS should be equal to the number of hardware threads available |
| 63 |
on the node. One MPI task per node should result in the best performance. |
| 64 |
|
| 65 |
|
| 66 |
Example configure invocations |
| 67 |
============================= |
| 68 |
|
| 69 |
GCC, OpenMP, portable binary: |
| 70 |
CFLAGS="-std=c99 -O3 -ffast-math -fopenmp" ./configure |
| 71 |
|
| 72 |
GCC, no OpenMP, portable binary: |
| 73 |
CFLAGS="-std=c99 -O3 -ffast-math" ./configure |
| 74 |
|
| 75 |
Clang, OpenMP, portable binary: |
| 76 |
CC=clang CFLAGS="-std=c99 -O3 -ffast-math -fopenmp" ./configure |
| 77 |
|
| 78 |
Intel C compiler, OpenMP, nonportable binary: |
| 79 |
CC=icc CFLAGS="-std=c99 -O3 -march=native -ffast-math -fopenmp -D__PURE_INTEL_C99_HEADERS__" ./configure --disable-multiarch |
| 80 |
|
| 81 |
MPI support, nonportable binary: |
| 82 |
CC=mpicc CFLAGS="-DUSE_MPI -std=c99 -O3 -march=native -ffast-math" ./configure --disable-multiarch |
| 83 |
|
| 84 |
Additional GCC flags for pedantic warning and debugging: |
| 85 |
|
| 86 |
-Wall -Wextra -Wshadow -Wmissing-prototypes -Wfatal-errors -pedantic -g |
| 87 |
-fsanitize=address |