Skip to content

Commit 4fd1b54

Browse files
committed
Add abstractions that use memory accessible from both hosts and devices.
- `thrust::universal_vector`. - `thrust::universal_ptr`. - `thrust::universal_allocator`. Change all backend fancy pointer and reference types to be aliases. Substantially refactor `thrust::reference`. Fix a bug that allowed `thrust::reference`s to const objects to be swapped: https://godbolt.org/z/r9G4nY Introduce a new `thrust::tagged_reference` type that breaks the circular template argument dependency between `thrust::pointer` and `thrust::reference`.
1 parent b1c3336 commit 4fd1b54

59 files changed

Lines changed: 1702 additions & 2801 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ The new `thrust::shuffle` algorithm has been tweaked to improve the randomness
1212
of the output.
1313

1414
Our CMake package and build system continue to see improvements with
15-
improved `add_subdirectory` support, installation rules, status messages, and
16-
other features that make CUB easier to use from CMake projects.
15+
better `add_subdirectory` support, installation rules, status messages, and
16+
other features that make Thrust easier to use from CMake projects.
1717

1818
The release includes several other bugfixes and modernizations, and received
1919
updates from 12 contributors.
@@ -72,11 +72,12 @@ updates from 12 contributors.
7272
- Github's `thrust/cub` repository is now `NVIDIA/cub`
7373
- Development has moved from the `master` branch to the `main` branch.
7474

75-
# Thrust 1.10.0 (NVIDIA HPC SDK 20.9)
75+
# Thrust 1.10.0 (NVIDIA HPC SDK 20.9, CUDA Toolkit 11.2)
7676

7777
## Summary
7878

79-
Thrust 1.10.0 is the major release accompanying the NVIDIA HPC SDK 20.9 release.
79+
Thrust 1.10.0 is the major release accompanying the NVIDIA HPC SDK 20.9 release
80+
and the CUDA Toolkit 11.2 release.
8081
It drops support for C++03, GCC < 5, Clang < 6, and MSVC < 2017.
8182
It also overhauls CMake support.
8283
Finally, we now have a Code of Conduct for contributors:

examples/sorting_aos_vs_soa.cu

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <thrust/host_vector.h>
12
#include <thrust/device_vector.h>
23
#include <thrust/sort.h>
34
#include <thrust/random.h>
@@ -7,7 +8,7 @@
78

89
// This examples compares sorting performance using Array of Structures (AoS)
910
// and Structure of Arrays (SoA) data layout. Legacy applications will often
10-
// store data in C/C++ structs, such as MyStruct defined below. Although
11+
// store data in C/C++ structs, such as MyStruct defined below. Although
1112
// Thrust can process array of structs, it is typically less efficient than
1213
// the equivalent structure of arrays layout. In this particular example,
1314
// the optimized SoA approach is approximately *five times faster* than the
@@ -57,7 +58,7 @@ int main(void)
5758
{
5859
size_t N = 2 * 1024 * 1024;
5960

60-
// Sort Key-Value pairs using Array of Structures (AoS) storage
61+
// Sort Key-Value pairs using Array of Structures (AoS) storage
6162
{
6263
thrust::device_vector<MyStruct> structures(N);
6364

@@ -71,7 +72,7 @@ int main(void)
7172
std::cout << "AoS sort took " << 1e3 * t.elapsed() << " milliseconds" << std::endl;
7273
}
7374

74-
// Sort Key-Value pairs using Structure of Arrays (SoA) storage
75+
// Sort Key-Value pairs using Structure of Arrays (SoA) storage
7576
{
7677
thrust::device_vector<int> keys(N);
7778
thrust::device_vector<float> values(N);

examples/transform_input_output_iterator.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <thrust/host_vector.h>
12
#include <thrust/device_vector.h>
23
#include <thrust/functional.h>
34
#include <thrust/gather.h>

testing/cuda/managed_memory_pointer.cu

Lines changed: 0 additions & 141 deletions
This file was deleted.

testing/functional_placeholders_bitwise.cu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ template<typename T, typename U, typename Allocator>
2424
typename Allocator::template rebind<U>::other> type;
2525
};
2626

27+
template<typename T, typename U, typename Allocator>
28+
struct rebind_vector<thrust::universal_vector<T, Allocator>, U>
29+
{
30+
typedef thrust::universal_vector<U,
31+
typename Allocator::template rebind<U>::other> type;
32+
};
33+
2734
#define BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(name, op, reference_functor, type_list) \
2835
template<typename Vector> \
2936
struct TestFunctionalPlaceholders##name \

testing/functional_placeholders_logical.cu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ template<typename T, typename U, typename Allocator>
2323
typename Allocator::template rebind<U>::other> type;
2424
};
2525

26+
template<typename T, typename U, typename Allocator>
27+
struct rebind_vector<thrust::universal_vector<T, Allocator>, U>
28+
{
29+
typedef thrust::universal_vector<U,
30+
typename Allocator::template rebind<U>::other> type;
31+
};
32+
2633
#define BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(name, reference_operator, functor) \
2734
template<typename Vector> \
2835
void TestFunctionalPlaceholders##name(void) \

testing/functional_placeholders_relational.cu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ template<typename T, typename U, typename Allocator>
2323
typename Allocator::template rebind<U>::other> type;
2424
};
2525

26+
template<typename T, typename U, typename Allocator>
27+
struct rebind_vector<thrust::universal_vector<T, Allocator>, U>
28+
{
29+
typedef thrust::universal_vector<U,
30+
typename Allocator::template rebind<U>::other> type;
31+
};
32+
2633
#define BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(name, reference_operator, functor) \
2734
template<typename Vector> \
2835
void TestFunctionalPlaceholdersBinary##name(void) \

0 commit comments

Comments
 (0)