diff options
Diffstat (limited to 'arm_compute/core/CL/CLDevice.h')
-rw-r--r-- | arm_compute/core/CL/CLDevice.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/arm_compute/core/CL/CLDevice.h b/arm_compute/core/CL/CLDevice.h index 033bf8fa96..ded6bb8493 100644 --- a/arm_compute/core/CL/CLDevice.h +++ b/arm_compute/core/CL/CLDevice.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,6 +30,7 @@ #include "arm_compute/core/IDevice.h" #include <set> +#include <sstream> #include <string> namespace arm_compute @@ -43,8 +44,7 @@ class CLDevice : public IDevice { public: /** Default Constructor */ - CLDevice() - : _device(cl::Device()), _options() + CLDevice() : _device(cl::Device()), _options() { } @@ -52,8 +52,7 @@ public: * * @param[in] cl_device OpenCL device */ - CLDevice(const cl::Device &cl_device) - : _device(), _options() + CLDevice(const cl::Device &cl_device) : _device(), _options() { _device = cl_device; @@ -65,13 +64,13 @@ public: std::string extensions = _device.getInfo<CL_DEVICE_EXTENSIONS>(); std::istringstream iss(extensions); - for(std::string s; iss >> s;) + for (std::string s; iss >> s;) { _options.extensions.insert(s); } // SW workaround for G76 - if(_options.gpu_target == GPUTarget::G76) + if (_options.gpu_target == GPUTarget::G76) { _options.extensions.insert("cl_arm_integer_dot_product_int8"); } @@ -142,6 +141,32 @@ public: return _options.extensions.count(extension) != 0; } + /** Returns whether non-uniform workgroup is supported and the build options. + * + * If the feature is supported, the appropriate build options will be + * appended to the specified string. + * + * @return A tuple (supported, build_options) indicating whether the feature + * is supported and the corresponding build options to enable it. + */ + std::tuple<bool, std::string> is_non_uniform_workgroup_supported() const + { + if (version() == CLVersion::CL30 && get_cl_non_uniform_work_group_supported(_device)) + { + return {true, " -cl-std=CL3.0 "}; + } + else if (version() == CLVersion::CL20) + { + return {true, " -cl-std=CL2.0 "}; + } + else if (supported("cl_arm_non_uniform_work_group_size")) + { + return {true, " -cl-arm-non-uniform-work-group-size "}; + } + + return {false, ""}; + } + private: cl::Device _device; /**< OpenCL device. */ struct CLDeviceOptions _options; /**< OpenCL device options */ |