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 (int newDevice)
 
 ~ScopedSetDevice ()
 

Private Attributes

int prevDevice_
 

Detailed Description

Definition at line 10 of file ScopedSetDevice.h.

Constructor & Destructor Documentation

◆ ScopedSetDevice()

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

Definition at line 12 of file ScopedSetDevice.h.

12  {
13  cudaCheck(cudaGetDevice(&prevDevice_));
14  cudaCheck(cudaSetDevice(newDevice));
15  }

References cudaCheck, and prevDevice_.

◆ ~ScopedSetDevice()

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

Definition at line 17 of file ScopedSetDevice.h.

17  {
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  }

References prevDevice_.

Member Data Documentation

◆ prevDevice_

int cms::cuda::ScopedSetDevice::prevDevice_
private

Definition at line 25 of file ScopedSetDevice.h.

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

cms::cuda::ScopedSetDevice::prevDevice_
int prevDevice_
Definition: ScopedSetDevice.h:25
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62