File indexing completed on 2023-03-17 11:05:44
0001 #include "FWCore/ServiceRegistry/interface/Service.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "HeterogeneousCore/CUDAServices/interface/CUDAInterface.h"
0004
0005 #include "chooseDevice.h"
0006
0007 namespace cms::cuda {
0008 int chooseDevice(edm::StreamID id) {
0009 edm::Service<CUDAInterface> cuda;
0010 if (not cuda or not cuda->enabled()) {
0011 cms::Exception ex("CUDAError");
0012 ex << "Unable to choose current device because CUDAService is not preset or disabled.\n"
0013 << "If CUDAService was not explicitly disabled in the configuration, the probable\n"
0014 << "cause is that there is no GPU or there is some problem in the CUDA runtime or\n"
0015 << "drivers.";
0016 ex.addContext("Calling cms::cuda::chooseDevice()");
0017 throw ex;
0018 }
0019
0020
0021
0022
0023
0024
0025
0026 return id % cuda->numberOfDevices();
0027 }
0028 }