Macros¶
Including <Kokkos_Macros.hpp> (which <Kokkos_Core.hpp> does) gives access
to two kinds of macros.
Always-defined macros¶
These macros are defined by every Kokkos build. They are meant to be used directly in application code, to mark functions, to select host or device code, or to check the Kokkos version.
Page |
Content |
|---|---|
|
|
|
|
|
Configuration macros¶
These macros let you introspect how Kokkos was configured, for example which
backends are enabled. Unlike the macros above, they are defined only if the
corresponding option was enabled, so test them with #ifdef or
#if defined(...).
Page |
Content |
|---|---|
Debugging, deprecation, tuning, C++ standard and third-party libraries. |
|
Which execution spaces are enabled, and backend-specific options. |
|
|
Relationship with CMake configuration options¶
The KOKKOS_ENABLE_* and KOKKOS_ARCH_* macros are, for the most part, the counterpart of a
CMake option documented in the Configuration Guide. The names follow a simple rule:
CMake option |
Macro |
|---|---|
|
|
|
|
|
|
These macros are either defined or not: test them with #if defined(...),
#ifdef or #ifndef, not with their value. Options that are OFF leave the
macro undefined. Exceptions to the naming rule, and macros that have no CMake
counterpart, are called out on each page.
#include <Kokkos_Core.hpp>
#ifdef KOKKOS_ENABLE_CUDA
// Kokkos was configured with -DKokkos_ENABLE_CUDA=ON
#endif