Setting the CPU architecture for optimal performance

When building from source, configure will by default cause the build script to produce generic code
suitable for any current CPU. If you want to ensure optimal performance on your system, you can request that configure produce code tailored to your specific CPU architecture, which will allow it to use all available CPU instructions and tune the code differently. This can improve performance particularly for linear algebra operations since Eigen will then make use of these extensions.

However, note that this means the executables produced will likely not run on different CPUs with different instruction sets, resulting in ‘illegal instruction’ runtime errors. If you intend to run MRtrix3 on a variety of different systems with a range of CPUs, or you have no idea what the CPU is on your target system, it is safest to avoid changing the default.

Specifying a different CPU architecture is done by setting the ARCH environment variable prior to invoking ./configure. The value of this variable will then be passed to the compiler via the -march option. To get the best performance on the current system, you can specify native as the architecture, leaving it up to the compiler to detect your particular CPU and its available instructions. For example:

export ARCH=native
./configure
./build

For more specific architectures, you can provide any value from the list of specifiers understood by the compiler, for example ARCH='sandybridge' ./configure