Skip to content

Commit

Permalink
Make Version function to_uint() for consistency
Browse files Browse the repository at this point in the history
Includes fix for MacOS build error

Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 committed Feb 5, 2021
1 parent 1282bca commit b0ca448
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test_common/harness/rounding_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void *FlushToZero(void)
#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
uint i;
unsigned int i;
void *p;
} u = { _mm_getcsr() };
_mm_setcsr(u.i | 0x8040);
Expand Down Expand Up @@ -235,7 +235,7 @@ void UnFlushToZero(void *p)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
void *p;
uint i;
unsigned int i;
} u = { p };
_mm_setcsr(u.i);
#elif defined(__arm__) || defined(__aarch64__)
Expand Down
18 changes: 12 additions & 6 deletions test_common/harness/testHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@ class Version {
public:
Version(): m_major(0), m_minor(0) {}
Version(uint major, uint minor): m_major(major), m_minor(minor) {}
bool operator>(const Version &rhs) const { return to_int() > rhs.to_int(); }
bool operator<(const Version &rhs) const { return to_int() < rhs.to_int(); }
bool operator>(const Version &rhs) const
{
return to_uint() > rhs.to_uint();
}
bool operator<(const Version &rhs) const
{
return to_uint() < rhs.to_uint();
}
bool operator<=(const Version &rhs) const
{
return to_int() <= rhs.to_int();
return to_uint() <= rhs.to_uint();
}
bool operator>=(const Version &rhs) const
{
return to_int() >= rhs.to_int();
return to_uint() >= rhs.to_uint();
}
bool operator==(const Version &rhs) const
{
return to_int() == rhs.to_int();
return to_uint() == rhs.to_uint();
}
int to_int() const { return m_major * 10 + m_minor; }
uint to_uint() const { return m_major * 10 + m_minor; }
std::string to_string() const
{
std::stringstream ss;
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/basic/test_preprocessors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int test_kernel_preprocessor_macros(cl_device_id deviceID, cl_context context, c
// The OpenCL version reported by the macro reports the feature level supported by the compiler. Since
// this doesn't directly match any property we can query, we just check to see if it's a sane value
auto device_cl_version = get_device_cl_version(deviceID);
int device_cl_version_int = device_cl_version.to_int() * 10;
int device_cl_version_int = device_cl_version.to_uint() * 10;
if ((results[2] < 100) || (results[2] > device_cl_version_int))
{
log_error("ERROR: Kernel preprocessor __OPENCL_VERSION__ does not make "
Expand Down Expand Up @@ -248,7 +248,7 @@ int test_kernel_preprocessor_macros(cl_device_id deviceID, cl_context context, c
"ERROR: Kernel preprocessor __OPENCL_C_VERSION__ does not make "
"sense w.r.t. device's version string! "
"(preprocessor states %d, CL_DEVICE_OPENCL_C_VERSION is %d (%s))\n",
results[3], device_version.to_int() * 10,
results[3], device_version.to_uint() * 10,
device_version.to_string().c_str());
log_error("This means that CL_DEVICE_OPENCL_C_VERSION < "
"__OPENCL_C_VERSION__");
Expand Down

0 comments on commit b0ca448

Please sign in to comment.