OpenCL device type class * * Initializes and stores all the information about a cl device, * working mainly as a cache mechanism. * */
| 45 | * working mainly as a cache mechanism. |
| 46 | * */ |
| 47 | class CLDevice : public IDevice |
| 48 | { |
| 49 | public: |
| 50 | /** Default Constructor */ |
| 51 | CLDevice() : _device(cl::Device()), _options() |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | /** Constructor |
| 56 | * |
| 57 | * @param[in] cl_device OpenCL device |
| 58 | */ |
| 59 | CLDevice(const cl::Device &cl_device) : _device(), _options() |
| 60 | { |
| 61 | _device = cl_device; |
| 62 | |
| 63 | // Get device target |
| 64 | std::string device_name = _device.getInfo<CL_DEVICE_NAME>(); |
| 65 | _options.gpu_target = get_target_from_name(device_name); |
| 66 | |
| 67 | // Fill extensions |
| 68 | std::string extensions = _device.getInfo<CL_DEVICE_EXTENSIONS>(); |
| 69 | |
| 70 | std::istringstream iss(extensions); |
| 71 | for (std::string s; iss >> s;) |
| 72 | { |
| 73 | _options.extensions.insert(s); |
| 74 | } |
| 75 | |
| 76 | // SW workaround for G76 |
| 77 | if (_options.gpu_target == GPUTarget::G76) |
| 78 | { |
| 79 | _options.extensions.insert("cl_arm_integer_dot_product_int8"); |
| 80 | } |
| 81 | |
| 82 | // Get device version |
| 83 | _options.version = get_cl_version(_device); |
| 84 | |
| 85 | // Get compute units |
| 86 | _options.compute_units = _device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>(); |
| 87 | |
| 88 | // Get device version |
| 89 | _options.device_version = _device.getInfo<CL_DEVICE_VERSION>(); |
| 90 | } |
| 91 | |
| 92 | /** Returns the GPU target of the cl device |
| 93 | * |
| 94 | * @return The GPU target |
| 95 | */ |
| 96 | const GPUTarget &target() const |
| 97 | { |
| 98 | return _options.gpu_target; |
| 99 | } |
| 100 | |
| 101 | /** Returns the number of compute units available |
| 102 | * |
| 103 | * @return Number of compute units |
| 104 | */ |
no outgoing calls
no test coverage detected