[cmake-developers] CMake Var for Specific Processor Type

Axel Huebl a.huebl at hzdr.de
Fri Oct 6 05:42:55 EDT 2017

Dear CMake List,

we are building HPC software with CMake. In many cases, we find that the
performance of (auto)vectorization heavy code depends greatly on
specifying the exact processor generation for optimally tuned binaries.
That is no surprise, since a compiler's architecture flags just group an
according set of available instructions for e.g. SIMD extensions.

The question now is: Is there a generic CMake best-practice to specify
the *exact* architecture -mtune/-march/-mcpu/-qarch/-x/... flags,
ideally according to the currently used compiler (icc,gcc,xlc,pgc,...)
just from the name of the processor generation?

CMAKE_SYSTEM_PROCESSOR looks like it but its documentation is a bit
short. Does it allow me to set details such as "bdver1", "corei7-avx" or
"core-avx2" as targets (instead of generic "x86_64")?

Note: Portability of binaries is not relevant since we can re-compile
for each system (and have performance portable source code).

Vice versa, is there a way already for setting the CUDA compute
capabilities of a target via a CMake variable?

For both cases, we currently hijack CXX flags and do switches on
compilers, which is probably not the most generic way to write
maintainable CMake scripts. For NVCC and Clang CUDA SM targets for PTX
and SASS code embedding, we just have our own CMake variable, which is
also sub-ideal for as it is not standardized.

How do you usually address this?

All the best,

Axel Huebl
Phone +49 351 260 3582
Computational Radiation Physics
Laser Particle Acceleration Division
Helmholtz-Zentrum Dresden - Rossendorf e.V.

Bautzner Landstrasse 400, 01328 Dresden
POB 510119, D-01314 Dresden
Vorstand: Prof. Dr.Dr.h.c. R. Sauerbrey
          Prof. Dr.Dr.h.c. P. Joehnk
VR 1693 beim Amtsgericht Dresden

More information about the cmake-developers mailing list