From 39fdb462be7ea4bf2c2b2c6d23e84a70c3def78d Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Sat, 28 Aug 2021 02:21:34 -0700 Subject: [PATCH] define NOMINMAX in the CMakefile to fix std::min and std::max on MSVC (#1308) --- CMakeLists.txt | 2 ++ test_common/harness/kernelHelpers.cpp | 2 +- test_common/harness/os_helpers.cpp | 3 --- test_conformance/basic/test_async_copy2D.cpp | 4 ++-- test_conformance/basic/test_async_copy3D.cpp | 4 ++-- test_conformance/integer_ops/test_integer_dot_product.cpp | 5 ----- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a614649f..04551dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,8 @@ endif() if(MSVC) # Don't warn when using standard non-secure functions. add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + # Fix std::min and std::max handling with windows.harness. + add_compile_definitions(NOMINMAX) endif() if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" ) diff --git a/test_common/harness/kernelHelpers.cpp b/test_common/harness/kernelHelpers.cpp index 18f51cbe..1d1f8d8c 100644 --- a/test_common/harness/kernelHelpers.cpp +++ b/test_common/harness/kernelHelpers.cpp @@ -1707,7 +1707,7 @@ Version get_max_OpenCL_C_for_context(cl_context context) else { current_version = - (std::min)(device_version, current_version); + std::min(device_version, current_version); } }); return current_version; diff --git a/test_common/harness/os_helpers.cpp b/test_common/harness/os_helpers.cpp index daf21958..8fc91108 100644 --- a/test_common/harness/os_helpers.cpp +++ b/test_common/harness/os_helpers.cpp @@ -333,9 +333,6 @@ std::string exe_dir() #include -#if defined(max) -#undef max -#endif #include #include diff --git a/test_conformance/basic/test_async_copy2D.cpp b/test_conformance/basic/test_async_copy2D.cpp index 9fbdcb6e..fafcac83 100644 --- a/test_conformance/basic/test_async_copy2D.cpp +++ b/test_conformance/basic/test_async_copy2D.cpp @@ -203,13 +203,13 @@ int test_copy2D(cl_device_id deviceID, cl_context context, / (numElementsPerLine + srcStride); size_t maxTotalLinesOut = (max_alloc_size / elementSize + dstStride) / (numElementsPerLine + dstStride); - size_t maxTotalLines = (std::min)(maxTotalLinesIn, maxTotalLinesOut); + size_t maxTotalLines = std::min(maxTotalLinesIn, maxTotalLinesOut); size_t maxLocalWorkgroups = maxTotalLines / (localWorkgroupSize * lineCopiesPerWorkItem); size_t localBufferSize = localWorkgroupSize * localStorageSpacePerWorkitem - (localIsDst ? dstStride : srcStride); - size_t numberOfLocalWorkgroups = (std::min)(1111, (int)maxLocalWorkgroups); + size_t numberOfLocalWorkgroups = std::min(1111, (int)maxLocalWorkgroups); size_t totalLines = numberOfLocalWorkgroups * localWorkgroupSize * lineCopiesPerWorkItem; size_t inBufferSize = elementSize diff --git a/test_conformance/basic/test_async_copy3D.cpp b/test_conformance/basic/test_async_copy3D.cpp index 252159bc..2b184ee5 100644 --- a/test_conformance/basic/test_async_copy3D.cpp +++ b/test_conformance/basic/test_async_copy3D.cpp @@ -230,13 +230,13 @@ int test_copy3D(cl_device_id deviceID, cl_context context, size_t maxTotalPlanesOut = ((max_alloc_size / elementSize) + dstPlaneStride) / ((numLines * numElementsPerLine + numLines * dstLineStride) + dstPlaneStride); - size_t maxTotalPlanes = (std::min)(maxTotalPlanesIn, maxTotalPlanesOut); + size_t maxTotalPlanes = std::min(maxTotalPlanesIn, maxTotalPlanesOut); size_t maxLocalWorkgroups = maxTotalPlanes / (localWorkgroupSize * planesCopiesPerWorkItem); size_t localBufferSize = localWorkgroupSize * localStorageSpacePerWorkitem - (localIsDst ? dstPlaneStride : srcPlaneStride); - size_t numberOfLocalWorkgroups = (std::min)(1111, (int)maxLocalWorkgroups); + size_t numberOfLocalWorkgroups = std::min(1111, (int)maxLocalWorkgroups); size_t totalPlanes = numberOfLocalWorkgroups * localWorkgroupSize * planesCopiesPerWorkItem; size_t inBufferSize = elementSize diff --git a/test_conformance/integer_ops/test_integer_dot_product.cpp b/test_conformance/integer_ops/test_integer_dot_product.cpp index b5378ae0..be25b320 100644 --- a/test_conformance/integer_ops/test_integer_dot_product.cpp +++ b/test_conformance/integer_ops/test_integer_dot_product.cpp @@ -14,11 +14,6 @@ // limitations under the License. // -// This is needed for std::numeric_limits<>::min() and max() to work on Windows. -#if defined(_WIN32) -#define NOMINMAX -#endif - #include #include #include