CMS 3D CMS Logo

host.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_AlpakaInterface_interface_host_h
2 #define HeterogeneousCore_AlpakaInterface_interface_host_h
3 
4 #include <cassert>
5 
6 #include <alpaka/alpaka.hpp>
7 
8 namespace cms::alpakatools {
9 
10  namespace detail {
11 
12  inline alpaka::DevCpu enumerate_host() {
13  using Platform = alpaka::PltfCpu;
14  using Host = alpaka::DevCpu;
15 
16  assert(alpaka::getDevCount<Platform>() == 1);
17  Host host = alpaka::getDevByIdx<Platform>(0);
18  assert(alpaka::getNativeHandle(host) == 0);
19 
20  return host;
21  }
22 
23  } // namespace detail
24 
25  // returns the alpaka host device
26  inline alpaka::DevCpu const& host() {
27  static const auto host = detail::enumerate_host();
28  return host;
29  }
30 
31 } // namespace cms::alpakatools
32 
33 #endif // HeterogeneousCore_AlpakaInterface_interface_host_h
assert(be >=bs)
alpaka::DevCpu enumerate_host()
Definition: host.h:12
alpaka::DevCpu const & host()
Definition: host.h:26