diff --git a/thrust/testing/catch2_test_transform.cu b/thrust/testing/catch2_test_transform.cu index ec45eddbdc4..053e3e232bc 100644 --- a/thrust/testing/catch2_test_transform.cu +++ b/thrust/testing/catch2_test_transform.cu @@ -11,10 +11,18 @@ #include "unittest/random.h" #include "unittest/special_types.h" -TEMPLATE_LIST_TEST_CASE("UnarySimple", "[transform]", vector_list) +// There is an unfortunate miscompilation of the gcc-11 vectorizer leading to OOB writes +// Adding this attribute suffices that this miscompilation does not appear anymore +#if _CCCL_COMPILER(GCC, >=, 11) +# define THRUST_DISABLE_BROKEN_GCC_VECTORIZER __attribute__((optimize("no-tree-vectorize"))) +#else +# define THRUST_DISABLE_BROKEN_GCC_VECTORIZER +#endif + +template +THRUST_DISABLE_BROKEN_GCC_VECTORIZER void test_unary_simple() { - using Vector = TestType; - using T = typename Vector::value_type; + using T = typename Vector::value_type; typename Vector::iterator iter; @@ -28,6 +36,11 @@ TEMPLATE_LIST_TEST_CASE("UnarySimple", "[transform]", vector_list) CHECK(output == result); } +TEMPLATE_LIST_TEST_CASE("UnarySimple", "[transform]", vector_list) +{ + test_unary_simple(); +} + template OutputIterator transform(my_system& system, InputIterator, InputIterator, OutputIterator result, UnaryFunction) { @@ -181,16 +194,13 @@ TEST_CASE("UnaryDispatchImplicit", "[transform_if]") CHECK(13 == vec.front()); } -TEMPLATE_LIST_TEST_CASE("BinarySimple", "[transform]", vector_list) +template +THRUST_DISABLE_BROKEN_GCC_VECTORIZER void test_binary_simple() { - using Vector = TestType; - using T = typename Vector::value_type; + using T = typename Vector::value_type; typename Vector::iterator iter; - // There is a strange gcc bug here where it believes we would write out of bounds. - // It seems to go away if we add one more element that we leave untouched. Luckily 0 - 0 = 0 so all is fine. - // Note that we still write the element, so it does not hide a functional thrust bug Vector input1{1, -2, 3}; Vector input2{-4, 5, 6}; Vector output(3); @@ -202,6 +212,11 @@ TEMPLATE_LIST_TEST_CASE("BinarySimple", "[transform]", vector_list) CHECK(output == result); } +TEMPLATE_LIST_TEST_CASE("BinarySimple", "[transform]", vector_list) +{ + test_binary_simple(); +} + template OutputIterator transform(my_system& system, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, UnaryFunction)