HeterogeneousCore
CUDAUtilities
interface
ScopedSetDevice.h
Go to the documentation of this file.
1
#ifndef HeterogeneousCore_CUDAUtilities_ScopedSetDevice_h
2
#define HeterogeneousCore_CUDAUtilities_ScopedSetDevice_h
3
4
#include "
HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h
"
5
6
#include <cuda_runtime.h>
7
8
namespace
cms
{
9
namespace
cuda
{
10
class
ScopedSetDevice
{
11
public
:
12
explicit
ScopedSetDevice
(
int
newDevice) {
13
cudaCheck
(cudaGetDevice(&
prevDevice_
));
14
cudaCheck
(cudaSetDevice(newDevice));
15
}
16
17
~ScopedSetDevice
() {
18
// Intentionally don't check the return value to avoid
19
// exceptions to be thrown. If this call fails, the process is
20
// doomed anyway.
21
cudaSetDevice(
prevDevice_
);
22
}
23
24
private
:
25
int
prevDevice_
;
26
};
27
}
// namespace cuda
28
}
// namespace cms
29
30
#endif
cms::cuda::ScopedSetDevice::~ScopedSetDevice
~ScopedSetDevice()
Definition:
ScopedSetDevice.h:17
cms::cuda::ScopedSetDevice
Definition:
ScopedSetDevice.h:10
cms::cuda::ScopedSetDevice::prevDevice_
int prevDevice_
Definition:
ScopedSetDevice.h:25
prod1Switch_cff.cuda
cuda
Definition:
prod1Switch_cff.py:11
cudaCheck.h
cudaCheck
#define cudaCheck(ARG,...)
Definition:
cudaCheck.h:62
cms::cuda::ScopedSetDevice::ScopedSetDevice
ScopedSetDevice(int newDevice)
Definition:
ScopedSetDevice.h:12
cms
Namespace of DDCMS conversion namespace.
Definition:
ProducerAnalyzer.cc:21
Generated for CMSSW Reference Manual by
1.8.16