File indexing completed on 2024-04-06 12:15:39
0001 #include "FWCore/ServiceRegistry/interface/Service.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/Utilities/interface/stringize.h"
0004 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/chooseDevice.h"
0005 #include "HeterogeneousCore/AlpakaInterface/interface/devices.h"
0006 #include "HeterogeneousCore/AlpakaServices/interface/alpaka/AlpakaService.h"
0007
0008 namespace ALPAKA_ACCELERATOR_NAMESPACE::detail {
0009 Device const& chooseDevice(edm::StreamID id) {
0010
0011
0012
0013
0014
0015
0016
0017
0018 edm::Service<ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService> alpakaService;
0019 if (not alpakaService->enabled()) {
0020 cms::Exception ex("AlpakaError");
0021 ex << "Unable to choose current device because AlpakaService is disabled. If AlpakaService was not explicitly\n"
0022 "disabled in the configuration, the probable cause is that there is no GPU or there is some problem\n"
0023 "in the platform runtime or drivers.";
0024 ex.addContext("Calling " EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE) "::detail::chooseDevice()");
0025 throw ex;
0026 };
0027
0028
0029
0030
0031
0032
0033
0034 auto const& devices = cms::alpakatools::devices<Platform>();
0035 return devices[id % devices.size()];
0036 }
0037 }