diff options
Diffstat (limited to 'test_common/harness/deviceInfo.cpp')
-rw-r--r-- | test_common/harness/deviceInfo.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test_common/harness/deviceInfo.cpp b/test_common/harness/deviceInfo.cpp index 287a1423..97ab8c85 100644 --- a/test_common/harness/deviceInfo.cpp +++ b/test_common/harness/deviceInfo.cpp @@ -63,6 +63,40 @@ int is_extension_available(cl_device_id device, const char *extensionName) return false; } +cl_version get_extension_version(cl_device_id device, const char *extensionName) +{ + cl_int err; + size_t size; + + err = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS_WITH_VERSION, 0, nullptr, + &size); + if (err != CL_SUCCESS) + { + throw std::runtime_error("clGetDeviceInfo(CL_DEVICE_EXTENSIONS_WITH_" + "VERSION) failed to return size\n"); + } + + std::vector<cl_name_version> extensions(size / sizeof(cl_name_version)); + err = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS_WITH_VERSION, size, + extensions.data(), &size); + if (err != CL_SUCCESS) + { + throw std::runtime_error("clGetDeviceInfo(CL_DEVICE_EXTENSIONS_WITH_" + "VERSION) failed to return value\n"); + } + + for (auto &ext : extensions) + { + if (!strcmp(extensionName, ext.name)) + { + return ext.version; + } + } + + throw std::runtime_error("Extension " + std::string(extensionName) + + " not supported by device!"); +} + /* Returns a string containing the supported extensions list for a device. */ std::string get_device_extensions_string(cl_device_id device) { |