HeterogeneousCore
CUDACore
src
chooseDevice.cc
Go to the documentation of this file.
1
#include "
FWCore/ServiceRegistry/interface/Service.h
"
2
#include "
FWCore/Utilities/interface/Exception.h
"
3
#include "
HeterogeneousCore/CUDAServices/interface/CUDAService.h
"
4
5
#include "
chooseDevice.h
"
6
7
namespace
cms::cuda
{
8
int
chooseDevice
(
edm::StreamID
id
) {
9
edm::Service<CUDAService>
cudaService;
10
if
(not cudaService->
enabled
()) {
11
cms::Exception
ex(
"CUDAError"
);
12
ex <<
"Unable to choose current device because CUDAService is disabled. If CUDAService was not explicitly\n"
13
"disabled in the configuration, the probable cause is that there is no GPU or there is some problem\n"
14
"in the CUDA runtime or drivers."
;
15
ex.
addContext
(
"Calling cms::cuda::chooseDevice()"
);
16
throw
ex;
17
}
18
19
// For startes we "statically" assign the device based on
20
// edm::Stream number. This is suboptimal if the number of
21
// edm::Streams is not a multiple of the number of CUDA devices
22
// (and even then there is no load balancing).
23
//
24
// TODO: improve the "assignment" logic
25
return
id
% cudaService->
numberOfDevices
();
26
}
27
}
// namespace cms::cuda
cms::cuda
Definition:
Product.h:14
edm::StreamID
Definition:
StreamID.h:30
cms::cuda::chooseDevice
int chooseDevice(edm::StreamID id)
Definition:
chooseDevice.cc:8
cms::Exception::addContext
void addContext(std::string const &context)
Definition:
Exception.cc:165
chooseDevice.h
CUDAService::numberOfDevices
int numberOfDevices() const
Definition:
CUDAService.h:24
Service.h
edm::Service
Definition:
Service.h:30
CUDAService.h
CUDAService::enabled
bool enabled() const
Definition:
CUDAService.h:22
Exception.h
cms::Exception
Definition:
Exception.h:70
Generated for CMSSW Reference Manual by
1.8.16