Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions thrust/testing/catch2_test_transform.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class Vector>
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;

Expand All @@ -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<TestType>();
}

template <typename InputIterator, typename OutputIterator, typename UnaryFunction>
OutputIterator transform(my_system& system, InputIterator, InputIterator, OutputIterator result, UnaryFunction)
{
Expand Down Expand Up @@ -181,16 +194,13 @@ TEST_CASE("UnaryDispatchImplicit", "[transform_if]")
CHECK(13 == vec.front());
}

TEMPLATE_LIST_TEST_CASE("BinarySimple", "[transform]", vector_list)
template <class Vector>
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);
Expand All @@ -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<TestType>();
}

template <typename InputIterator1, typename InputIterator2, typename OutputIterator, typename UnaryFunction>
OutputIterator
transform(my_system& system, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, UnaryFunction)
Expand Down
Loading