From b0ca448ae2f01ceea1b27fa9a5010f53e6e54156 Mon Sep 17 00:00:00 2001 From: Ellen Norris-Thompson Date: Thu, 4 Feb 2021 15:50:43 +0000 Subject: [PATCH] Make Version function to_uint() for consistency Includes fix for MacOS build error Contributes #787 Signed-off-by: Ellen Norris-Thompson --- test_common/harness/rounding_mode.cpp | 4 ++-- test_common/harness/testHarness.h | 18 ++++++++++++------ test_conformance/basic/test_preprocessors.cpp | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test_common/harness/rounding_mode.cpp b/test_common/harness/rounding_mode.cpp index fd31146713..bb7539dd19 100644 --- a/test_common/harness/rounding_mode.cpp +++ b/test_common/harness/rounding_mode.cpp @@ -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); @@ -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__) diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index 15dfdf52b8..772eb5f51c 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -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; diff --git a/test_conformance/basic/test_preprocessors.cpp b/test_conformance/basic/test_preprocessors.cpp index 2038d15076..818a0476ea 100644 --- a/test_conformance/basic/test_preprocessors.cpp +++ b/test_conformance/basic/test_preprocessors.cpp @@ -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 " @@ -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__");