\class device \brief A compute device. Typical compute devices include GPUs and multi-core CPUs. A list of all compute devices available on a platform can be obtained via the platform::devices() method. The default compute device for the system can be obtained with the system::default_device() method. For example: \snippet test/test_device.cpp default_gpu \see platform, context, command_queue
| 44 | /// |
| 45 | /// \see platform, context, command_queue |
| 46 | class device |
| 47 | { |
| 48 | public: |
| 49 | enum type { |
| 50 | cpu = CL_DEVICE_TYPE_CPU, |
| 51 | gpu = CL_DEVICE_TYPE_GPU, |
| 52 | accelerator = CL_DEVICE_TYPE_ACCELERATOR |
| 53 | }; |
| 54 | |
| 55 | /// Creates a null device object. |
| 56 | device() |
| 57 | : m_id(0) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | /// Creates a new device object for \p id. If \p retain is \c true, |
| 62 | /// the reference count for the device will be incremented. |
| 63 | explicit device(cl_device_id id, bool retain = true) |
| 64 | : m_id(id) |
| 65 | { |
| 66 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
| 67 | if(m_id && retain && is_subdevice()){ |
| 68 | clRetainDevice(m_id); |
| 69 | } |
| 70 | #else |
| 71 | (void) retain; |
| 72 | #endif |
| 73 | } |
| 74 | |
| 75 | /// Creates a new device object as a copy of \p other. |
| 76 | device(const device &other) |
| 77 | : m_id(other.m_id) |
| 78 | { |
| 79 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
| 80 | if(m_id && is_subdevice()){ |
| 81 | clRetainDevice(m_id); |
| 82 | } |
| 83 | #endif |
| 84 | } |
| 85 | |
| 86 | /// Copies the device from \p other to \c *this. |
| 87 | device& operator=(const device &other) |
| 88 | { |
| 89 | if(this != &other){ |
| 90 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
| 91 | if(m_id && is_subdevice()){ |
| 92 | clReleaseDevice(m_id); |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | m_id = other.m_id; |
| 97 | |
| 98 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
| 99 | if(m_id && is_subdevice()){ |
| 100 | clRetainDevice(m_id); |
| 101 | } |
| 102 | #endif |
| 103 | } |
no outgoing calls
no test coverage detected