Device Class

A Device is a processing unit that can execute OpenCL kernels. It is mainly a GPU, but it can also be a CPU or a simulation of a device (e.g. pocl, oclgrind). It is a good practice to consider a device as a mini computer with its own memory with which you can communicate through the OpenCL API. This class holds a set of information allowing the identification of a specific hardware for future communication with it during execution.

The class has no processing functions; it is mainly used to store necessary information required to identify the hardware. The detection and the communication is managed by Backend class.

Users should not need to interact with the Device class extensively, except during the initialization of the library or when using multiple devices for computation.

class Device

Device class This class is used to manage devices.

Public Types

enum class Type

Device type.

Values:

enumerator CUDA
enumerator OPENCL

Public Functions

Device() = default

Construct a new Device object.

virtual ~Device() = default

Destroy the Device object.

virtual auto initialize() -> void = 0

Initialize a device pointer.

virtual auto finalize() -> void = 0

Release the device pointer.

virtual auto finish() const -> void = 0

Wait for command queue to finish.

virtual auto setWaitToFinish(bool flag) -> void = 0

Set flag for waiting for command queue to finish.

virtual auto isInitialized() const -> bool = 0

Check if device is initialized.

Returns:

bool

virtual auto getName(bool lowercase = false) const -> std::string = 0

Get device name.

Returns:

std::string

virtual auto getInfo() const -> std::string = 0

Get device info.

Returns:

std::string

virtual auto getInfoExtended() const -> std::string = 0

Get device with more info.

Returns:

std::string

virtual auto getType() const -> Device::Type = 0

Get device type.

Returns:

Device::Type

virtual auto getDeviceType() const -> std::string = 0

Get device type as string.

Returns:

std::string

virtual auto getDeviceIndex() const -> size_t = 0

Get device index in context.

virtual auto getPlatform() const -> std::string = 0

Get device platform.

Returns:

std::string

virtual auto supportImage() const -> bool = 0

check if device is compatible with cl_image

Returns:

bool

virtual auto getNbDevicesFromContext() const -> size_t = 0

Get shared context devices.

Friends

inline friend auto operator<<(std::ostream &out, const Device::Type &device_type) -> std::ostream&

operator << for Device::Type

inline friend auto operator<<(std::ostream &out, const Device::Pointer &device) -> std::ostream&

operator << for Device::Pointer