Skip to content

Commit

Permalink
Drop Thrust's deprecated compiler macros (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber authored Jan 9, 2025
1 parent 76f0ac6 commit e7e74a1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 147 deletions.
1 change: 0 additions & 1 deletion thrust/cmake/ThrustHeaderTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ function(thrust_add_header_test thrust_target label definitions)
${header_definitions}
"THRUST_CPP11_REQUIRED_NO_ERROR"
"THRUST_CPP14_REQUIRED_NO_ERROR"
"THRUST_MODERN_GCC_REQUIRED_NO_ERROR"
)
thrust_clone_target_properties(${headertest_target} ${thrust_target})

Expand Down
9 changes: 1 addition & 8 deletions thrust/examples/arbitrary_transformation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
#include <thrust/device_vector.h>
#include <thrust/for_each.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/zip_function.h>

#include <iostream>

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

#include "include/host_device.h"

// This example shows how to implement an arbitrary transformation of
Expand Down Expand Up @@ -54,7 +51,6 @@ struct arbitrary_functor1
}
};

#if !defined(THRUST_LEGACY_GCC)
struct arbitrary_functor2
{
__host__ __device__ void operator()(const float& a, const float& b, const float& c, float& d)
Expand All @@ -63,7 +59,6 @@ struct arbitrary_functor2
d = a + b * c;
}
};
#endif // >= C++11

int main()
{
Expand Down Expand Up @@ -95,7 +90,6 @@ int main()
}

// apply the transformation using zip_function
#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 All @@ -107,5 +101,4 @@ int main()
{
std::cout << A[i] << " + " << B[i] << " * " << C[i] << " = " << D2[i] << std::endl;
}
#endif // >= C++11
}
23 changes: 10 additions & 13 deletions thrust/testing/zip_function.cu
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#include <thrust/detail/config.h>

#if !defined(THRUST_LEGACY_GCC)
#include <thrust/device_vector.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/remove.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
#include <thrust/zip_function.h>

# include <thrust/device_vector.h>
# include <thrust/iterator/zip_iterator.h>
# include <thrust/remove.h>
# include <thrust/sort.h>
# include <thrust/transform.h>
# include <thrust/zip_function.h>
#include <iostream>

# include <iostream>

# include <unittest/unittest.h>
#include <unittest/unittest.h>

using namespace unittest;

Expand All @@ -35,9 +33,9 @@ struct TestZipFunctionCtor
{
ASSERT_EQUAL(thrust::zip_function<SumThree>()(thrust::make_tuple(1, 2, 3)), SumThree{}(1, 2, 3));
ASSERT_EQUAL(thrust::zip_function<SumThree>(SumThree{})(thrust::make_tuple(1, 2, 3)), SumThree{}(1, 2, 3));
# ifdef __cpp_deduction_guides
#ifdef __cpp_deduction_guides
ASSERT_EQUAL(thrust::zip_function(SumThree{})(thrust::make_tuple(1, 2, 3)), SumThree{}(1, 2, 3));
# endif // __cpp_deduction_guides
#endif // __cpp_deduction_guides
}
};
SimpleUnitTest<TestZipFunctionCtor, type_list<int>> TestZipFunctionCtorInstance;
Expand Down Expand Up @@ -176,4 +174,3 @@ struct TestNestedZipFunction2
}
};
SimpleUnitTest<TestNestedZipFunction2, type_list<int, float>> TestNestedZipFunctionInstance2;
#endif // _CCCL_STD_VER
78 changes: 0 additions & 78 deletions thrust/thrust/detail/config/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,84 +30,6 @@
# pragma system_header
#endif // no system header

// enumerate host compilers we know about
//! deprecated [Since 2.7]
#define THRUST_HOST_COMPILER_UNKNOWN 0
//! deprecated [Since 2.7]
#define THRUST_HOST_COMPILER_MSVC 1
//! deprecated [Since 2.7]
#define THRUST_HOST_COMPILER_GCC 2
//! deprecated [Since 2.7]
#define THRUST_HOST_COMPILER_CLANG 3
//! deprecated [Since 2.7]
#define THRUST_HOST_COMPILER_INTEL 4

// enumerate device compilers we know about
//! deprecated [Since 2.7]
#define THRUST_DEVICE_COMPILER_UNKNOWN 0
//! deprecated [Since 2.7]
#define THRUST_DEVICE_COMPILER_MSVC 1
//! deprecated [Since 2.7]
#define THRUST_DEVICE_COMPILER_GCC 2
//! deprecated [Since 2.7]
#define THRUST_DEVICE_COMPILER_CLANG 3
//! deprecated [Since 2.7]
#define THRUST_DEVICE_COMPILER_NVCC 4

// figure out which host compiler we're using
#if _CCCL_COMPILER(MSVC)
//! deprecated [Since 2.7]
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC
//! deprecated [Since 2.7]
# define THRUST_MSVC_VERSION _MSC_VER
//! deprecated [Since 2.7]
# define THRUST_MSVC_VERSION_FULL _MSC_FULL_VER
#elif _CCCL_COMPILER(CLANG)
//! deprecated [Since 2.7]
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_CLANG
//! deprecated [Since 2.7]
# define THRUST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#elif _CCCL_COMPILER(GCC)
//! deprecated [Since 2.7]
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_GCC
//! deprecated [Since 2.7]
# define THRUST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
# if _CCCL_COMPILER(GCC, >=, 5)
//! deprecated [Since 2.7]
# define THRUST_MODERN_GCC
# else
//! deprecated [Since 2.7]
# define THRUST_LEGACY_GCC
# endif
#else
//! deprecated [Since 2.7]
# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_UNKNOWN
#endif // TRUST_HOST_COMPILER

// figure out which device compiler we're using
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
#elif _CCCL_COMPILER(MSVC)
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_MSVC
#elif _CCCL_COMPILER(GCC)
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_GCC
#elif _CCCL_COMPILER(CLANG)
// CUDA-capable clang should behave similar to NVCC.
# if defined(__CUDA__)
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC
# else
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_CLANG
# endif
#else
//! deprecated [Since 2.7]
# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_UNKNOWN
#endif

// is the device compiler capable of compiling omp?
#if defined(_OPENMP) || defined(_NVHPC_STDPAR_OPENMP)
# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_TRUE
Expand Down
33 changes: 0 additions & 33 deletions thrust/thrust/detail/modern_gcc_required.h

This file was deleted.

24 changes: 10 additions & 14 deletions thrust/thrust/zip_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <thrust/detail/modern_gcc_required.h>
#if !defined(THRUST_LEGACY_GCC)

# include <thrust/detail/type_deduction.h>
# include <thrust/tuple.h>
# include <thrust/type_traits/integer_sequence.h>
#include <thrust/detail/type_deduction.h>
#include <thrust/tuple.h>
#include <thrust/type_traits/integer_sequence.h>

# include <cuda/functional>
#include <cuda/functional>

THRUST_NAMESPACE_BEGIN

Expand All @@ -42,7 +40,7 @@ namespace zip_detail
{

// Add workaround for decltype(auto) on C++11-only compilers:
# if _CCCL_STD_VER >= 2014
#if _CCCL_STD_VER >= 2014

_CCCL_EXEC_CHECK_DISABLE
template <typename Function, typename Tuple, std::size_t... Is>
Expand All @@ -58,7 +56,7 @@ _CCCL_HOST_DEVICE decltype(auto) apply(Function&& func, Tuple&& args)
return apply_impl(THRUST_FWD(func), THRUST_FWD(args), make_index_sequence<tuple_size>{});
}

# else // _CCCL_STD_VER
#else // _CCCL_STD_VER

_CCCL_EXEC_CHECK_DISABLE
template <typename Function, typename Tuple, std::size_t... Is>
Expand All @@ -71,7 +69,7 @@ _CCCL_HOST_DEVICE auto apply_impl(Function&& func, Tuple&& args, index_sequence<
THRUST_FWD(args),
make_index_sequence<thrust::tuple_size<typename std::decay<Tuple>::type>::value>{}))

# endif // _CCCL_STD_VER
#endif // _CCCL_STD_VER

} // namespace zip_detail
} // namespace detail
Expand Down Expand Up @@ -149,15 +147,15 @@ class zip_function
{}

// Add workaround for decltype(auto) on C++11-only compilers:
# if _CCCL_STD_VER >= 2014
#if _CCCL_STD_VER >= 2014

template <typename Tuple>
_CCCL_HOST_DEVICE decltype(auto) operator()(Tuple&& args) const
{
return detail::zip_detail::apply(func, THRUST_FWD(args));
}

# else // _CCCL_STD_VER
#else // _CCCL_STD_VER

// Can't just use THRUST_DECLTYPE_RETURNS here since we need to use
// std::declval for the signature components:
Expand All @@ -169,7 +167,7 @@ class zip_function
return detail::zip_detail::apply(func, THRUST_FWD(args));
}

# endif // _CCCL_STD_VER
#endif // _CCCL_STD_VER

//! Returns a reference to the underlying function.
_CCCL_HOST_DEVICE Function& underlying_function() const
Expand Down Expand Up @@ -208,5 +206,3 @@ template <typename F>
struct proclaims_copyable_arguments<THRUST_NS_QUALIFIER::zip_function<F>> : proclaims_copyable_arguments<F>
{};
_LIBCUDACXX_END_NAMESPACE_CUDA

#endif

0 comments on commit e7e74a1

Please sign in to comment.