Skip to content

[SYCL] Avoid clashes with compiler macro #6911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions sycl/plugins/opencl/pi_opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@
namespace OCLV {
class OpenCLVersion {
protected:
unsigned int major;
unsigned int minor;
unsigned int majorVer;
unsigned int minorVer;

public:
OpenCLVersion() : major(0), minor(0) {}
OpenCLVersion() : majorVer(0), minorVer(0) {}

OpenCLVersion(unsigned int major, unsigned int minor)
: major(major), minor(minor) {
OpenCLVersion(unsigned int majorVer, unsigned int minorVer)
: majorVer(majorVer), minorVer(minorVer) {
if (!isValid())
major = minor = 0;
majorVer = minorVer = 0;
}

OpenCLVersion(const char *version) : OpenCLVersion(std::string(version)) {}

OpenCLVersion(const std::string &version) : major(0), minor(0) {
OpenCLVersion(const std::string &version) : majorVer(0), minorVer(0) {
/* The OpenCL specification defines the full version string as
* 'OpenCL<space><major_version.minor_version><space><platform-specific
* information>' for platforms and as
Expand All @@ -56,25 +56,25 @@ class OpenCLVersion {
std::smatch match;

if (std::regex_search(version, match, rx) && (match.size() == 3)) {
major = strtoul(match[1].str().c_str(), nullptr, 10);
minor = strtoul(match[2].str().c_str(), nullptr, 10);
majorVer = strtoul(match[1].str().c_str(), nullptr, 10);
minorVer = strtoul(match[2].str().c_str(), nullptr, 10);

if (!isValid())
major = minor = 0;
majorVer = minorVer = 0;
}
}

bool operator==(const OpenCLVersion &v) const {
return major == v.major && minor == v.minor;
return majorVer == v.majorVer && minorVer == v.minorVer;
}

bool operator!=(const OpenCLVersion &v) const { return !(*this == v); }

bool operator<(const OpenCLVersion &v) const {
if (major == v.major)
return minor < v.minor;
if (majorVer == v.majorVer)
return minorVer < v.minorVer;

return major < v.major;
return majorVer < v.majorVer;
}

bool operator>(const OpenCLVersion &v) const { return v < *this; }
Expand All @@ -88,21 +88,21 @@ class OpenCLVersion {
}

bool isValid() const {
switch (major) {
switch (majorVer) {
case 0:
return false;
case 1:
case 2:
return minor <= 2;
return minorVer <= 2;
case UINT_MAX:
return false;
default:
return minor != UINT_MAX;
return minorVer != UINT_MAX;
}
}

int getMajor() const { return major; }
int getMinor() const { return minor; }
int getMajor() const { return majorVer; }
int getMinor() const { return minorVer; }
};

inline const OpenCLVersion V1_0(1, 0);
Expand Down