Skip to content

Commit 54dad0f

Browse files
BeanavilNB4444
authored andcommitted
Various and sundry fixes for Thrust's CPP backends.
1 parent 878a2a0 commit 54dad0f

40 files changed

+435
-493
lines changed

examples/padded_grid_reduction.cu

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
#include <thrust/transform_reduce.h>
2-
#include <thrust/functional.h>
31
#include <thrust/device_vector.h>
2+
#include <thrust/extrema.h>
3+
#include <thrust/functional.h>
44
#include <thrust/host_vector.h>
55
#include <thrust/iterator/constant_iterator.h>
66
#include <thrust/iterator/zip_iterator.h>
77
#include <thrust/random.h>
8-
#include <thrust/extrema.h>
8+
#include <thrust/transform_reduce.h>
9+
910
#include <cmath>
1011
#include <iomanip>
11-
#include <float.h>
1212

1313
#include "include/host_device.h"
14+
#include <float.h>
1415

1516
// This example computes the minimum and maximum values
1617
// over a padded grid. The padded values are not considered

examples/remove_points2d.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <thrust/host_vector.h>
2-
#include <thrust/remove.h>
32
#include <thrust/random.h>
3+
#include <thrust/remove.h>
44

55
#include "include/host_device.h"
66

examples/repeated_range.cu

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#include <thrust/copy.h>
2+
#include <thrust/device_vector.h>
3+
#include <thrust/fill.h>
4+
#include <thrust/functional.h>
15
#include <thrust/iterator/counting_iterator.h>
2-
#include <thrust/iterator/transform_iterator.h>
36
#include <thrust/iterator/permutation_iterator.h>
4-
#include <thrust/functional.h>
5-
#include <thrust/fill.h>
6-
#include <thrust/device_vector.h>
7-
#include <thrust/copy.h>
7+
#include <thrust/iterator/transform_iterator.h>
8+
89
#include <iostream>
910

1011
#include "include/host_device.h"

examples/saxpy.cu

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#include <thrust/transform.h>
21
#include <thrust/device_vector.h>
3-
#include <thrust/host_vector.h>
42
#include <thrust/functional.h>
3+
#include <thrust/host_vector.h>
4+
#include <thrust/transform.h>
5+
6+
#include <algorithm>
57
#include <iostream>
68
#include <iterator>
7-
#include <algorithm>
89

910
#include "include/host_device.h"
1011

examples/scan_by_key.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include <thrust/device_vector.h>
21
#include <thrust/copy.h>
2+
#include <thrust/device_vector.h>
33
#include <thrust/scan.h>
4+
45
#include <iostream>
56

67
#include "include/host_device.h"

examples/sorting_aos_vs_soa.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include <thrust/host_vector.h>
21
#include <thrust/device_vector.h>
3-
#include <thrust/sort.h>
2+
#include <thrust/host_vector.h>
43
#include <thrust/random.h>
5-
#include <assert.h>
4+
#include <thrust/sort.h>
65

76
#include "include/host_device.h"
87
#include "include/timer.h"
8+
#include <assert.h>
99

1010
// This examples compares sorting performance using Array of Structures (AoS)
1111
// and Structure of Arrays (SoA) data layout. Legacy applications will often

examples/stream_compaction.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include <thrust/device_vector.h>
2-
#include <thrust/sequence.h>
31
#include <thrust/copy.h>
42
#include <thrust/count.h>
3+
#include <thrust/device_vector.h>
54
#include <thrust/remove.h>
5+
#include <thrust/sequence.h>
6+
67
#include <iostream>
78
#include <iterator>
89
#include <string>

examples/strided_range.cu

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#include <thrust/copy.h>
2+
#include <thrust/device_vector.h>
3+
#include <thrust/fill.h>
4+
#include <thrust/functional.h>
15
#include <thrust/iterator/counting_iterator.h>
2-
#include <thrust/iterator/transform_iterator.h>
36
#include <thrust/iterator/permutation_iterator.h>
4-
#include <thrust/functional.h>
5-
#include <thrust/fill.h>
6-
#include <thrust/device_vector.h>
7-
#include <thrust/copy.h>
7+
#include <thrust/iterator/transform_iterator.h>
8+
89
#include <iostream>
910

1011
#include "include/host_device.h"

examples/summary_statistics.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include <thrust/device_vector.h>
2+
#include <thrust/extrema.h>
3+
#include <thrust/functional.h>
24
#include <thrust/host_vector.h>
35
#include <thrust/transform_reduce.h>
4-
#include <thrust/functional.h>
5-
#include <thrust/extrema.h>
6+
67
#include <cmath>
78
#include <limits>
89
#include <iostream>

examples/tiled_range.cu

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#include <thrust/copy.h>
2+
#include <thrust/device_vector.h>
3+
#include <thrust/fill.h>
4+
#include <thrust/functional.h>
15
#include <thrust/iterator/counting_iterator.h>
2-
#include <thrust/iterator/transform_iterator.h>
36
#include <thrust/iterator/permutation_iterator.h>
4-
#include <thrust/functional.h>
5-
#include <thrust/fill.h>
6-
#include <thrust/device_vector.h>
7-
#include <thrust/copy.h>
7+
#include <thrust/iterator/transform_iterator.h>
8+
89
#include <iostream>
910

1011
#include "include/host_device.h"

examples/transform_iterator.cu

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include <thrust/iterator/transform_iterator.h>
2-
#include <thrust/iterator/counting_iterator.h>
31
#include <thrust/device_vector.h>
4-
#include <thrust/reduce.h>
52
#include <thrust/functional.h>
3+
#include <thrust/iterator/counting_iterator.h>
4+
#include <thrust/iterator/transform_iterator.h>
5+
#include <thrust/reduce.h>
6+
67
#include <iostream>
78
#include <iterator>
89
#include <string>

examples/word_count.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <thrust/device_vector.h>
2-
#include <thrust/reduce.h>
32
#include <thrust/functional.h>
43
#include <thrust/inner_product.h>
4+
#include <thrust/reduce.h>
55

66
#include <iostream>
77

testing/docs/doxybook_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class test_class
116116
/*! \brief \c test_protected_member_function is a function intended to
117117
* exercise and test Doxybook rendering.
118118
*/
119-
_CCCL_DEVICE auto test_protected_member_function();
119+
THRUST_DEVICE auto test_protected_member_function();
120120
};
121121

122122
/*! \brief \c test_derived_class is a derived class intended to exercise and

testing/sort_permutation_iterator.cu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ class strided_range
2020
stride_functor(difference_type stride)
2121
: stride(stride) {}
2222

23-
THRUST_HOST_DEVICE
24-
difference_type operator()(const difference_type& i) const
25-
{
23+
THRUST_HOST_DEVICE difference_type operator()(const difference_type& i) const
24+
{
2625
return stride * i;
2726
}
2827
};

testing/zip_function.cu

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ VariableUnitTest<TestZipFunctionTransform, ThirtyTwoBitTypes> TestZipFunctionTra
7070

7171
struct RemovePred
7272
{
73-
__host__ __device__ bool operator()(const thrust::tuple<uint32_t, uint32_t>& ele1, const float&)
73+
THRUST_HOST_DEVICE bool operator()(const thrust::tuple<uint32_t, uint32_t>& ele1, const float&)
7474
{
7575
return thrust::get<0>(ele1) == thrust::get<1>(ele1);
7676
}
@@ -102,7 +102,7 @@ SimpleUnitTest<TestZipFunctionMixed, type_list<int, float> > TestZipFunctionMixe
102102

103103
struct NestedFunctionCall
104104
{
105-
__host__ __device__ bool
105+
THRUST_HOST_DEVICE bool
106106
operator()(const thrust::tuple<uint32_t, thrust::tuple<thrust::tuple<int, int>, thrust::tuple<int, int>>>& idAndPt)
107107
{
108108
thrust::tuple<thrust::tuple<int, int>, thrust::tuple<int, int>> ele1 = thrust::get<1>(idAndPt);
@@ -138,12 +138,13 @@ struct TestNestedZipFunction
138138
};
139139
SimpleUnitTest<TestNestedZipFunction, type_list<int, float> > TestNestedZipFunctionInstance;
140140

141-
struct SortPred {
142-
__device__ __forceinline__
143-
bool operator()(const thrust::tuple<thrust::tuple<int, int>, int>& a,
144-
const thrust::tuple<thrust::tuple<int, int>, int>& b) {
145-
return thrust::get<1>(a) < thrust::get<1>(b);
146-
}
141+
struct SortPred
142+
{
143+
THRUST_DEVICE __forceinline__ bool
144+
operator()(const thrust::tuple<thrust::tuple<int, int>, int>& a, const thrust::tuple<thrust::tuple<int, int>, int>& b)
145+
{
146+
return thrust::get<1>(a) < thrust::get<1>(b);
147+
}
147148
};
148149
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
149150
template <typename T>

thrust/cmake/thrust-config.cmake

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -567,34 +567,42 @@ endmacro()
567567
macro(_thrust_find_TBB required)
568568
if(NOT TARGET Thrust::TBB)
569569
thrust_debug("Searching for TBB ${required}" internal)
570-
# Swap in a temporary module path to make sure we use our FindTBB.cmake
571-
set(_THRUST_STASH_MODULE_PATH "${CMAKE_MODULE_PATH}")
572-
set(CMAKE_MODULE_PATH "${_THRUST_CMAKE_DIR}")
573-
574-
# Push policy CMP0074 to silence warnings about TBB_ROOT being set. This
575-
# var is used unconventionally in this FindTBB.cmake module.
576-
# Someday we'll have a suitable TBB cmake configuration and can avoid this.
577-
cmake_policy(PUSH)
578-
cmake_policy(SET CMP0074 OLD)
579-
set(THRUST_TBB_ROOT "" CACHE PATH "Path to the root of the TBB installation.")
580-
if (TBB_ROOT AND NOT THRUST_TBB_ROOT)
570+
571+
# Try to find the CMake package that newer versions of TBB install themselves:
572+
if (NOT TARGET TBB::tbb)
573+
find_package(TBB CONFIG ${_THRUST_QUIET_FLAG})
574+
endif()
575+
576+
# If that fails, fall back to the Path of Sadness: FindTBB.cmake
577+
if (NOT TARGET TBB::tbb)
578+
# Swap in a temporary module path to make sure we use our FindTBB.cmake
579+
set(_THRUST_STASH_MODULE_PATH "${CMAKE_MODULE_PATH}")
580+
set(CMAKE_MODULE_PATH "${_THRUST_CMAKE_DIR}")
581+
582+
# Push policy CMP0074 to silence warnings about TBB_ROOT being set. This
583+
# var is used unconventionally in this FindTBB.cmake module.
584+
cmake_policy(PUSH)
585+
cmake_policy(SET CMP0074 OLD)
586+
set(_THRUST_STASH_TBB_ROOT "${TBB_ROOT}")
587+
set(THRUST_TBB_ROOT "" CACHE PATH "Path to the root of the TBB installation.")
588+
if (TBB_ROOT AND NOT THRUST_TBB_ROOT)
581589
message(
582590
"Warning: TBB_ROOT is set. "
583591
"Thrust uses THRUST_TBB_ROOT to avoid issues with CMake Policy CMP0074. "
584592
"Please set this variable instead when using Thrust with TBB."
585593
)
586-
endif()
587-
set(TBB_ROOT "${THRUST_TBB_ROOT}")
588-
set(_THRUST_STASH_TBB_ROOT "${TBB_ROOT}")
594+
endif()
595+
set(TBB_ROOT "${THRUST_TBB_ROOT}")
589596

590-
find_package(TBB
591-
${_THRUST_QUIET_FLAG}
592-
${required}
593-
)
597+
find_package(TBB
598+
${_THRUST_QUIET_FLAG}
599+
${required}
600+
)
594601

595-
cmake_policy(POP)
596-
set(TBB_ROOT "${_THRUST_STASH_TBB_ROOT}")
597-
set(CMAKE_MODULE_PATH "${_THRUST_STASH_MODULE_PATH}")
602+
cmake_policy(POP)
603+
set(TBB_ROOT "${_THRUST_STASH_TBB_ROOT}")
604+
set(CMAKE_MODULE_PATH "${_THRUST_STASH_MODULE_PATH}")
605+
endif()
598606

599607
if (TARGET TBB::tbb)
600608
thrust_set_TBB_target(TBB::tbb)

thrust/complex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pow(const complex<T0>& x, const complex<T1>& y);
744744
* \param x The base.
745745
* \param y The exponent.
746746
*/
747-
template <typename T0, typename T1, std::enable_if_t<std::is_arithmetic<T1>::value, int> = 0>
747+
template <typename T0, typename T1>
748748
THRUST_HOST_DEVICE
749749
complex<typename detail::promoted_numerical_type<T0, T1>::type>
750750
pow(const complex<T0>& x, const T1& y);
@@ -757,7 +757,7 @@ pow(const complex<T0>& x, const T1& y);
757757
* \param x The base.
758758
* \param y The exponent.
759759
*/
760-
template <typename T0, typename T1, std::enable_if_t<std::is_arithmetic<T0>::value, int> = 0>
760+
template <typename T0, typename T1>
761761
THRUST_HOST_DEVICE
762762
complex<typename detail::promoted_numerical_type<T0, T1>::type>
763763
pow(const T0& x, const complex<T1>& y);

0 commit comments

Comments
 (0)