Compute Library
 21.08
CLDevice Class Reference

OpenCL device type class. More...

#include <CLDevice.h>

Collaboration diagram for CLDevice:
[legend]

Public Member Functions

 CLDevice ()
 Default Constructor. More...
 
 CLDevice (const cl::Device &cl_device)
 Constructor. More...
 
const GPUTargettarget () const
 Returns the GPU target of the cl device. More...
 
size_t compute_units () const
 Returns the number of compute units available. More...
 
const cl::Device & cl_device () const
 Returns the underlying cl device object. More...
 
CLVersion version () const
 Returns the device's CL version. More...
 
std::string device_version () const
 Returns the device version as a string. More...
 
DeviceType type () const override
 Device type accessor. More...
 
bool supported (const std::string &extension) const override
 Check if extensions on a device are supported. More...
 
- Public Member Functions inherited from IDevice
virtual ~IDevice ()=default
 Virtual Destructor. More...
 

Detailed Description

OpenCL device type class.

Initializes and stores all the information about a cl device, working mainly as a cache mechanism.

Definition at line 43 of file CLDevice.h.

Constructor & Destructor Documentation

◆ CLDevice() [1/2]

CLDevice ( )
inline

Default Constructor.

Definition at line 47 of file CLDevice.h.

48  : _device(cl::Device()), _options()
49  {
50  }

◆ CLDevice() [2/2]

CLDevice ( const cl::Device &  cl_device)
inline

Constructor.

Parameters
[in]cl_deviceOpenCL device

Definition at line 56 of file CLDevice.h.

References CLDevice::cl_device(), CLDeviceOptions::compute_units, CLDeviceOptions::device_version, CLDeviceOptions::extensions, arm_compute::G76, arm_compute::get_cl_version(), arm_compute::get_target_from_name(), CLDeviceOptions::gpu_target, and CLDeviceOptions::version.

57  : _device(), _options()
58  {
59  _device = cl_device;
60 
61  // Get device target
62  std::string device_name = _device.getInfo<CL_DEVICE_NAME>();
63  _options.gpu_target = get_target_from_name(device_name);
64 
65  // Fill extensions
66  std::string extensions = _device.getInfo<CL_DEVICE_EXTENSIONS>();
67 
68  std::istringstream iss(extensions);
69  for(std::string s; iss >> s;)
70  {
71  _options.extensions.insert(s);
72  }
73 
74  // SW workaround for G76
75  if(_options.gpu_target == GPUTarget::G76)
76  {
77  _options.extensions.insert("cl_arm_integer_dot_product_int8");
78  }
79 
80  // Get device version
81  _options.version = get_cl_version(_device);
82 
83  // Get compute units
84  _options.compute_units = _device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();
85 
86  // Get device version
87  _options.device_version = _device.getInfo<CL_DEVICE_VERSION>();
88  }
size_t compute_units
Number of compute units.
Definition: CLTypes.h:57
GPUTarget get_target_from_name(const std::string &device_name)
Helper function to get the GPU target from a device name.
Definition: GPUTarget.cpp:145
GPUTarget gpu_target
GPU target architecture/instance.
Definition: CLTypes.h:55
std::set< std::string > extensions
List of supported extensions.
Definition: CLTypes.h:53
CLVersion get_cl_version(const cl::Device &device)
Helper function to get the highest OpenCL version supported.
Definition: CLHelpers.cpp:256
std::string device_version
Device version string.
Definition: CLTypes.h:52
const cl::Device & cl_device() const
Returns the underlying cl device object.
Definition: CLDevice.h:112
CLVersion version
Device OpenCL version.
Definition: CLTypes.h:56

Member Function Documentation

◆ cl_device()

const cl::Device& cl_device ( ) const
inline

Returns the underlying cl device object.

Returns
A cl device

Definition at line 112 of file CLDevice.h.

Referenced by CLDevice::CLDevice(), CLCompileContext::create_kernel(), CLCompileContext::default_ndrange(), CLCompileContext::get_device(), and CLCompileContext::max_local_workgroup_size().

113  {
114  return _device;
115  }

◆ compute_units()

size_t compute_units ( ) const
inline

Returns the number of compute units available.

Returns
Number of compute units

Definition at line 103 of file CLDevice.h.

References CLDeviceOptions::compute_units.

Referenced by CLCompileContext::get_num_compute_units().

104  {
105  return _options.compute_units;
106  }
size_t compute_units
Number of compute units.
Definition: CLTypes.h:57

◆ device_version()

std::string device_version ( ) const
inline

Returns the device version as a string.

Returns
CLVersion of the device

Definition at line 130 of file CLDevice.h.

References CLDeviceOptions::device_version.

Referenced by CLCompileContext::get_device_version(), and CLCompileContext::set_context().

131  {
132  return _options.device_version;
133  }
std::string device_version
Device version string.
Definition: CLTypes.h:52

◆ supported()

bool supported ( const std::string &  extension) const
inlineoverridevirtual

Check if extensions on a device are supported.

Parameters
[in]extensionAn extension to check if it's supported.
Returns
True if the extension is supported else false

Implements IDevice.

Definition at line 141 of file CLDevice.h.

References CLDeviceOptions::extensions.

Referenced by CLCompileContext::fp16_supported(), CLCompileContext::int64_base_atomics_supported(), and CLCompileContext::set_context().

142  {
143  return _options.extensions.count(extension) != 0;
144  }
std::set< std::string > extensions
List of supported extensions.
Definition: CLTypes.h:53

◆ target()

const GPUTarget& target ( ) const
inline

Returns the GPU target of the cl device.

Returns
The GPU target

Definition at line 94 of file CLDevice.h.

References CLDeviceOptions::gpu_target.

Referenced by CLCompileContext::set_context().

95  {
96  return _options.gpu_target;
97  }
GPUTarget gpu_target
GPU target architecture/instance.
Definition: CLTypes.h:55

◆ type()

DeviceType type ( ) const
inlineoverridevirtual

Device type accessor.

Implements IDevice.

Definition at line 136 of file CLDevice.h.

References arm_compute::CL.

137  {
138  return DeviceType::CL;
139  }

◆ version()

CLVersion version ( ) const
inline

Returns the device's CL version.

Returns
CLVersion of the device

Definition at line 121 of file CLDevice.h.

References CLDeviceOptions::version.

Referenced by CLCompileContext::set_context().

122  {
123  return _options.version;
124  }
CLVersion version
Device OpenCL version.
Definition: CLTypes.h:56

The documentation for this class was generated from the following file: