Utilities

Error Handling and Diagnostics

Kokkos provides utility functions for error handling, debugging, and output that work consistently across host and device code.

abort

Terminates the program immediately with an error message.

KOKKOS_ASSERT

Aborts the program if the user-specified condition is not true. Behavior depends on NDEBUG and KOKKOS_ENABLE_DEBUG macros.

printf

Prints formatted output to the standard output stream.

Runtime and Device Information

Kokkos provides utility functions to query runtime information about the Kokkos execution environment.

device_id

Returns the id of the device used by DefaultExecutionSpace.

num_devices

Returns the number of devices available to Kokkos.

num_threads

Returns the number of threads used by DefaultHostExecutionSpace.

print_configuration

Prints the Kokkos compile-time and runtime configuration to an output stream.

Other