-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix thrust::raw_reference_cast for tuple_of_iterator_references and simplify thrust::generate #3970
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc9a886
Add tests for raw_reference_cast
bernhardmgruber 53910e2
Fix raw_reference_cast for tuple_of_iterator_references
bernhardmgruber 8901ea2
Simplify thrust::generate
bernhardmgruber 79e8713
Missing header
bernhardmgruber 9ffde2d
Drop obsolete test
bernhardmgruber 4ff3824
Exec check
bernhardmgruber 98fc048
Drop runtime_static_assert
bernhardmgruber 4ad587d
Fix
bernhardmgruber e50d8c3
Fix dangling ref
bernhardmgruber 1609c0b
Fix
bernhardmgruber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <thrust/detail/raw_reference_cast.h> | ||
#include <thrust/device_vector.h> | ||
#include <thrust/iterator/zip_iterator.h> | ||
|
||
#include <unittest/unittest.h> | ||
|
||
void TestRawReferenceCast() | ||
{ | ||
using ::cuda::std::is_same_v; | ||
|
||
{ | ||
[[maybe_unused]] int i = 42; | ||
[[maybe_unused]] const int ci = 42; | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(i)), int&>); | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(ci)), const int&>); | ||
} | ||
{ | ||
[[maybe_unused]] thrust::host_vector<int> vec(1); | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(*vec.begin())), int&>); | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(*vec.cbegin())), const int&>); | ||
|
||
[[maybe_unused]] auto zip = thrust::make_zip_iterator(vec.begin(), vec.begin()); | ||
static_assert( | ||
is_same_v<decltype(thrust::raw_reference_cast(*zip)), thrust::detail::tuple_of_iterator_references<int&, int&>>); | ||
|
||
[[maybe_unused]] auto zip2 = thrust::make_zip_iterator(zip, zip); | ||
static_assert( | ||
is_same_v<decltype(thrust::raw_reference_cast(*zip2)), | ||
thrust::detail::tuple_of_iterator_references<thrust::detail::tuple_of_iterator_references<int&, int&>, | ||
thrust::detail::tuple_of_iterator_references<int&, int&>>>); | ||
} | ||
{ | ||
[[maybe_unused]] thrust::device_vector<int> vec(1); | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(*vec.begin())), int&>); | ||
static_assert(is_same_v<decltype(thrust::raw_reference_cast(*vec.cbegin())), const int&>); | ||
|
||
[[maybe_unused]] auto zip = thrust::make_zip_iterator(vec.begin(), vec.begin()); | ||
static_assert( | ||
is_same_v<decltype(thrust::raw_reference_cast(*zip)), thrust::detail::tuple_of_iterator_references<int&, int&>>); | ||
|
||
[[maybe_unused]] auto zip2 = thrust::make_zip_iterator(zip, zip); | ||
static_assert( | ||
is_same_v<decltype(thrust::raw_reference_cast(*zip2)), | ||
thrust::detail::tuple_of_iterator_references<thrust::detail::tuple_of_iterator_references<int&, int&>, | ||
thrust::detail::tuple_of_iterator_references<int&, int&>>>); | ||
} | ||
} | ||
DECLARE_UNITTEST(TestRawReferenceCast); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thrust::raw_reference_cast(*zip))
would returnconst thrust::detail::tuple_of_iterator_references<int&, int&>&
(const and ref qualified) before this PR, ifvec
is a host vector. It worked correctly for a device vector.