boost::compute::device — A compute device.
// In header: <boost/compute/device.hpp> class device { public: enum type { cpu = = CL_DEVICE_TYPE_CPU, gpu = = CL_DEVICE_TYPE_GPU, accelerator = = CL_DEVICE_TYPE_ACCELERATOR }; // construct/copy/destruct device(); explicit device(cl_device_id, bool = true); device(const device &); device(device &&) noexcept; device & operator=(const device &); device & operator=(device &&) noexcept; ~device(); // public member functions cl_device_id id() const; cl_device_id & get() const; cl_device_type type() const; platform platform() const; std::string name() const; std::string vendor() const; std::string profile() const; std::string version() const; std::string driver_version() const; std::vector< std::string > extensions() const; bool supports_extension(const std::string &) const; uint_ address_bits() const; ulong_ global_memory_size() const; ulong_ local_memory_size() const; uint_ clock_frequency() const; uint_ compute_units() const; template<typename T> uint_ preferred_vector_width() const; size_t profiling_timer_resolution() const; bool is_subdevice() const; template<typename T> T get_info(cl_device_info) const; template<int Enum> unspecified get_info() const; std::vector< device > partition(const cl_device_partition_property *) const; std::vector< device > partition_equally(size_t) const; std::vector< device > partition_by_counts(const std::vector< size_t > &) const; std::vector< device > partition_by_affinity_domain(cl_device_affinity_domain) const; bool operator==(const device &) const; bool operator!=(const device &) const; };
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:
boost::compute::device gpu = boost::compute::system::default_device();
See Also:
platform, context, command_queue
device
public
construct/copy/destructdevice();Creates a null device object.
explicit device(cl_device_id id, bool retain = true);
Creates a new device object for id
. If retain
is true
, the reference count for the device will be incremented.
device(const device & other);Creates a new device object as a copy of
other
. device(device && other) noexcept;Move-constructs a new device object from
other
. device & operator=(const device & other);Copies the device from
other
to *this
. device & operator=(device && other) noexcept;Move-assigns the device from
other
to *this
. ~device();Destroys the device object.
device
public member functionscl_device_id id() const;Returns the ID of the device.
cl_device_id & get() const;Returns a reference to the underlying OpenCL device id.
cl_device_type type() const;Returns the type of the device.
platform platform() const;Returns the platform for the device.
std::string name() const;Returns the name of the device.
std::string vendor() const;Returns the name of the vendor for the device.
std::string profile() const;Returns the device profile string.
std::string version() const;Returns the device version string.
std::string driver_version() const;Returns the driver version string.
std::vector< std::string > extensions() const;Returns a list of extensions supported by the device.
bool supports_extension(const std::string & name) const;
Returns true
if the device supports the extension with name
.
uint_ address_bits() const;Returns the number of address bits.
ulong_ global_memory_size() const;Returns the global memory size in bytes.
ulong_ local_memory_size() const;Returns the local memory size in bytes.
uint_ clock_frequency() const;Returns the clock frequency for the device's compute units.
uint_ compute_units() const;Returns the number of compute units in the device.
template<typename T> uint_ preferred_vector_width() const;Returns the preferred vector width for type
T
. size_t profiling_timer_resolution() const;Returns the profiling timer resolution in nanoseconds.
bool is_subdevice() const;Returns
true
if the device is a sub-device. template<typename T> T get_info(cl_device_info info) const;
Returns information about the device.
For example, to get the number of compute units:
device.get_info<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS);
Alternatively, the template-specialized version can be used which automatically determines the result type:
device.get_info<CL_DEVICE_MAX_COMPUTE_UNITS>();
See the documentation for clGetDeviceInfo() for more information.
template<int Enum> unspecified get_info() const;
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< device > partition(const cl_device_partition_property * properties) const;
Partitions the device into multiple sub-devices according to properties
.
Warning | |
---|---|
This method is only available if the OpenCL version is 1.2 or later. |
std::vector< device > partition_equally(size_t count) const;
Warning | |
---|---|
This method is only available if the OpenCL version is 1.2 or later. |
std::vector< device > partition_by_counts(const std::vector< size_t > & counts) const;
Warning | |
---|---|
This method is only available if the OpenCL version is 1.2 or later. |
std::vector< device > partition_by_affinity_domain(cl_device_affinity_domain domain) const;
Warning | |
---|---|
This method is only available if the OpenCL version is 1.2 or later. |
bool operator==(const device & other) const;Returns
true
if the device is the same at other
. bool operator!=(const device & other) const;Returns
true
if the device is different from other
.