Skip to content

Commit

Permalink
Feat 565 remove redundant thrust dialect conditional (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZelboK authored Mar 20, 2024
1 parent 4ba5eb4 commit 117ebda
Show file tree
Hide file tree
Showing 75 changed files with 106 additions and 738 deletions.
8 changes: 5 additions & 3 deletions thrust/examples/arbitrary_transformation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <thrust/detail/config.h>

#if _CCCL_STD_VER >= 2011 && !defined(THRUST_LEGACY_GCC)
#if !defined(THRUST_LEGACY_GCC)
#include <thrust/zip_function.h>
#endif // >= C++11

Expand Down Expand Up @@ -52,7 +52,8 @@ struct arbitrary_functor1
}
};

#if _CCCL_STD_VER >= 2011 && !defined(THRUST_LEGACY_GCC)

#if !defined(THRUST_LEGACY_GCC)
struct arbitrary_functor2
{
__host__ __device__
Expand Down Expand Up @@ -89,8 +90,9 @@ int main(void)
for(int i = 0; i < 5; i++)
std::cout << A[i] << " + " << B[i] << " * " << C[i] << " = " << D1[i] << std::endl;


// apply the transformation using zip_function
#if _CCCL_STD_VER >= 2011 && !defined(THRUST_LEGACY_GCC)
#if !defined(THRUST_LEGACY_GCC)
thrust::device_vector<float> D2(5);
thrust::for_each(thrust::make_zip_iterator(thrust::make_tuple(A.begin(), B.begin(), C.begin(), D2.begin())),
thrust::make_zip_iterator(thrust::make_tuple(A.end(), B.end(), C.end(), D2.end())),
Expand Down
5 changes: 0 additions & 5 deletions thrust/examples/cuda/async_reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <thrust/system/cuda/execution_policy.h>
#include <cassert>

#if _CCCL_STD_VER >= 2011
#include <future>
#endif

// This example demonstrates two ways to achieve algorithm invocations that are asynchronous with
// the calling thread.
Expand Down Expand Up @@ -59,9 +57,7 @@ int main()
// reset the result
result[0] = 0;

#if _CCCL_STD_VER >= 2011
// method 2: use std::async to create asynchrony

// copy all the algorithm parameters
auto begin = data.begin();
auto end = data.end();
Expand All @@ -77,7 +73,6 @@ int main()

// wait on the result and check that it is correct
assert(future_result.get() == n);
#endif

return 0;
}
Expand Down
10 changes: 0 additions & 10 deletions thrust/examples/cuda/global_device_vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ typedef thrust::system::cuda::detail::cuda_memory_resource<
thrust::cuda::pointer<void>
> device_ignore_shutdown_memory_resource;

#if _CCCL_STD_VER >= 2011
template <typename T>
using device_ignore_shutdown_allocator =
thrust::mr::stateless_resource_allocator<
Expand All @@ -30,15 +29,6 @@ typedef thrust::system::cuda::detail::cuda_memory_resource<
>;

thrust::device_vector<double, device_ignore_shutdown_allocator<double>> d;
#else
thrust::device_vector<
double,
thrust::mr::stateless_resource_allocator<
double,
thrust::device_ptr_memory_resource<device_ignore_shutdown_memory_resource>
>
> d;
#endif

int main() {
d.resize(25);
Expand Down
4 changes: 1 addition & 3 deletions thrust/examples/uninitialized_vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ template<typename T>
__host__
~uninitialized_allocator() {}

#if _CCCL_STD_VER >= 2011
uninitialized_allocator & operator=(const uninitialized_allocator &) = default;
#endif
uninitialized_allocator & operator=(const uninitialized_allocator &) = default;

// for correctness, you should also redefine rebind when you inherit
// from an allocator type; this way, if the allocator is rebound somewhere,
Expand Down
29 changes: 6 additions & 23 deletions thrust/internal/benchmark/bench.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
#include <thrust/reduce.h>
#include <thrust/scan.h>
#include <thrust/detail/config.h>

#if _CCCL_STD_VER >= 2011
#include <thrust/random.h>
#include <thrust/shuffle.h>

#include <random>
#endif

#include <algorithm>
#include <numeric>

Expand Down Expand Up @@ -47,15 +43,6 @@
#define PP_STRINGIZE(expr) PP_STRINGIZE_(expr)

#define PP_CAT(a, b) a ## b

// We don't use THRUST_NOEXCEPT because it's new, and we want this benchmark to
// be backwards-compatible to older versions of Thrust.
#if _CCCL_STD_VER >= 2011
#define NOEXCEPT noexcept
#else
#define NOEXCEPT throw()
#endif

///////////////////////////////////////////////////////////////////////////////

template <typename T>
Expand Down Expand Up @@ -699,7 +686,6 @@ struct copy_trial_base : trial_base<TrialKind>
}
};

#if _CCCL_STD_VER >= 2011
template <typename Container, typename TrialKind = regular_trial>
struct shuffle_trial_base : trial_base<TrialKind>
{
Expand All @@ -712,7 +698,6 @@ struct shuffle_trial_base : trial_base<TrialKind>
randomize(input);
}
};
#endif

///////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -909,7 +894,6 @@ struct copy_tester
#endif
};

#if _CCCL_STD_VER >= 2011
template <typename T>
struct shuffle_tester
{
Expand Down Expand Up @@ -938,7 +922,6 @@ struct shuffle_tester
}
};
};
#endif

///////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1079,8 +1062,8 @@ std::vector<std::string> split(std::string const& str, std::string const& delim)

struct command_line_option_error : std::exception
{
virtual ~command_line_option_error() NOEXCEPT {}
virtual const char* what() const NOEXCEPT = 0;
virtual ~command_line_option_error() noexcept {}
virtual const char* what() const noexcept = 0;
};

struct only_one_option_allowed : command_line_option_error
Expand Down Expand Up @@ -1109,9 +1092,9 @@ struct only_one_option_allowed : command_line_option_error
message += ".";
}

virtual ~only_one_option_allowed() NOEXCEPT {}
virtual ~only_one_option_allowed() noexcept {}

virtual const char* what() const NOEXCEPT
virtual const char* what() const noexcept
{
return message.c_str();
}
Expand All @@ -1132,9 +1115,9 @@ struct required_option_missing : command_line_option_error
message += "` option is required.";
}

virtual ~required_option_missing() NOEXCEPT {}
virtual ~required_option_missing() noexcept {}

virtual const char* what() const NOEXCEPT
virtual const char* what() const noexcept
{
return message.c_str();
}
Expand Down
106 changes: 53 additions & 53 deletions thrust/testing/alignment.cu
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,29 @@ DECLARE_UNITTEST(test_alignof_mocks_sizes);

void test_alignof()
{
ASSERT_EQUAL(THRUST_ALIGNOF(bool) , sizeof(bool));
ASSERT_EQUAL(THRUST_ALIGNOF(signed char) , sizeof(signed char));
ASSERT_EQUAL(THRUST_ALIGNOF(unsigned char) , sizeof(unsigned char));
ASSERT_EQUAL(THRUST_ALIGNOF(char) , sizeof(char));
ASSERT_EQUAL(THRUST_ALIGNOF(short int) , sizeof(short int));
ASSERT_EQUAL(THRUST_ALIGNOF(unsigned short int) , sizeof(unsigned short int));
ASSERT_EQUAL(THRUST_ALIGNOF(int) , sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(unsigned int) , sizeof(unsigned int));
ASSERT_EQUAL(THRUST_ALIGNOF(long int) , sizeof(long int));
ASSERT_EQUAL(THRUST_ALIGNOF(unsigned long int) , sizeof(unsigned long int));
ASSERT_EQUAL(THRUST_ALIGNOF(long long int) , sizeof(long long int));
ASSERT_EQUAL(THRUST_ALIGNOF(unsigned long long int), sizeof(unsigned long long int));
ASSERT_EQUAL(THRUST_ALIGNOF(float) , sizeof(float));
ASSERT_EQUAL(THRUST_ALIGNOF(double) , sizeof(double));
ASSERT_EQUAL(THRUST_ALIGNOF(long double) , sizeof(long double));
ASSERT_EQUAL(alignof(bool) , sizeof(bool));
ASSERT_EQUAL(alignof(signed char) , sizeof(signed char));
ASSERT_EQUAL(alignof(unsigned char) , sizeof(unsigned char));
ASSERT_EQUAL(alignof(char) , sizeof(char));
ASSERT_EQUAL(alignof(short int) , sizeof(short int));
ASSERT_EQUAL(alignof(unsigned short int) , sizeof(unsigned short int));
ASSERT_EQUAL(alignof(int) , sizeof(int));
ASSERT_EQUAL(alignof(unsigned int) , sizeof(unsigned int));
ASSERT_EQUAL(alignof(long int) , sizeof(long int));
ASSERT_EQUAL(alignof(unsigned long int) , sizeof(unsigned long int));
ASSERT_EQUAL(alignof(long long int) , sizeof(long long int));
ASSERT_EQUAL(alignof(unsigned long long int), sizeof(unsigned long long int));
ASSERT_EQUAL(alignof(float) , sizeof(float));
ASSERT_EQUAL(alignof(double) , sizeof(double));
ASSERT_EQUAL(alignof(long double) , sizeof(long double));

ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_0), sizeof(char));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_1), sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_2), sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_3), sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_4), sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_5), sizeof(int));
ASSERT_EQUAL(THRUST_ALIGNOF(alignof_mock_6), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_0), sizeof(char));
ASSERT_EQUAL(alignof(alignof_mock_1), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_2), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_3), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_4), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_5), sizeof(int));
ASSERT_EQUAL(alignof(alignof_mock_6), sizeof(int));
}
DECLARE_UNITTEST(test_alignof);

Expand Down Expand Up @@ -192,7 +192,7 @@ void test_aligned_type_instantiation()
{
typedef typename thrust::detail::aligned_type<Align>::type type;
ASSERT_GEQUAL(sizeof(type), 1lu);
ASSERT_EQUAL(THRUST_ALIGNOF(type), Align);
ASSERT_EQUAL(alignof(type), Align);
ASSERT_EQUAL(thrust::detail::alignment_of<type>::value, Align);
}

Expand All @@ -212,64 +212,64 @@ DECLARE_UNITTEST(test_aligned_type);
void test_max_align_t()
{
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(bool)
alignof(thrust::detail::max_align_t)
, alignof(bool)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(signed char)
alignof(thrust::detail::max_align_t)
, alignof(signed char)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(unsigned char)
alignof(thrust::detail::max_align_t)
, alignof(unsigned char)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(char)
alignof(thrust::detail::max_align_t)
, alignof(char)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(short int)
alignof(thrust::detail::max_align_t)
, alignof(short int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(unsigned short int)
alignof(thrust::detail::max_align_t)
, alignof(unsigned short int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(int)
alignof(thrust::detail::max_align_t)
, alignof(int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(unsigned int)
alignof(thrust::detail::max_align_t)
, alignof(unsigned int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(long int)
alignof(thrust::detail::max_align_t)
, alignof(long int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(unsigned long int)
alignof(thrust::detail::max_align_t)
, alignof(unsigned long int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(long long int)
alignof(thrust::detail::max_align_t)
, alignof(long long int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(unsigned long long int)
alignof(thrust::detail::max_align_t)
, alignof(unsigned long long int)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(float)
alignof(thrust::detail::max_align_t)
, alignof(float)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(double)
alignof(thrust::detail::max_align_t)
, alignof(double)
);
ASSERT_GEQUAL(
THRUST_ALIGNOF(thrust::detail::max_align_t)
, THRUST_ALIGNOF(long double)
alignof(thrust::detail::max_align_t)
, alignof(long double)
);
}
DECLARE_UNITTEST(test_max_align_t);
Expand Down
2 changes: 0 additions & 2 deletions thrust/testing/allocator_aware_policies.cu
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ struct TestAllocatorAttachment
test_temporary_allocation_valid(policy(const_alloc));
test_temporary_allocation_valid(policy(&test_memory_resource));

#if _CCCL_STD_VER >= 2011
test_temporary_allocation_valid(policy(std::allocator<int>()).after(1));
test_temporary_allocation_valid(policy(alloc).after(1));
test_temporary_allocation_valid(policy(const_alloc).after(1));
#endif
}
};

Expand Down
Loading

0 comments on commit 117ebda

Please sign in to comment.