Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-02-14 04:11:48

0001 #ifndef HeterogeneousCore_AlpakaInterface_interface_devices_h
0002 #define HeterogeneousCore_AlpakaInterface_interface_devices_h
0003 
0004 #include <vector>
0005 
0006 #include <alpaka/alpaka.hpp>
0007 
0008 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0009 
0010 namespace cms::alpakatools {
0011 
0012   // returns the alpaka accelerator platform
0013   template <typename TPlatform, typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
0014   inline TPlatform const& platform() {
0015     // initialise the platform the first time that this function is called
0016     static const auto platform = TPlatform{};
0017     return platform;
0018   }
0019 
0020   // return the alpaka accelerator devices for the given platform
0021   template <typename TPlatform, typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
0022   inline std::vector<alpaka::Dev<TPlatform>> const& devices() {
0023     // enumerate all devices the first time that this function is called
0024     static const auto devices = alpaka::getDevs(platform<TPlatform>());
0025     return devices;
0026   }
0027 
0028 }  // namespace cms::alpakatools
0029 
0030 #endif  // HeterogeneousCore_AlpakaInterface_interface_devices_h