diff --git a/cmake/ThrustBuildCompilerTargets.cmake b/cmake/ThrustBuildCompilerTargets.cmake index bf0b31ed4c..560919ef44 100644 --- a/cmake/ThrustBuildCompilerTargets.cmake +++ b/cmake/ThrustBuildCompilerTargets.cmake @@ -73,9 +73,6 @@ function(thrust_build_compiler_targets) # Some of the async tests require /bigobj to fit all their sections into the # object files: append_option_if_available("/bigobj" cxx_compile_options) - - # "Oh right, this is Visual Studio." - list(APPEND cxx_compile_definitions "NOMINMAX") else() append_option_if_available("-Werror" cxx_compile_options) append_option_if_available("-Wall" cxx_compile_options) diff --git a/cmake/header_test.in b/cmake/header_test.in index 6f20d259b0..c49deed2a5 100644 --- a/cmake/header_test.in +++ b/cmake/header_test.in @@ -15,7 +15,10 @@ // Hacky way to build a string, but it works on all tested platforms. #define THRUST_MACRO_CHECK(MACRO, HEADER) \ THRUST_MACRO_CHECK_IMPL(Identifier MACRO should not be used from Thrust \ - headers due to conflicts with HEADER.) + headers due to conflicts with HEADER macros.) +#define THRUST_MACRO_FUNCTION_CHECK(MACRO, HEADER) \ + THRUST_MACRO_CHECK_IMPL(Wrap MACRO in parentheses when used in Thrust \ + headers to avoid conflicts with HEADER macros.) // Use raw platform checks instead of the THRUST_HOST_COMPILER macros since we // don't want to #include any headers other than the one being tested. @@ -42,13 +45,14 @@ #endif // complex.h conflicts -#define I THRUST_MACRO_CHECK('I', complex.h) +#define I THRUST_MACRO_CHECK("I", complex.h) // windows.h conflicts -// Disabling for now; we use min/max in many places, but since most -// projects build with NOMINMAX this doesn't seem to be high priority to fix. -//#define min(...) THRUST_MACRO_CHECK('min', windows.h) -//#define max(...) THRUST_MACRO_CHECK('max', windows.h) +// Note that these are unlikely to be caught by builds against gcc's +// stdlib, since their bits/c++config.h header unconditionally undefs both +// min/max because of the windows.h macros. MSVC builds should catch this, tho. +#define min(...) THRUST_MACRO_FUNCTION_CHECK("min", windows.h) +#define max(...) THRUST_MACRO_FUNCTION_CHECK("max", windows.h) #endif // THRUST_IGNORE_MACRO_CHECKS diff --git a/dependencies/cub b/dependencies/cub index b7396790ed..89ec3cf0d8 160000 --- a/dependencies/cub +++ b/dependencies/cub @@ -1 +1 @@ -Subproject commit b7396790ed229d387987104d0db3af52bba6394b +Subproject commit 89ec3cf0d82f168a1929d304a0320ff83fcef788 diff --git a/examples/bounding_box.cu b/examples/bounding_box.cu index cca71a45e4..0d71958341 100644 --- a/examples/bounding_box.cu +++ b/examples/bounding_box.cu @@ -56,10 +56,10 @@ struct bbox_reduction : public thrust::binary_function bbox operator()(bbox a, bbox b) { // lower left corner - point2d ll(thrust::min(a.lower_left.x, b.lower_left.x), thrust::min(a.lower_left.y, b.lower_left.y)); + point2d ll((thrust::min)(a.lower_left.x, b.lower_left.x), (thrust::min)(a.lower_left.y, b.lower_left.y)); // upper right corner - point2d ur(thrust::max(a.upper_right.x, b.upper_right.x), thrust::max(a.upper_right.y, b.upper_right.y)); + point2d ur((thrust::max)(a.upper_right.x, b.upper_right.x), (thrust::max)(a.upper_right.y, b.upper_right.y)); return bbox(ll, ur); } diff --git a/examples/discrete_voronoi.cu b/examples/discrete_voronoi.cu index bfbf2242d9..e3457c4a77 100644 --- a/examples/discrete_voronoi.cu +++ b/examples/discrete_voronoi.cu @@ -222,7 +222,7 @@ int main(void) seeds.swap(temp); //JFA : main loop with k=n/2, n/4, ..., 1 - for(int k = thrust::max(m,n) / 2; k > 0; k /= 2) + for(int k = (thrust::max)(m,n) / 2; k > 0; k /= 2) { jfa(seeds,temp,k,m,n); seeds.swap(temp); diff --git a/examples/minmax.cu b/examples/minmax.cu index 3b4a538813..b215da2fc3 100644 --- a/examples/minmax.cu +++ b/examples/minmax.cu @@ -46,8 +46,8 @@ struct minmax_binary_op minmax_pair operator()(const minmax_pair& x, const minmax_pair& y) const { minmax_pair result; - result.min_val = thrust::min(x.min_val, y.min_val); - result.max_val = thrust::max(x.max_val, y.max_val); + result.min_val = (thrust::min)(x.min_val, y.min_val); + result.max_val = (thrust::max)(x.max_val, y.max_val); return result; } }; diff --git a/examples/padded_grid_reduction.cu b/examples/padded_grid_reduction.cu index 2467debca8..9984c9348b 100644 --- a/examples/padded_grid_reduction.cu +++ b/examples/padded_grid_reduction.cu @@ -54,8 +54,8 @@ struct reduce_tuple : { if(thrust::get<0>(t0) && thrust::get<0>(t1)) // both valid return Tuple(true, - thrust::min(thrust::get<1>(t0), thrust::get<1>(t1)), - thrust::max(thrust::get<2>(t0), thrust::get<2>(t1))); + (thrust::min)(thrust::get<1>(t0), thrust::get<1>(t1)), + (thrust::max)(thrust::get<2>(t0), thrust::get<2>(t1))); else if (thrust::get<0>(t0)) return t0; else if (thrust::get<0>(t1)) diff --git a/examples/set_operations.cu b/examples/set_operations.cu index 43e5bbd598..4c639e7257 100644 --- a/examples/set_operations.cu +++ b/examples/set_operations.cu @@ -73,7 +73,7 @@ template void SetIntersection(const Vector& A, const Vector& B) { // intersection output is at most min(A.size(), B.size()) - Vector C(thrust::min(A.size(), B.size())); + Vector C((thrust::min)(A.size(), B.size())); // set_union returns an iterator C_end denoting the end of input typename Vector::iterator C_end; diff --git a/examples/summary_statistics.cu b/examples/summary_statistics.cu index 38785e2b77..f269374cad 100644 --- a/examples/summary_statistics.cu +++ b/examples/summary_statistics.cu @@ -31,8 +31,8 @@ struct summary_stats_data void initialize() { n = mean = M2 = M3 = M4 = 0; - min = std::numeric_limits::max(); - max = std::numeric_limits::min(); + min = (std::numeric_limits::max)(); + max = (std::numeric_limits::min)(); } T variance() { return M2 / (n - 1); } @@ -89,8 +89,8 @@ struct summary_stats_binary_op //Basic number of samples (n), min, and max result.n = n; - result.min = thrust::min(x.min, y.min); - result.max = thrust::max(x.max, y.max); + result.min = (thrust::min)(x.min, y.min); + result.max = (thrust::max)(x.max, y.max); result.mean = x.mean + delta * y.n / n; diff --git a/testing/counting_iterator.cu b/testing/counting_iterator.cu index ebefe4d64a..63ad90986a 100644 --- a/testing/counting_iterator.cu +++ b/testing/counting_iterator.cu @@ -220,7 +220,7 @@ void TestCountingIteratorDifference(void) typedef thrust::counting_iterator Iterator; typedef thrust::iterator_difference::type Difference; - Difference diff = std::numeric_limits::max() + 1; + Difference diff = (std::numeric_limits::max)() + 1; Iterator first(0); Iterator last = first + diff; diff --git a/testing/cuda/fill.cu b/testing/cuda/fill.cu index 17cf58c547..a25a13c254 100644 --- a/testing/cuda/fill.cu +++ b/testing/cuda/fill.cu @@ -17,9 +17,9 @@ void TestFillDevice(ExecutionPolicy exec, size_t n) thrust::host_vector h_data = unittest::random_integers(n); thrust::device_vector d_data = h_data; - thrust::fill(h_data.begin() + std::min((size_t)1, n), h_data.begin() + std::min((size_t)3, n), (T) 0); + thrust::fill(h_data.begin() + (std::min)((size_t)1, n), h_data.begin() + (std::min)((size_t)3, n), (T) 0); - fill_kernel<<<1,1>>>(exec, d_data.begin() + std::min((size_t)1, n), d_data.begin() + std::min((size_t)3, n), (T) 0); + fill_kernel<<<1,1>>>(exec, d_data.begin() + (std::min)((size_t)1, n), d_data.begin() + (std::min)((size_t)3, n), (T) 0); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -27,9 +27,9 @@ void TestFillDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)117, n), h_data.begin() + std::min((size_t)367, n), (T) 1); + thrust::fill(h_data.begin() + (std::min)((size_t)117, n), h_data.begin() + (std::min)((size_t)367, n), (T) 1); - fill_kernel<<<1,1>>>(exec, d_data.begin() + std::min((size_t)117, n), d_data.begin() + std::min((size_t)367, n), (T) 1); + fill_kernel<<<1,1>>>(exec, d_data.begin() + (std::min)((size_t)117, n), d_data.begin() + (std::min)((size_t)367, n), (T) 1); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -37,9 +37,9 @@ void TestFillDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)8, n), h_data.begin() + std::min((size_t)259, n), (T) 2); + thrust::fill(h_data.begin() + (std::min)((size_t)8, n), h_data.begin() + (std::min)((size_t)259, n), (T) 2); - fill_kernel<<<1,1>>>(exec, d_data.begin() + std::min((size_t)8, n), d_data.begin() + std::min((size_t)259, n), (T) 2); + fill_kernel<<<1,1>>>(exec, d_data.begin() + (std::min)((size_t)8, n), d_data.begin() + (std::min)((size_t)259, n), (T) 2); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -47,9 +47,9 @@ void TestFillDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)3, n), h_data.end(), (T) 3); + thrust::fill(h_data.begin() + (std::min)((size_t)3, n), h_data.end(), (T) 3); - fill_kernel<<<1,1>>>(exec, d_data.begin() + std::min((size_t)3, n), d_data.end(), (T) 3); + fill_kernel<<<1,1>>>(exec, d_data.begin() + (std::min)((size_t)3, n), d_data.end(), (T) 3); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -97,11 +97,11 @@ void TestFillNDevice(ExecutionPolicy exec, size_t n) thrust::host_vector h_data = unittest::random_integers(n); thrust::device_vector d_data = h_data; - size_t begin_offset = std::min(1,n); + size_t begin_offset = (std::min)(1,n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)3, n) - begin_offset, (T) 0); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)3, n) - begin_offset, (T) 0); - fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, std::min((size_t)3, n) - begin_offset, (T) 0); + fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, (std::min)((size_t)3, n) - begin_offset, (T) 0); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -109,11 +109,11 @@ void TestFillNDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(117, n); + begin_offset = (std::min)(117, n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)367, n) - begin_offset, (T) 1); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)367, n) - begin_offset, (T) 1); - fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, std::min((size_t)367, n) - begin_offset, (T) 1); + fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, (std::min)((size_t)367, n) - begin_offset, (T) 1); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -121,11 +121,11 @@ void TestFillNDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(8, n); + begin_offset = (std::min)(8, n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)259, n) - begin_offset, (T) 2); - fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2); + fill_n_kernel<<<1,1>>>(exec, d_data.begin() + begin_offset, (std::min)((size_t)259, n) - begin_offset, (T) 2); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -133,7 +133,7 @@ void TestFillNDevice(ExecutionPolicy exec, size_t n) ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(3, n); + begin_offset = (std::min)(3, n); thrust::fill_n(h_data.begin() + begin_offset, h_data.size() - begin_offset, (T) 3); diff --git a/testing/cuda/for_each.cu b/testing/cuda/for_each.cu index be6a7738c5..01314d9e1d 100644 --- a/testing/cuda/for_each.cu +++ b/testing/cuda/for_each.cu @@ -69,7 +69,7 @@ __global__ void for_each_kernel(ExecutionPolicy exec, Iterator first, Iterator l template void TestForEachDeviceSeq(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); @@ -100,7 +100,7 @@ DECLARE_VARIABLE_UNITTEST(TestForEachDeviceSeq); template void TestForEachDeviceDevice(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); @@ -145,7 +145,7 @@ void for_each_n_kernel(ExecutionPolicy exec, Iterator first, Size n, Function f) template void TestForEachNDeviceSeq(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); @@ -176,7 +176,7 @@ DECLARE_VARIABLE_UNITTEST(TestForEachNDeviceSeq); template void TestForEachNDeviceDevice(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); diff --git a/testing/cuda/gather.cu b/testing/cuda/gather.cu index a9a8c9333e..d7137582a6 100644 --- a/testing/cuda/gather.cu +++ b/testing/cuda/gather.cu @@ -14,7 +14,7 @@ void gather_kernel(ExecutionPolicy exec, Iterator1 map_first, Iterator1 map_last template void TestGatherDevice(ExecutionPolicy exec, const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); @@ -107,7 +107,7 @@ struct is_even_gather_if template void TestGatherIfDevice(ExecutionPolicy exec, const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); diff --git a/testing/cuda/scatter.cu b/testing/cuda/scatter.cu index 52bd9755f5..9f9ddab428 100644 --- a/testing/cuda/scatter.cu +++ b/testing/cuda/scatter.cu @@ -15,7 +15,7 @@ template void TestScatterDevice(ExecutionPolicy exec) { size_t n = 1000; - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input(n, 1); thrust::device_vector d_input(n, 1); @@ -73,7 +73,7 @@ template void TestScatterIfDevice(ExecutionPolicy exec) { size_t n = 1000; - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input(n, 1); thrust::device_vector d_input(n, 1); diff --git a/testing/fill.cu b/testing/fill.cu index 7154b4118f..43f8ba2876 100644 --- a/testing/fill.cu +++ b/testing/fill.cu @@ -92,23 +92,23 @@ void TestFill(size_t n) thrust::host_vector h_data = unittest::random_integers(n); thrust::device_vector d_data = h_data; - thrust::fill(h_data.begin() + std::min((size_t)1, n), h_data.begin() + std::min((size_t)3, n), (T) 0); - thrust::fill(d_data.begin() + std::min((size_t)1, n), d_data.begin() + std::min((size_t)3, n), (T) 0); + thrust::fill(h_data.begin() + (std::min)((size_t)1, n), h_data.begin() + (std::min)((size_t)3, n), (T) 0); + thrust::fill(d_data.begin() + (std::min)((size_t)1, n), d_data.begin() + (std::min)((size_t)3, n), (T) 0); ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)117, n), h_data.begin() + std::min((size_t)367, n), (T) 1); - thrust::fill(d_data.begin() + std::min((size_t)117, n), d_data.begin() + std::min((size_t)367, n), (T) 1); + thrust::fill(h_data.begin() + (std::min)((size_t)117, n), h_data.begin() + (std::min)((size_t)367, n), (T) 1); + thrust::fill(d_data.begin() + (std::min)((size_t)117, n), d_data.begin() + (std::min)((size_t)367, n), (T) 1); ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)8, n), h_data.begin() + std::min((size_t)259, n), (T) 2); - thrust::fill(d_data.begin() + std::min((size_t)8, n), d_data.begin() + std::min((size_t)259, n), (T) 2); + thrust::fill(h_data.begin() + (std::min)((size_t)8, n), h_data.begin() + (std::min)((size_t)259, n), (T) 2); + thrust::fill(d_data.begin() + (std::min)((size_t)8, n), d_data.begin() + (std::min)((size_t)259, n), (T) 2); ASSERT_EQUAL(h_data, d_data); - thrust::fill(h_data.begin() + std::min((size_t)3, n), h_data.end(), (T) 3); - thrust::fill(d_data.begin() + std::min((size_t)3, n), d_data.end(), (T) 3); + thrust::fill(h_data.begin() + (std::min)((size_t)3, n), h_data.end(), (T) 3); + thrust::fill(d_data.begin() + (std::min)((size_t)3, n), d_data.end(), (T) 3); ASSERT_EQUAL(h_data, d_data); @@ -216,25 +216,25 @@ void TestFillN(size_t n) thrust::host_vector h_data = unittest::random_integers(n); thrust::device_vector d_data = h_data; - size_t begin_offset = std::min(1,n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)3, n) - begin_offset, (T) 0); - thrust::fill_n(d_data.begin() + begin_offset, std::min((size_t)3, n) - begin_offset, (T) 0); + size_t begin_offset = (std::min)(1,n); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)3, n) - begin_offset, (T) 0); + thrust::fill_n(d_data.begin() + begin_offset, (std::min)((size_t)3, n) - begin_offset, (T) 0); ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(117, n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)367, n) - begin_offset, (T) 1); - thrust::fill_n(d_data.begin() + begin_offset, std::min((size_t)367, n) - begin_offset, (T) 1); + begin_offset = (std::min)(117, n); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)367, n) - begin_offset, (T) 1); + thrust::fill_n(d_data.begin() + begin_offset, (std::min)((size_t)367, n) - begin_offset, (T) 1); ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(8, n); - thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2); - thrust::fill_n(d_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2); + begin_offset = (std::min)(8, n); + thrust::fill_n(h_data.begin() + begin_offset, (std::min)((size_t)259, n) - begin_offset, (T) 2); + thrust::fill_n(d_data.begin() + begin_offset, (std::min)((size_t)259, n) - begin_offset, (T) 2); ASSERT_EQUAL(h_data, d_data); - begin_offset = std::min(3, n); + begin_offset = (std::min)(3, n); thrust::fill_n(h_data.begin() + begin_offset, h_data.size() - begin_offset, (T) 3); thrust::fill_n(d_data.begin() + begin_offset, d_data.size() - begin_offset, (T) 3); diff --git a/testing/for_each.cu b/testing/for_each.cu index 8040e5f785..106938ea5d 100644 --- a/testing/for_each.cu +++ b/testing/for_each.cu @@ -194,7 +194,7 @@ DECLARE_UNITTEST(TestForEachNSimpleAnySystem); template void TestForEach(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); @@ -227,7 +227,7 @@ DECLARE_VARIABLE_UNITTEST(TestForEach); template void TestForEachN(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input = unittest::random_integers(n); diff --git a/testing/gather.cu b/testing/gather.cu index c164e44b2b..0dbeb43820 100644 --- a/testing/gather.cu +++ b/testing/gather.cu @@ -79,7 +79,7 @@ DECLARE_UNITTEST(TestGatherDispatchImplicit); template void TestGather(const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); @@ -108,7 +108,7 @@ DECLARE_VARIABLE_UNITTEST(TestGather); template void TestGatherToDiscardIterator(const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); @@ -234,7 +234,7 @@ DECLARE_UNITTEST(TestGatherIfDispatchImplicit); template void TestGatherIf(const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); @@ -272,7 +272,7 @@ DECLARE_VARIABLE_UNITTEST(TestGatherIf); template void TestGatherIfToDiscardIterator(const size_t n) { - const size_t source_size = std::min((size_t) 10, 2 * n); + const size_t source_size = (std::min)((size_t) 10, 2 * n); // source vectors to gather from thrust::host_vector h_source = unittest::random_samples(source_size); diff --git a/testing/random.cu b/testing/random.cu index 53a165055b..933cb4e367 100644 --- a/testing/random.cu +++ b/testing/random.cu @@ -169,7 +169,7 @@ template for(int i = 0; i < 10000; ++i) { - result &= (d(e) >= d.min()); + result &= (d(e) >= (d.min)()); } return result; @@ -198,7 +198,7 @@ template for(int i = 0; i < 10000; ++i) { - result &= (d(e) <= d.max()); + result &= (d(e) <= (d.max)()); } return result; diff --git a/testing/scan.cu b/testing/scan.cu index 3422841b03..72191a3be5 100644 --- a/testing/scan.cu +++ b/testing/scan.cu @@ -17,7 +17,7 @@ template __host__ __device__ T operator()(T rhs, T lhs) const { - return thrust::max(rhs,lhs); + return (thrust::max)(rhs,lhs); } }; diff --git a/testing/scatter.cu b/testing/scatter.cu index ffd56f27c1..0b1b57e3c5 100644 --- a/testing/scatter.cu +++ b/testing/scatter.cu @@ -90,7 +90,7 @@ DECLARE_UNITTEST(TestScatterDispatchImplicit); template void TestScatter(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input(n, (T) 1); thrust::device_vector d_input(n, (T) 1); @@ -116,7 +116,7 @@ DECLARE_VARIABLE_UNITTEST(TestScatter); template void TestScatterToDiscardIterator(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input(n, (T) 1); thrust::device_vector d_input(n, (T) 1); @@ -233,7 +233,7 @@ class is_even_scatter_if template void TestScatterIf(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); + const size_t output_size = (std::min)((size_t) 10, 2 * n); thrust::host_vector h_input(n, (T) 1); thrust::device_vector d_input(n, (T) 1); @@ -259,8 +259,8 @@ DECLARE_VARIABLE_UNITTEST(TestScatterIf); template void TestScatterIfToDiscardIterator(const size_t n) { - const size_t output_size = std::min((size_t) 10, 2 * n); - + const size_t output_size = (std::min)((size_t) 10, 2 * n); + thrust::host_vector h_input(n, (T) 1); thrust::device_vector d_input(n, (T) 1); diff --git a/testing/shuffle.cu b/testing/shuffle.cu index a5b1c6f296..dd5b802b49 100644 --- a/testing/shuffle.cu +++ b/testing/shuffle.cu @@ -383,7 +383,7 @@ void TestFunctionIsBijection(size_t m) { thrust::system::detail::generic::feistel_bijection host_f(m, host_g); thrust::system::detail::generic::feistel_bijection device_f(m, device_g); - if (host_f.nearest_power_of_two() >= std::numeric_limits::max() || m == 0) { + if (host_f.nearest_power_of_two() >= (std::numeric_limits::max)() || m == 0) { return; } @@ -561,7 +561,7 @@ void TestShuffleEvenDistribution() { const uint64_t shuffle_sizes[] = {10, 100, 500}; thrust::default_random_engine g(0xD5); for (auto shuffle_size : shuffle_sizes) { - if(shuffle_size > std::numeric_limits::max()) + if(shuffle_size > (std::numeric_limits::max)()) continue; const uint64_t num_samples = shuffle_size == 500 ? 1000 : 200; diff --git a/testing/unittest/assertions.h b/testing/unittest/assertions.h index 855d705a4c..bcb277d9bb 100644 --- a/testing/unittest/assertions.h +++ b/testing/unittest/assertions.h @@ -397,7 +397,7 @@ void assert_equal(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterat difference_type length1 = THRUST_NS_QUALIFIER::distance(first1, last1); difference_type length2 = THRUST_NS_QUALIFIER::distance(first2, last2); - difference_type min_length = THRUST_NS_QUALIFIER::min(length1, length2); + difference_type min_length = (THRUST_NS_QUALIFIER::min)(length1, length2); unittest::UnitTestFailure f; f << "[" << filename << ":" << lineno << "] "; diff --git a/testing/unittest/random.h b/testing/unittest/random.h index c94c3fecb0..ee687ffc1f 100644 --- a/testing/unittest/random.h +++ b/testing/unittest/random.h @@ -63,8 +63,8 @@ template { T operator()(unsigned int i) const { - T const min = std::numeric_limits::min(); - T const max = std::numeric_limits::max(); + T const min = (std::numeric_limits::min)(); + T const max = (std::numeric_limits::max)(); THRUST_NS_QUALIFIER::default_random_engine rng(hash(i)); THRUST_NS_QUALIFIER::uniform_real_distribution dist(min, max); diff --git a/testing/unittest/util.h b/testing/unittest/util.h index 986f80c7b5..48e0c4e1c9 100644 --- a/testing/unittest/util.h +++ b/testing/unittest/util.h @@ -28,7 +28,7 @@ typename THRUST_NS_QUALIFIER::detail::disable_if< { return static_cast(THRUST_NS_QUALIFIER::min( n, - static_cast(THRUST_NS_QUALIFIER::numeric_limits::max()))); + static_cast((THRUST_NS_QUALIFIER::numeric_limits::max)()))); } // TODO: This probably won't work for `half`. @@ -40,7 +40,7 @@ typename THRUST_NS_QUALIFIER::detail::enable_if< { return THRUST_NS_QUALIFIER::min( static_cast(n), - THRUST_NS_QUALIFIER::numeric_limits::max()); + (THRUST_NS_QUALIFIER::numeric_limits::max)()); } } // end unittest diff --git a/testing/vector.cu b/testing/vector.cu index de211af933..4141804e2d 100644 --- a/testing/vector.cu +++ b/testing/vector.cu @@ -597,7 +597,7 @@ void TestVectorResizing(void) // of two possible exceptions try { - v.resize(std::numeric_limits::max()); + v.resize((std::numeric_limits::max)()); } catch(std::length_error e) {} catch(std::bad_alloc e) @@ -632,7 +632,7 @@ void TestVectorReserving(void) #if defined(__CUDACC__) && CUDART_VERSION==3000 try { - v.reserve(std::numeric_limits::max()); + v.reserve((std::numeric_limits::max)()); } catch(std::length_error e) {} catch(std::bad_alloc e) {} diff --git a/thrust/system/cuda/detail/extrema.h b/thrust/system/cuda/detail/extrema.h index 0937beb8bc..c7e98aaa58 100644 --- a/thrust/system/cuda/detail/extrema.h +++ b/thrust/system/cuda/detail/extrema.h @@ -265,7 +265,7 @@ namespace __extrema { // if not enough to fill the device with threadblocks // then fill the device with threadblocks - reduce_grid_size = static_cast(min(num_tiles, static_cast(reduce_device_occupancy))); + reduce_grid_size = static_cast((min)(num_tiles, static_cast(reduce_device_occupancy))); typedef AgentLauncher<__reduce::DrainAgent > drain_agent; AgentPlan drain_plan = drain_agent::get_plan(); diff --git a/thrust/system/cuda/detail/merge.h b/thrust/system/cuda/detail/merge.h index 160c41ea4c..ef8d69dadf 100644 --- a/thrust/system/cuda/detail/merge.h +++ b/thrust/system/cuda/detail/merge.h @@ -170,7 +170,7 @@ namespace __merge { Size partition_idx = blockDim.x * blockIdx.x + threadIdx.x; if (partition_idx < num_partitions) { - Size partition_at = thrust::min(partition_idx * items_per_tile, + Size partition_at = (thrust::min)(partition_idx * items_per_tile, keys1_count + keys2_count); Size partition_diag = merge_path(keys1, keys2, @@ -463,7 +463,7 @@ namespace __merge { Size partition_end = merge_partitions[tile_idx + 1]; Size diag0 = ITEMS_PER_TILE * tile_idx; - Size diag1 = thrust::min(keys1_count + keys2_count, diag0 + ITEMS_PER_TILE); + Size diag1 = (thrust::min)(keys1_count + keys2_count, diag0 + ITEMS_PER_TILE); // compute bounding box for keys1 & keys2 // diff --git a/thrust/system/cuda/detail/reduce.h b/thrust/system/cuda/detail/reduce.h index 43c85bd0bb..0cb83f2df2 100644 --- a/thrust/system/cuda/detail/reduce.h +++ b/thrust/system/cuda/detail/reduce.h @@ -808,7 +808,7 @@ namespace __reduce { // if not enough to fill the device with threadblocks // then fill the device with threadblocks - reduce_grid_size = static_cast(min(num_tiles, static_cast(reduce_device_occupancy))); + reduce_grid_size = static_cast((min)(num_tiles, static_cast(reduce_device_occupancy))); typedef AgentLauncher > drain_agent; AgentPlan drain_plan = drain_agent::get_plan(); diff --git a/thrust/system/detail/sequential/stable_merge_sort.inl b/thrust/system/detail/sequential/stable_merge_sort.inl index 631b3c73a4..921b45aa39 100644 --- a/thrust/system/detail/sequential/stable_merge_sort.inl +++ b/thrust/system/detail/sequential/stable_merge_sort.inl @@ -97,7 +97,7 @@ void insertion_sort_each(RandomAccessIterator first, { for(; first < last; first += partition_size) { - RandomAccessIterator partition_last = thrust::min(last, first + partition_size); + RandomAccessIterator partition_last = (thrust::min)(last, first + partition_size); thrust::system::detail::sequential::insertion_sort(first, partition_last, comp); } // end for @@ -120,7 +120,7 @@ void insertion_sort_each_by_key(RandomAccessIterator1 keys_first, { for(; keys_first < keys_last; keys_first += partition_size, values_first += partition_size) { - RandomAccessIterator1 keys_partition_last = thrust::min(keys_last, keys_first + partition_size); + RandomAccessIterator1 keys_partition_last = (thrust::min)(keys_last, keys_first + partition_size); thrust::system::detail::sequential::insertion_sort_by_key(keys_first, keys_partition_last, values_first, comp); } // end for @@ -143,8 +143,8 @@ void merge_adjacent_partitions(sequential::execution_policy &exec { for(; first < last; first += 2 * partition_size, result += 2 * partition_size) { - RandomAccessIterator1 interval_middle = thrust::min(last, first + partition_size); - RandomAccessIterator1 interval_last = thrust::min(last, interval_middle + partition_size); + RandomAccessIterator1 interval_middle = (thrust::min)(last, first + partition_size); + RandomAccessIterator1 interval_last = (thrust::min)(last, interval_middle + partition_size); thrust::merge(exec, first, interval_middle, @@ -178,8 +178,8 @@ void merge_adjacent_partitions_by_key(sequential::execution_policy