-
Notifications
You must be signed in to change notification settings - Fork 428
[CUB] Fix DeviceAdjacentDifference for cuda::device_buffer iterators #9861
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
Open
Noperi0r
wants to merge
4
commits into
NVIDIA:main
Choose a base branch
from
Noperi0r:fix/cub-adjacent-difference-device-buffer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−1
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1b058db
Fix DeviceAdjacentDifference for device_buffer iterators [skip-docs]
Noperi0r facc0d5
Move DeviceAdjacentDifference device_buffer test [skip-docs]
Noperi0r 7aed3a4
Make AdjacentDifference output pointer binding const [skip-docs]
Noperi0r 8c1fa4f
Use launch wrapper in device_buffer regression test [skip-docs]
Noperi0r 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 contains hidden or 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
This file contains hidden or 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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||
|
|
||||||||||||||||
| #include <cub/device/device_adjacent_difference.cuh> | ||||||||||||||||
|
|
||||||||||||||||
| #include <cuda/buffer> | ||||||||||||||||
| #include <cuda/devices> | ||||||||||||||||
| #include <cuda/iterator> | ||||||||||||||||
| #include <cuda/std/execution> | ||||||||||||||||
|
|
@@ -258,6 +259,35 @@ C2H_TEST("DeviceAdjacentDifference::SubtractLeftCopy works with user provided me | |||||||||||||||
| test_subtract_left_copy(policy); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| C2H_TEST("DeviceAdjacentDifference::SubtractLeftCopy accepts cuda::device_buffer input", | ||||||||||||||||
| "[adjacent_difference][device]") | ||||||||||||||||
| { | ||||||||||||||||
| using type = std::int32_t; | ||||||||||||||||
|
|
||||||||||||||||
| cuda::stream stream{cuda::devices[0]}; | ||||||||||||||||
| auto input = cuda::make_device_buffer<type>(stream, cuda::devices[0], {2, 5, 9, 14, 20}); | ||||||||||||||||
| c2h::device_vector<type> output(input.size(), thrust::no_init); | ||||||||||||||||
| const auto output_it = thrust::raw_pointer_cast(output.data()); | ||||||||||||||||
|
|
||||||||||||||||
| void* temporary_storage = nullptr; | ||||||||||||||||
| std::size_t temporary_bytes = 0; | ||||||||||||||||
| REQUIRE( | ||||||||||||||||
| cudaSuccess | ||||||||||||||||
| == cub::DeviceAdjacentDifference::SubtractLeftCopy( | ||||||||||||||||
| temporary_storage, temporary_bytes, input.begin(), output_it, input.size(), cuda::std::minus<>{}, stream.get())); | ||||||||||||||||
|
|
||||||||||||||||
| c2h::device_vector<std::uint8_t> temporary_buffer(temporary_bytes, thrust::no_init); | ||||||||||||||||
| temporary_storage = thrust::raw_pointer_cast(temporary_buffer.data()); | ||||||||||||||||
| REQUIRE( | ||||||||||||||||
| cudaSuccess | ||||||||||||||||
| == cub::DeviceAdjacentDifference::SubtractLeftCopy( | ||||||||||||||||
| temporary_storage, temporary_bytes, input.begin(), output_it, input.size(), cuda::std::minus<>{}, stream.get())); | ||||||||||||||||
| stream.sync(); | ||||||||||||||||
|
|
||||||||||||||||
| const c2h::host_vector<type> expected{2, 3, 4, 5, 6}; | ||||||||||||||||
| REQUIRE(output == expected); | ||||||||||||||||
|
Comment on lines
+274
to
+276
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important: I think we do not to sync when we use a custom stream:
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| #endif // TEST_LAUNCH == 0 | ||||||||||||||||
|
|
||||||||||||||||
| C2H_TEST("DeviceAdjacentDifference::SubtractLeftCopy works with iterators", "[device][adjacent_difference]", types) | ||||||||||||||||
|
|
||||||||||||||||
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.
Important: Just use the launch wrapper
adjacent_difference_subtract_leftinstead of handling the temporary storage allocation yourself.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.
Updated the regression test to use
adjacent_difference_subtract_left_copy, since this test coversSubtractLeftCopy. The launch wrapper now handles the temporary storage internally.The focused target build, regression test, and targeted pre-commit checks pass locally.