CMS 3D CMS Logo

devices.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_AlpakaInterface_interface_devices_h
2 #define HeterogeneousCore_AlpakaInterface_interface_devices_h
3 
4 #include <vector>
5 
6 #include <alpaka/alpaka.hpp>
7 
9 
10 namespace cms::alpakatools {
11 
12  // returns the alpaka accelerator platform
13  template <typename TPlatform, typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
14  inline TPlatform const& platform() {
15  // initialise the platform the first time that this function is called
16  static const auto platform = TPlatform{};
17  return platform;
18  }
19 
20  // return the alpaka accelerator devices for the given platform
21  template <typename TPlatform, typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
22  inline std::vector<alpaka::Dev<TPlatform>> const& devices() {
23  // enumerate all devices the first time that this function is called
24  static const auto devices = alpaka::getDevs(platform<TPlatform>());
25  return devices;
26  }
27 
28 } // namespace cms::alpakatools
29 
30 #endif // HeterogeneousCore_AlpakaInterface_interface_devices_h
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:22
TPlatform const & platform()
Definition: devices.h:14