CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cms::cuda::ScopedSetDevice Class Reference

#include <ScopedSetDevice.h>

Public Member Functions

 ScopedSetDevice ()
 
 ScopedSetDevice (int device)
 
void set (int device)
 
 ~ScopedSetDevice ()
 

Private Attributes

int originalDevice_
 

Detailed Description

Definition at line 10 of file ScopedSetDevice.h.

Constructor & Destructor Documentation

◆ ScopedSetDevice() [1/2]

cms::cuda::ScopedSetDevice::ScopedSetDevice ( )
inline

Definition at line 13 of file ScopedSetDevice.h.

13  {
14  // Store the original device
15  cudaCheck(cudaGetDevice(&originalDevice_));
16  }

References cudaCheck, and originalDevice_.

◆ ScopedSetDevice() [2/2]

cms::cuda::ScopedSetDevice::ScopedSetDevice ( int  device)
inlineexplicit

Definition at line 19 of file ScopedSetDevice.h.

19  : ScopedSetDevice() {
20  // Change the current device
21  set(device);
22  }

References set().

◆ ~ScopedSetDevice()

cms::cuda::ScopedSetDevice::~ScopedSetDevice ( )
inline

Definition at line 25 of file ScopedSetDevice.h.

25  {
26  // Intentionally don't check the return value to avoid
27  // exceptions to be thrown. If this call fails, the process is
28  // doomed anyway.
29  cudaSetDevice(originalDevice_);
30  }

References originalDevice_.

Member Function Documentation

◆ set()

void cms::cuda::ScopedSetDevice::set ( int  device)
inline

Definition at line 34 of file ScopedSetDevice.h.

34  {
35  // Change the current device
36  cudaCheck(cudaSetDevice(device));
37  }

References cudaCheck.

Referenced by cms::cuda::ESProduct< HcalGainWidthsGPU::Product >::ESProduct(), and ScopedSetDevice().

Member Data Documentation

◆ originalDevice_

int cms::cuda::ScopedSetDevice::originalDevice_
private

Definition at line 40 of file ScopedSetDevice.h.

Referenced by ScopedSetDevice(), and ~ScopedSetDevice().

cms::cuda::ScopedSetDevice::ScopedSetDevice
ScopedSetDevice()
Definition: ScopedSetDevice.h:13
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
cms::cuda::ScopedSetDevice::originalDevice_
int originalDevice_
Definition: ScopedSetDevice.h:40
cms::cuda::ScopedSetDevice::set
void set(int device)
Definition: ScopedSetDevice.h:34