HAMR
The Heterogeneous Accelerator Memory Resource
hamr_cuda_device.h
Go to the documentation of this file.
1 #ifndef hamr_cuda_device_h
2 #define hamr_cuda_device_h
3 
4 #include "hamr_config.h"
5 
6 ///@file
7 
8 namespace hamr
9 {
10 /// gets the device identifier for the first GPU. @returns zero if successful.
11 inline int HAMR_EXPORT get_cuda_device_identifier(int &dev_id) { dev_id = 0; return 0; }
12 
13 /// gets the device identifier for the CPU. @returns zero if successful.
14 inline int HAMR_EXPORT get_cuda_cpu_identifier(int &dev_id) { dev_id = -1; return 0; }
15 
16 /// gets the currently atcive CUDA device. @returns zero if successful.
17 int HAMR_EXPORT get_active_cuda_device(int &dev_id);
18 
19 /// sets the active CUDA device. returns zero if successful.
20 int HAMR_EXPORT set_active_cuda_device(int dev_id);
21 
22 /// gets the device that owns the given pointer. @returns zero if successful.
23 int HAMR_EXPORT get_cuda_device(const void *ptr, int &device_id);
24 
25 /** Activate the specified CUDA device, and restore the previously active
26  * device when the object is destroyed.
27  */
28 class HAMR_EXPORT activate_cuda_device
29 {
30 public:
31  activate_cuda_device() = delete;
33  void operator=(const activate_cuda_device &) = delete;
34 
35  activate_cuda_device(int id);
37 
38 private:
39  int m_device;
40 };
41 
42 }
43 #endif
hamr::get_cuda_cpu_identifier
int HAMR_EXPORT get_cuda_cpu_identifier(int &dev_id)
gets the device identifier for the CPU.
Definition: hamr_cuda_device.h:14
hamr::set_active_cuda_device
int HAMR_EXPORT set_active_cuda_device(int dev_id)
sets the active CUDA device. returns zero if successful.
hamr::get_cuda_device
int HAMR_EXPORT get_cuda_device(const void *ptr, int &device_id)
gets the device that owns the given pointer.
hamr::get_cuda_device_identifier
int HAMR_EXPORT get_cuda_device_identifier(int &dev_id)
gets the device identifier for the first GPU.
Definition: hamr_cuda_device.h:11
hamr::get_active_cuda_device
int HAMR_EXPORT get_active_cuda_device(int &dev_id)
gets the currently atcive CUDA device.
hamr
heterogeneous accelerator memory resource
Definition: hamr_buffer.h:40
hamr::activate_cuda_device
Definition: hamr_cuda_device.h:28