Skip to content

Commit deaa918

Browse files
authored
Various and sundry fixes for Thrust's CPP backends. (#1722)
* Fix non-CUDA Thrust handling of __host__/__device__ * Add some missing headers in the Thrust CPU backends. * Remove unused variables. * Add missing header. * Move deprecation markup to `result_of` definition. Having the deprecation markup on the declaration instead of the definition cause the deprecation diagnostics to be emitted when defining the deprecate type on gcc. Moving the markup fixes this. * Don't expose builtins as functions in thrust. error: use of built-in trait '__is_same(..., ...)' in function signature; use library traits instead. * Remove re-declaration of `reference_wrapper` This type was already forward-declared in `is_reference_wrapper.h`. Redeclaring it with the vis attribute broke gcc. * Disable failing OpenMP test (tracked in #1715). * Print CMake configure step on windows. * Use installed TBB CMake configs if available. Fallback to our FindTBB.cmake as a last resort.
1 parent 6a721a0 commit deaa918

File tree

171 files changed

+764
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+764
-658
lines changed

ci/windows/build_common.psm1

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ function configure_preset {
7373
# CMake must be invoked in the same directory as the presets file:
7474
pushd ".."
7575

76-
cmake --preset $PRESET $CMAKE_OPTIONS --log-level VERBOSE
76+
# Echo and execute command to stdout:
77+
$configure_command = "cmake --preset $PRESET $CMAKE_OPTIONS --log-level VERBOSE"
78+
Write-Host $configure_command
79+
Invoke-Expression $configure_command
7780
$test_result = $LastExitCode
7881

7982
If ($test_result -ne 0) {

libcudacxx/include/cuda/std/__tuple_dir/sfinae_helpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ template <bool... _Preds>
4242
struct __all_dummy;
4343

4444
template <bool... _Pred>
45-
using __all = _IsSame<__all_dummy<_Pred...>, __all_dummy<((void) _Pred, true)...>>;
45+
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void) _Pred, true)...>>;
4646

4747
struct __tuple_sfinae_base
4848
{

libcudacxx/include/cuda/std/__type_traits/result_of.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD
2828

2929
#if _CCCL_STD_VER <= 2017 || defined(_LIBCUDACXX_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3030
template <class _Callable>
31-
class _LIBCUDACXX_DEPRECATED_IN_CXX17 result_of;
31+
class result_of;
3232

3333
template <class _Fp, class... _Args>
34-
class _LIBCUDACXX_TEMPLATE_VIS result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...>
34+
class _LIBCUDACXX_DEPRECATED_IN_CXX17 _LIBCUDACXX_TEMPLATE_VIS result_of<_Fp(_Args...)>
35+
: public __invoke_of<_Fp, _Args...>
3536
{};
3637

3738
# if _CCCL_STD_VER > 2011

libcudacxx/include/cuda/std/detail/libcxx/include/type_traits

-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,6 @@ namespace std
567567

568568
_LIBCUDACXX_BEGIN_NAMESPACE_STD
569569

570-
template <class _Tp>
571-
class _LIBCUDACXX_TEMPLATE_VIS reference_wrapper;
572570
template <class _Tp>
573571
struct _LIBCUDACXX_TEMPLATE_VIS hash;
574572

thrust/examples/arbitrary_transformation.cu

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# include <thrust/zip_function.h>
1111
#endif // >= C++11
1212

13+
#include "include/host_device.h"
14+
1315
// This example shows how to implement an arbitrary transformation of
1416
// the form output[i] = F(first[i], second[i], third[i], ... ).
1517
// In this example, we use a function with 3 inputs and 1 output.

thrust/examples/bounding_box.cu

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <thrust/random.h>
55
#include <thrust/transform_reduce.h>
66

7+
#include "include/host_device.h"
8+
79
// This example shows how to compute a bounding box
810
// for a set of points in two dimensions.
911

thrust/examples/bucket_sort2d.cu

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <iomanip>
1010
#include <iostream>
1111

12+
#include "include/host_device.h"
13+
1214
// define a 2d float vector
1315
typedef thrust::tuple<float, float> vec2;
1416

thrust/examples/cuda/range_view.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <iostream>
77

8+
#include "../include/host_device.h"
9+
810
// This example demonstrates the use of a view: a non-owning wrapper for an
911
// iterator range which presents a container-like interface to the user.
1012
//

thrust/examples/discrete_voronoi.cu

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <iomanip>
1111
#include <iostream>
1212

13+
#include "include/host_device.h"
1314
#include "include/timer.h"
1415

1516
// Compute an approximate Voronoi Diagram with a Jump Flooding Algorithm (JFA)

thrust/examples/dot_products_with_zip.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <thrust/random.h>
66
#include <thrust/transform.h>
77

8+
#include "include/host_device.h"
9+
810
// This example shows how thrust::zip_iterator can be used to create a
911
// 'virtual' array of structures. In this case the structure is a 3d
1012
// vector type (Float3) whose (x,y,z) components will be stored in

thrust/examples/include/host_device.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2008-2009 NVIDIA Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#if THRUST_DEVICE_COMPILER != THRUST_DEVICE_COMPILER_NVCC
20+
21+
# ifndef __host__
22+
# define __host__
23+
# endif
24+
25+
# ifndef __device__
26+
# define __device__
27+
# endif
28+
29+
#endif

thrust/examples/lambda.cu

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <iostream>
66

7+
#include "include/host_device.h"
8+
79
// This example demonstrates the use of placeholders to implement
810
// the SAXPY operation (i.e. Y[i] = a * X[i] + Y[i]).
911
//

thrust/examples/max_abs_diff.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <cmath>
66
#include <iostream>
77

8+
#include "include/host_device.h"
9+
810
// this example computes the maximum absolute difference
911
// between the elements of two vectors
1012

thrust/examples/minmax.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <thrust/random.h>
66
#include <thrust/transform_reduce.h>
77

8+
#include "include/host_device.h"
9+
810
// compute minimum and maximum values in a single reduction
911

1012
// minmax_pair stores the minimum and maximum

thrust/examples/monte_carlo.cu

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <iomanip>
88
#include <iostream>
99

10+
#include "include/host_device.h"
11+
1012
// we could vary M & N to find the perf sweet spot
1113

1214
__host__ __device__ unsigned int hash(unsigned int a)

thrust/examples/monte_carlo_disjoint_sequences.cu

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <cmath>
77
#include <iostream>
88

9+
#include "include/host_device.h"
10+
911
// The technique demonstrated in the example monte_carlo.cu
1012
// assigns an independently seeded random number generator to each
1113
// of 30K threads, and uses a hashing scheme based on thread index to

thrust/examples/norm.cu

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <cmath>
77
#include <iostream>
88

9+
#include "include/host_device.h"
10+
911
// This example computes the norm [1] of a vector. The norm is
1012
// computed by squaring all numbers in the vector, summing the
1113
// squares, and taking the square root of the sum of squares. In

thrust/examples/padded_grid_reduction.cu

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cmath>
1111
#include <iomanip>
1212

13+
#include "include/host_device.h"
1314
#include <float.h>
1415

1516
// This example computes the minimum and maximum values

thrust/examples/raw_reference_cast.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <iostream>
77

8+
#include "include/host_device.h"
9+
810
// This example illustrates how to use the raw_reference_cast to convert
911
// system-specific reference wrappers into native references.
1012
//

thrust/examples/remove_points2d.cu

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <thrust/random.h>
33
#include <thrust/remove.h>
44

5+
#include "include/host_device.h"
6+
57
// This example generates random points in the
68
// unit square [0,1)x[0,1) and then removes all
79
// points where x^2 + y^2 > 1

thrust/examples/repeated_range.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <iostream>
1010

11+
#include "include/host_device.h"
12+
1113
// this example illustrates how to make repeated access to a range of values
1214
// examples:
1315
// repeated_range([0, 1, 2, 3], 1) -> [0, 1, 2, 3]

thrust/examples/saxpy.cu

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <iostream>
88
#include <iterator>
99

10+
#include "include/host_device.h"
11+
1012
// This example illustrates how to implement the SAXPY
1113
// operation (Y[i] = a * X[i] + Y[i]) using Thrust.
1214
// The saxpy_slow function demonstrates the most

thrust/examples/scan_by_key.cu

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <iostream>
66

7+
#include "include/host_device.h"
8+
79
// BinaryPredicate for the head flag segment representation
810
// equivalent to thrust::not2(thrust::project2nd<int,int>()));
911
template <typename HeadFlagType>

thrust/examples/scan_matrix_by_rows.cu

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <thrust/scan.h>
55
#include <thrust/sequence.h>
66

7+
#include "include/host_device.h"
78
#include <assert.h>
89

910
// We have a matrix stored in a `thrust::device_vector`. We want to perform a

thrust/examples/simple_moving_average.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <iomanip>
99
#include <iostream>
1010

11+
#include "include/host_device.h"
12+
1113
// Efficiently computes the simple moving average (SMA) [1] of a data series
1214
// using a parallel prefix-sum or "scan" operation.
1315
//

thrust/examples/sort.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <iomanip>
66
#include <iostream>
77

8+
#include "include/host_device.h"
9+
810
// Helper routines
911

1012
void initialize(thrust::device_vector<int>& v)

thrust/examples/sorting_aos_vs_soa.cu

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <thrust/random.h>
44
#include <thrust/sort.h>
55

6+
#include "include/host_device.h"
67
#include "include/timer.h"
78
#include <assert.h>
89

thrust/examples/stream_compaction.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <iterator>
99
#include <string>
1010

11+
#include "include/host_device.h"
12+
1113
// this functor returns true if the argument is odd, and false otherwise
1214
template <typename T>
1315
struct is_odd : public thrust::unary_function<T, bool>

thrust/examples/strided_range.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <iostream>
1010

11+
#include "include/host_device.h"
12+
1113
// this example illustrates how to make strided access to a range of values
1214
// examples:
1315
// strided_range([0, 1, 2, 3, 4, 5, 6], 1) -> [0, 1, 2, 3, 4, 5, 6]

thrust/examples/sum_rows.cu

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <iostream>
99

10+
#include "include/host_device.h"
11+
1012
// convert a linear index to a row index
1113
template <typename T>
1214
struct linear_index_to_row_index : public thrust::unary_function<T, T>

thrust/examples/summary_statistics.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <iostream>
99
#include <limits>
1010

11+
#include "include/host_device.h"
12+
1113
// This example computes several statistical properties of a data
1214
// series in a single reduction. The algorithm is described in detail here:
1315
// http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm

thrust/examples/summed_area_table.cu

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <iomanip>
1010
#include <iostream>
1111

12+
#include "include/host_device.h"
13+
1214
// This example computes a summed area table using segmented scan
1315
// http://en.wikipedia.org/wiki/Summed_area_table
1416

thrust/examples/tiled_range.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <iostream>
1010

11+
#include "include/host_device.h"
12+
1113
// this example illustrates how to tile a range multiple times
1214
// examples:
1315
// tiled_range([0, 1, 2, 3], 1) -> [0, 1, 2, 3]

thrust/examples/transform_input_output_iterator.cu

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <iostream>
99

10+
#include "include/host_device.h"
11+
1012
// Base 2 fixed point
1113
class ScaledInteger
1214
{

thrust/examples/transform_iterator.cu

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <iterator>
99
#include <string>
1010

11+
#include "include/host_device.h"
12+
1113
// this functor clamps a value to the range [lo, hi]
1214
template <typename T>
1315
struct clamp : public thrust::unary_function<T, T>

thrust/examples/transform_output_iterator.cu

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <iostream>
77

8+
#include "include/host_device.h"
89
struct Functor
910
{
1011
template <class Tuple>

thrust/examples/uninitialized_vector.cu

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <cassert>
1313

14+
#include "include/host_device.h"
15+
1416
// uninitialized_allocator is an allocator which
1517
// derives from device_allocator and which has a
1618
// no-op construct member function

thrust/examples/word_count.cu

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <iostream>
77

8+
#include "include/host_device.h"
9+
810
// This example computes the number of words in a text sample
911
// with a single call to thrust::inner_product. The algorithm
1012
// counts the number of characters which start a new word, i.e.

0 commit comments

Comments
 (0)