Skip to content

Compiler Flags

Robert Bird edited this page Jan 14, 2019 · 7 revisions

The section address the following two compilers:

  1. Intel (icpc);
  2. GNU/GCC (g++);

However please note different/additional compilers are supported (if you find any issues with a specific compiler, please let us know)

Platform Specific Options

For VPIC to obtain good performance (a factor of more than 2x), you need to ensure two things:

  1. The correct vector width has been selected for the platform during compilation
  2. The correct compiler flags were used for the platform (in addition to a RELEASE cmake build, which enables -O3 by default)

This means that for good performance, you must compile VPIC on a per-platform basis

Specifying Compiler Optimization Flags

CMake offers native support for user defined compiler optimization flags through the CMAKE_CXX_FLAGS variable. Users should set the variable when invoking CMake to compile the core VPIC library. This will likely look something like:

cmake -DCMAKE_CXX_FLAGS="-rdynamic" ..

Currently users may see a performance benefit from also setting CMAKE_C_FLAGS (same flags) for the pure C portion of VPIC, however this will ultimately be phased out in favor of pure C++.

Intel

To generate correct code for #2 above (when not cross-compiling) the user can use -XHost.

The following flags have been shown to give good performance on modern intel architectures:

-O3 -rdynamic -inline-forceinline -qoverride-limits -no-ansi-alias -xHost

GCC

To generate correct code for #2 above (when not cross-compiling) the user can use -march=native.

Additionally GCC requires the use of -fno-strict-aliasing for correct results.

A following is good initial attempt at compiling for GCC:

-O3 -rdynamic -fno-strict-aliasing

Clone this wiki locally