device_id¶
Defined in header <Kokkos_Core.hpp>
Usage¶
Kokkos::device_id();
Returns the id of the device that is used by DefaultExecutionSpace, or
-1 if only host backends are enabled.
Interface¶
-
[[nodiscard]] int device_id() noexcept¶
- Returns:
The id of the device used by
DefaultExecutionSpace, or-1if only host backends are enabled.
Added in version 4.1.
Example¶
#include <Kokkos_Core.hpp>
#include <iostream>
int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
{
std::cout << "device_id: " << Kokkos::device_id() << '\n';
}
Kokkos::finalize();
}
See Also¶
See also
- num_devices
Returns the number of devices available to Kokkos
- num_threads
Returns the number of threads used by Kokkos
- print_configuration
Prints Kokkos configuration information to an output stream
- initialize
Initialize the Kokkos execution environment
- InitializationSettings
Settings for initializing Kokkos