diff --git a/source/adapters/opencl/common.hpp b/source/adapters/opencl/common.hpp index 95105b552d..5e05a9cdbf 100644 --- a/source/adapters/opencl/common.hpp +++ b/source/adapters/opencl/common.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include /** @@ -72,12 +71,25 @@ class OpenCLVersion { * 'OpenCL' for devices. */ - std::regex Rx("OpenCL ([0-9]+)\\.([0-9]+)"); - std::smatch Match; + std::string_view Prefix = "OpenCL "; + size_t VersionBegin = Version.find_first_of(" "); + size_t VersionEnd = Version.find_first_of(" ", VersionBegin + 1); + size_t VersionSeparator = Version.find_first_of(".", VersionBegin + 1); - if (std::regex_search(Version, Match, Rx) && (Match.size() == 3)) { - OCLMajor = strtoul(Match[1].str().c_str(), nullptr, 10); - OCLMinor = strtoul(Match[2].str().c_str(), nullptr, 10); + bool HaveOCLPrefix = + std::equal(Prefix.begin(), Prefix.end(), Version.begin()); + + if (HaveOCLPrefix && VersionBegin != std::string::npos && + VersionEnd != std::string::npos && + VersionSeparator != std::string::npos) { + + std::string VersionMajor{Version.begin() + VersionBegin + 1, + Version.begin() + VersionSeparator}; + std::string VersionMinor{Version.begin() + VersionSeparator + 1, + Version.begin() + VersionEnd}; + + OCLMajor = strtoul(VersionMajor.c_str(), nullptr, 10); + OCLMinor = strtoul(VersionMinor.c_str(), nullptr, 10); if (!isValid()) { OCLMajor = OCLMinor = 0; diff --git a/source/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 80b1502854..00b37ca58c 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -9,6 +9,9 @@ //===----------------------------------------------------------------------===// #include "common.hpp" +#include +#include + UR_APIEXPORT ur_result_t UR_APICALL urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName, ur_kernel_handle_t *phKernel) {