|
12 | 12 | #include <climits>
|
13 | 13 | #include <map>
|
14 | 14 | #include <mutex>
|
15 |
| -#include <regex> |
16 | 15 | #include <ur/ur.hpp>
|
17 | 16 |
|
18 | 17 | /**
|
@@ -72,12 +71,25 @@ class OpenCLVersion {
|
72 | 71 | * 'OpenCL<space><ocl_major_version.ocl_minor_version><space><vendor-specific
|
73 | 72 | * information>' for devices.
|
74 | 73 | */
|
75 |
| - std::regex Rx("OpenCL ([0-9]+)\\.([0-9]+)"); |
76 |
| - std::smatch Match; |
| 74 | + std::string_view Prefix = "OpenCL "; |
| 75 | + size_t VersionBegin = Version.find_first_of(" "); |
| 76 | + size_t VersionEnd = Version.find_first_of(" ", VersionBegin + 1); |
| 77 | + size_t VersionSeparator = Version.find_first_of(".", VersionBegin + 1); |
77 | 78 |
|
78 |
| - if (std::regex_search(Version, Match, Rx) && (Match.size() == 3)) { |
79 |
| - OCLMajor = strtoul(Match[1].str().c_str(), nullptr, 10); |
80 |
| - OCLMinor = strtoul(Match[2].str().c_str(), nullptr, 10); |
| 79 | + bool HaveOCLPrefix = |
| 80 | + std::equal(Prefix.begin(), Prefix.end(), Version.begin()); |
| 81 | + |
| 82 | + if (HaveOCLPrefix && VersionBegin != std::string::npos && |
| 83 | + VersionEnd != std::string::npos && |
| 84 | + VersionSeparator != std::string::npos) { |
| 85 | + |
| 86 | + std::string VersionMajor{Version.begin() + VersionBegin + 1, |
| 87 | + Version.begin() + VersionSeparator}; |
| 88 | + std::string VersionMinor{Version.begin() + VersionSeparator + 1, |
| 89 | + Version.begin() + VersionEnd}; |
| 90 | + |
| 91 | + OCLMajor = strtoul(VersionMajor.c_str(), nullptr, 10); |
| 92 | + OCLMinor = strtoul(VersionMinor.c_str(), nullptr, 10); |
81 | 93 |
|
82 | 94 | if (!isValid()) {
|
83 | 95 | OCLMajor = OCLMinor = 0;
|
|
0 commit comments