From 1bb49720e50f35c347b43ed5bb944917265c237a Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 9 Sep 2024 10:06:47 +0200 Subject: [PATCH 1/2] Drop thrusts diagnostic suppression warnings We have global suppression warnings for CCCL, so use them --- thrust/testing/binary_search.cu | 5 +- thrust/testing/counting_iterator.cu | 5 +- thrust/testing/dereference.cu | 5 +- thrust/testing/fill.cu | 5 +- thrust/testing/for_each.cu | 5 +- thrust/testing/functional.cu | 5 +- thrust/testing/gather.cu | 5 +- thrust/testing/generate.cu | 5 +- thrust/testing/random.cu | 5 +- thrust/testing/unittest/testframework.cu | 5 +- thrust/testing/vector.cu | 10 +- thrust/thrust/detail/config/compiler.h | 100 ------------------ thrust/thrust/iterator/detail/join_iterator.h | 5 +- thrust/thrust/iterator/discard_iterator.h | 5 +- thrust/thrust/iterator/permutation_iterator.h | 5 +- thrust/thrust/iterator/transform_iterator.h | 5 +- thrust/thrust/system/cuda/detail/future.inl | 7 +- .../thrust/system/detail/error_category.inl | 5 +- 18 files changed, 58 insertions(+), 134 deletions(-) diff --git a/thrust/testing/binary_search.cu b/thrust/testing/binary_search.cu index e27d5a0c98..974b37ed54 100644 --- a/thrust/testing/binary_search.cu +++ b/thrust/testing/binary_search.cu @@ -5,7 +5,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data ////////////////////// // Scalar Functions // @@ -263,7 +264,7 @@ void TestScalarEqualRangeDispatchImplicit() } DECLARE_UNITTEST(TestScalarEqualRangeDispatchImplicit); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP void TestBoundsWithBigIndexesHelper(int magnitude) { diff --git a/thrust/testing/counting_iterator.cu b/thrust/testing/counting_iterator.cu index 410453363a..9e52021b7d 100644 --- a/thrust/testing/counting_iterator.cu +++ b/thrust/testing/counting_iterator.cu @@ -10,7 +10,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data // ensure that we properly support thrust::counting_iterator from cuda::std void test_iterator_traits() @@ -245,4 +246,4 @@ void TestCountingIteratorDifference() } DECLARE_UNITTEST(TestCountingIteratorDifference); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/dereference.cu b/thrust/testing/dereference.cu index e198cd820d..4a69fa6cb1 100644 --- a/thrust/testing/dereference.cu +++ b/thrust/testing/dereference.cu @@ -6,7 +6,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data template #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA @@ -106,4 +107,4 @@ void TestDeviceDereferenceTransformedCountingIterator() } DECLARE_UNITTEST(TestDeviceDereferenceTransformedCountingIterator); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/fill.cu b/thrust/testing/fill.cu index 883f1b8393..b4eba59fab 100644 --- a/thrust/testing/fill.cu +++ b/thrust/testing/fill.cu @@ -7,7 +7,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data template void TestFillSimple() @@ -446,4 +447,4 @@ void TestFillNDispatchImplicit() } DECLARE_UNITTEST(TestFillNDispatchImplicit); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/for_each.cu b/thrust/testing/for_each.cu index 90527e12ac..eb3a9bea4d 100644 --- a/thrust/testing/for_each.cu +++ b/thrust/testing/for_each.cu @@ -9,7 +9,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data template class mark_present_for_each @@ -354,7 +355,7 @@ void TestForEachNWithLargeTypes() } DECLARE_UNITTEST(TestForEachNWithLargeTypes); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP struct only_set_when_expected { diff --git a/thrust/testing/functional.cu b/thrust/testing/functional.cu index 00114012c0..105ad23aaf 100644 --- a/thrust/testing/functional.cu +++ b/thrust/testing/functional.cu @@ -6,7 +6,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data // There is a unfortunate miscompilation of the gcc-11 vectorizer leading to OOB writes // Adding this attribute suffices that this miscompilation does not appear anymore @@ -366,4 +367,4 @@ DECLARE_VECTOR_UNITTEST(TestNot2); #endif // Weird GCC11 failure case -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/gather.cu b/thrust/testing/gather.cu index 2730fc192c..c1c5ee3c63 100644 --- a/thrust/testing/gather.cu +++ b/thrust/testing/gather.cu @@ -9,7 +9,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data template void TestGatherSimple() @@ -361,4 +362,4 @@ void TestGatherCountingIterator() } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestGatherCountingIterator); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/generate.cu b/thrust/testing/generate.cu index 0e919b76f0..0fc734cc79 100644 --- a/thrust/testing/generate.cu +++ b/thrust/testing/generate.cu @@ -4,7 +4,8 @@ #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data template struct return_value @@ -219,4 +220,4 @@ void TestGenerateTuple() }; DECLARE_UNITTEST(TestGenerateTuple); -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/testing/random.cu b/thrust/testing/random.cu index d80f92387c..676c571858 100644 --- a/thrust/testing/random.cu +++ b/thrust/testing/random.cu @@ -670,7 +670,8 @@ void TestRanlux48Unequal() } DECLARE_UNITTEST(TestRanlux48Unequal); -THRUST_DISABLE_MSVC_WARNING_BEGIN(4305) // truncation warning +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4305) // truncation warning template void ValidateDistributionCharacteristic() { @@ -732,7 +733,7 @@ void ValidateDistributionCharacteristic() ASSERT_EQUAL(true, d[0]); } -THRUST_DISABLE_MSVC_WARNING_END(4305) +_CCCL_DIAG_POP template void TestDistributionSaveRestore() diff --git a/thrust/testing/unittest/testframework.cu b/thrust/testing/unittest/testframework.cu index a5252d093e..ff08a90646 100644 --- a/thrust/testing/unittest/testframework.cu +++ b/thrust/testing/unittest/testframework.cu @@ -280,10 +280,11 @@ bool UnitTestDriver::run_tests(std::vector& tests_to_run, const Argum { std::time_t start_time = std::time(0); - THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_MSVC(4800) // Forcing value to bool bool verbose = kwargs.count("verbose"); bool concise = kwargs.count("concise"); - THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END + _CCCL_DIAG_POP std::vector test_results; diff --git a/thrust/testing/vector.cu b/thrust/testing/vector.cu index d6b2845b06..57bcf45775 100644 --- a/thrust/testing/vector.cu +++ b/thrust/testing/vector.cu @@ -272,7 +272,10 @@ void TestVectorToAndFromHostVector() ASSERT_EQUAL(v, h); - THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(v = v); + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_CLANG("-Wself-assign") + v = v; + _CCCL_DIAG_POP ASSERT_EQUAL(v, h); @@ -330,7 +333,10 @@ void TestVectorToAndFromDeviceVector() ASSERT_EQUAL(v, h); - THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(v = v); + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_CLANG("-Wself-assign") + v = v; + _CCCL_DIAG_POP ASSERT_EQUAL(v, h); diff --git a/thrust/thrust/detail/config/compiler.h b/thrust/thrust/detail/config/compiler.h index 2b06e1c00b..7644b2d2e8 100644 --- a/thrust/thrust/detail/config/compiler.h +++ b/thrust/thrust/detail/config/compiler.h @@ -117,103 +117,3 @@ #else # define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE #endif // _OPENMP - -#if defined(_CCCL_COMPILER_MSVC) && !defined(__CUDA_ARCH__) -# define THRUST_DISABLE_MSVC_WARNING_BEGIN(x) __pragma(warning(push)) __pragma(warning(disable : x)) /**/ -# define THRUST_DISABLE_MSVC_WARNING_END(x) __pragma(warning(pop)) /**/ -#else -# define THRUST_DISABLE_MSVC_WARNING_BEGIN(x) -# define THRUST_DISABLE_MSVC_WARNING_END(x) -#endif - -#if defined(_CCCL_COMPILER_CLANG) && !defined(__CUDA_ARCH__) -# define THRUST_IGNORE_CLANG_WARNING_IMPL(x) \ - THRUST_PP_STRINGIZE(clang diagnostic ignored x) \ - /**/ -# define THRUST_IGNORE_CLANG_WARNING(x) \ - THRUST_IGNORE_CLANG_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \ - /**/ - -# define THRUST_DISABLE_CLANG_WARNING_BEGIN(x) \ - _Pragma("clang diagnostic push") _Pragma(THRUST_IGNORE_CLANG_WARNING(x)) /**/ -# define THRUST_DISABLE_CLANG_WARNING_END(x) _Pragma("clang diagnostic pop") /**/ -#else -# define THRUST_DISABLE_CLANG_WARNING_BEGIN(x) -# define THRUST_DISABLE_CLANG_WARNING_END(x) -#endif - -#if defined(_CCCL_COMPILER_GCC) && !defined(__CUDA_ARCH__) -# define THRUST_IGNORE_GCC_WARNING_IMPL(x) \ - THRUST_PP_STRINGIZE(GCC diagnostic ignored x) \ - /**/ -# define THRUST_IGNORE_GCC_WARNING(x) \ - THRUST_IGNORE_GCC_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \ - /**/ - -# define THRUST_DISABLE_GCC_WARNING_BEGIN(x) _Pragma("GCC diagnostic push") _Pragma(THRUST_IGNORE_GCC_WARNING(x)) /**/ -# define THRUST_DISABLE_GCC_WARNING_END(x) _Pragma("GCC diagnostic pop") /**/ -#else -# define THRUST_DISABLE_GCC_WARNING_BEGIN(x) -# define THRUST_DISABLE_GCC_WARNING_END(x) -#endif - -#if defined(_CCCL_COMPILER_ICC) && !defined(__CUDA_ARCH__) -# define THRUST_DISABLE_ICC_WARNING_BEGIN(x) _CCCL_DIAG_PUSH _CCCL_DIAG_SUPPRESS_ICC(x) -# define THRUST_DISABLE_ICC_WARNING_END(x) _CCCL_DIAG_POP -#else -# define THRUST_DISABLE_ICC_WARNING_BEGIN(x) -# define THRUST_DISABLE_ICC_WARNING_END(x) -#endif - -#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \ - THRUST_DISABLE_MSVC_WARNING_BEGIN(4244 4267) \ - /**/ -#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \ - THRUST_DISABLE_MSVC_WARNING_END(4244 4267) \ - /**/ -#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING(x) \ - THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \ - x; \ - THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \ - /**/ - -#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \ - THRUST_DISABLE_MSVC_WARNING_BEGIN(4800) \ - /**/ -#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \ - THRUST_DISABLE_MSVC_WARNING_END(4800) \ - /**/ -#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING(x) \ - THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \ - x; \ - THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \ - /**/ - -// auto-formatting splits -Wself-assign into -Wself - assign -// clang-format off -#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \ - THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wself-assign) -#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \ - THRUST_DISABLE_CLANG_WARNING_END(-Wself-assign) -// clang-format on -#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(x) \ - THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \ - x; \ - THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \ - /**/ - -#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \ - THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wreorder) \ - THRUST_DISABLE_GCC_WARNING_BEGIN(-Wreorder) \ - THRUST_DISABLE_ICC_WARNING_BEGIN(2407) \ - /**/ -#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \ - THRUST_DISABLE_CLANG_WARNING_END(-Wreorder) \ - THRUST_DISABLE_GCC_WARNING_END(-Wreorder) \ - THRUST_DISABLE_ICC_WARNING_END(2407) \ - /**/ -#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING(x) \ - THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \ - x; \ - THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \ - /**/ diff --git a/thrust/thrust/iterator/detail/join_iterator.h b/thrust/thrust/iterator/detail/join_iterator.h index 7787b08328..75fee3056f 100644 --- a/thrust/thrust/iterator/detail/join_iterator.h +++ b/thrust/thrust/iterator/detail/join_iterator.h @@ -95,7 +95,8 @@ class join_iterator // MSVC 2013 and 2015 incorrectly warning about returning a reference to // a local/temporary here. // See goo.gl/LELTNp - THRUST_DISABLE_MSVC_WARNING_BEGIN(4172) + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_MSVC(4172) _CCCL_HOST_DEVICE typename super_t::reference dereference() const { @@ -103,7 +104,7 @@ class join_iterator return (i < m_n1) ? m_iter1[i] : static_cast(m_iter2[i]); } // end dereference() - THRUST_DISABLE_MSVC_WARNING_END(4172) + _CCCL_DIAG_POP size_type m_n1; RandomAccessIterator1 m_iter1; diff --git a/thrust/thrust/iterator/discard_iterator.h b/thrust/thrust/iterator/discard_iterator.h index 00a6aead0a..5b64aabd5a 100644 --- a/thrust/thrust/iterator/discard_iterator.h +++ b/thrust/thrust/iterator/discard_iterator.h @@ -32,7 +32,8 @@ #include #include -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN +_CCCL_DIAG_PUSH +_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data THRUST_NAMESPACE_BEGIN @@ -162,4 +163,4 @@ make_discard_iterator(discard_iterator<>::difference_type i = discard_iterator<> THRUST_NAMESPACE_END -THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END +_CCCL_DIAG_POP diff --git a/thrust/thrust/iterator/permutation_iterator.h b/thrust/thrust/iterator/permutation_iterator.h index 16b6fa33f4..eba537d1ee 100644 --- a/thrust/thrust/iterator/permutation_iterator.h +++ b/thrust/thrust/iterator/permutation_iterator.h @@ -171,7 +171,8 @@ class permutation_iterator : public thrust::detail::permutation_iterator_basebase()); } - THRUST_DISABLE_MSVC_WARNING_END(4172) + _CCCL_DIAG_POP // make friends for the copy constructor template diff --git a/thrust/thrust/iterator/transform_iterator.h b/thrust/thrust/iterator/transform_iterator.h index 081bf675bb..fd7cee8381 100644 --- a/thrust/thrust/iterator/transform_iterator.h +++ b/thrust/thrust/iterator/transform_iterator.h @@ -297,7 +297,8 @@ class transform_iterator // MSVC 2013 and 2015 incorrectly warning about returning a reference to // a local/temporary here. // See goo.gl/LELTNp - THRUST_DISABLE_MSVC_WARNING_BEGIN(4172) + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_MSVC(4172) _CCCL_EXEC_CHECK_DISABLE _CCCL_HOST_DEVICE typename super_t::reference dereference() const @@ -309,7 +310,7 @@ class transform_iterator return m_f(x); } - THRUST_DISABLE_MSVC_WARNING_END(4172) + _CCCL_DIAG_POP // tag this as mutable per Dave Abrahams in this thread: // http://lists.boost.org/Archives/boost/2004/05/65332.php diff --git a/thrust/thrust/system/cuda/detail/future.inl b/thrust/thrust/system/cuda/detail/future.inl index fb97838ca8..343a18156e 100644 --- a/thrust/thrust/system/cuda/detail/future.inl +++ b/thrust/thrust/system/cuda/detail/future.inl @@ -458,7 +458,10 @@ public: // address after its been moved into the new signal we're constructing. // NOTE: NVCC has a bug that causes it to reorder our base class initializers // in generated host code, which leads to -Wreorder warnings. - THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_CLANG("-Wreorder") + _CCCL_DIAG_SUPPRESS_GCC("-Wreorder") + _CCCL_DIAG_SUPPRESS_ICC(2407) template _CCCL_HOST explicit async_addressable_value_with_keep_alives( unique_stream&& stream, keep_alives_type&& keep_alives, ComputeContent&& compute_content) @@ -468,7 +471,7 @@ public: { content_ = THRUST_FWD(compute_content)(std::get<0>(this->keep_alives_)); } - THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END + _CCCL_DIAG_POP _CCCL_HOST bool valid_content() const noexcept final override { diff --git a/thrust/thrust/system/detail/error_category.inl b/thrust/thrust/system/detail/error_category.inl index 64768807d9..cd90321ea7 100644 --- a/thrust/thrust/system/detail/error_category.inl +++ b/thrust/thrust/system/detail/error_category.inl @@ -92,9 +92,10 @@ public: // XXX strerror is not thread-safe: // prefer strerror_r (which is not provided on windows) - THRUST_DISABLE_MSVC_WARNING_BEGIN(4996) + _CCCL_DIAG_PUSH + _CCCL_DIAG_SUPPRESS_MSVC(4996) const char* c_str = std::strerror(ev); - THRUST_DISABLE_MSVC_WARNING_END(4996) + _CCCL_DIAG_POP return c_str ? std::string(c_str) : unknown_err; } }; // end generic_category_result From bd04ca6dd3901951d8bd711ea29fccfaa04165a5 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Tue, 10 Sep 2024 09:41:37 +0200 Subject: [PATCH 2/2] Avoid warning of possible loss of data when casting to index type --- thrust/thrust/system/detail/generic/copy_if.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thrust/thrust/system/detail/generic/copy_if.inl b/thrust/thrust/system/detail/generic/copy_if.inl index dd21ffc611..41d21fd1e4 100644 --- a/thrust/thrust/system/detail/generic/copy_if.inl +++ b/thrust/thrust/system/detail/generic/copy_if.inl @@ -65,7 +65,7 @@ _CCCL_HOST_DEVICE OutputIterator copy_if( OutputIterator result, Predicate pred) { - THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING(IndexType n = thrust::distance(first, last)); + const auto n = static_cast(thrust::distance(first, last)); // compute {0,1} predicates thrust::detail::temporary_array predicates(exec, n);