# Setting the CPU architecture for optimal performance

**URL:** <https://community.mrtrix.org/t/setting-the-cpu-architecture-for-optimal-performance/3550>\
**Category:** Wiki\
**Tags:** performance, installation\
**Created:** [April 22, 2020, 10:24am UTC](https://community.mrtrix.org/t/setting-the-cpu-architecture-for-optimal-performance/3550 "2020-04-22T10:24:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [April 22, 2020, 10:24am UTC](https://community.mrtrix.org/t/setting-the-cpu-architecture-for-optimal-performance/3550/1 "2020-04-22T10:24:27Z")

</div>

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](http://eigen.tuxfamily.org) 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:

```auto
export ARCH=native
./configure
./build

```

For more specific architectures, you can provide any value from the [list of specifiers understood by the compiler](https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/x86-Options.html#x86-Options), for example `ARCH='sandybridge' ./configure`
