OpenMPCD
Device.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the `OpenMPCD::CUDA::Device` class.
4  */
5 
6 #ifndef OPENMPCD_CUDA_DEVICE_HPP
7 #define OPENMPCD_CUDA_DEVICE_HPP
8 
10 
11 #include <string>
12 
13 namespace OpenMPCD
14 {
15 namespace CUDA
16 {
17 
18 /**
19  * Class representing a CUDA Device.
20  */
21 class Device
22 {
23  public:
24  /**
25  * Represents the CUDA Device active at the moment of this instance's
26  * construction on the current thread.
27  */
28  Device();
29 
30  private:
31  /**
32  * The copy constructor.
33  */
34  Device(const Device&);
35 
36  public:
37  /**
38  * Returns the number of CUDA Devices available.
39  */
40  static unsigned int getDeviceCount();
41 
42  /**
43  * Returns the PCI Domain ID of this Device.
44  */
45  unsigned int getPCIDomainID() const;
46 
47  /**
48  * Returns the PCI Bus ID of this Device.
49  */
50  unsigned int getPCIBusID() const;
51 
52  /**
53  * Returns the PCI Slot ID (also known as PCI Device ID) of this Device.
54  */
55  unsigned int getPCISlotID() const;
56 
57  /**
58  * Returns a string representing the PCI address.
59  *
60  * The returned value is formatted as `DDDD:BB:SS`, where `DDDD` is the
61  * four-digit hexademical (lowercase) representation of the value
62  * returned by `getPCIDomainID`, `BB` is two hexademical (lowercase)
63  * digits corresponding to the return value of `getPCIBusID`, and `SS`
64  * likewise for `getPCISlotID`.
65  */
66  const std::string getPCIAddressString() const;
67 
68  /**
69  * Returns the stack size, in bytes, per Device thread.
70  */
71  std::size_t getStackSizePerThread() const;
72 
73  /**
74  * Sets the stack size, in bytes, per Device thread.
75  *
76  * @throw OpenMPCD::Exception
77  * Throws if an error occurred.
78  * @throw OpenMPCD::InvalidArgumentException
79  * If `OPENMPCD_DEBUG` is defined, throws if `value == 0`.
80  *
81  * @param[in] value The new stack size, which must be positive.
82  */
83  void setStackSizePerThread(const std::size_t value) const;
84 
85  private:
86  /**
87  * The assignment operator.
88  */
89  const Device& operator=(const Device&);
90 
91  private:
92  int deviceID; ///< The CUDA Device ID of this instance.
93  cudaDeviceProp properties; ///< The Device properties.
94 }; //class Device
95 } //namespace CUDA
96 } //namespace OpenMPCD
97 
98 #endif
OpenMPCD::CUDA::Device::getPCIBusID
unsigned int getPCIBusID() const
Returns the PCI Bus ID of this Device.
Definition: Device.cpp:42
OpenMPCD::CUDA::Device::setStackSizePerThread
void setStackSizePerThread(const std::size_t value) const
Sets the stack size, in bytes, per Device thread.
Definition: Device.cpp:75
OpenMPCD::CUDA::Device
Class representing a CUDA Device.
Definition: Device.hpp:21
OpenMPCD::CUDA::Device::getPCIAddressString
const std::string getPCIAddressString() const
Returns a string representing the PCI address.
Definition: Device.cpp:56
OpenMPCD::CUDA::Device::Device
Device()
Represents the CUDA Device active at the moment of this instance's construction on the current thread...
Definition: Device.cpp:15
OpenMPCD::CUDA::Device::getStackSizePerThread
std::size_t getStackSizePerThread() const
Returns the stack size, in bytes, per Device thread.
Definition: Device.cpp:67
OpenMPCD::CUDA::Device::getPCIDomainID
unsigned int getPCIDomainID() const
Returns the PCI Domain ID of this Device.
Definition: Device.cpp:35
OpenMPCD::CUDA::Device::getDeviceCount
static unsigned int getDeviceCount()
Returns the number of CUDA Devices available.
Definition: Device.cpp:24
runtime.hpp
OpenMPCD::CUDA::Device::getPCISlotID
unsigned int getPCISlotID() const
Returns the PCI Slot ID (also known as PCI Device ID) of this Device.
Definition: Device.cpp:49