-
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
1b058db
facc0d5
7aed3a4
8c1fa4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,12 @@ | |||||
|
|
||||||
| #include <cub/device/device_adjacent_difference.cuh> | ||||||
|
|
||||||
| #include <cuda/buffer> | ||||||
| #include <cuda/devices> | ||||||
| #include <cuda/std/functional> | ||||||
|
|
||||||
| #include <cstdint> | ||||||
|
|
||||||
| #include <c2h/catch2_test_helper.h> | ||||||
|
|
||||||
| // Guard: the legacy memory-size query call with all defaults (no explicit difference_op, | ||||||
|
|
@@ -51,4 +57,33 @@ C2H_TEST("DeviceAdjacentDifference::SubtractRight legacy size-query is unambiguo | |||||
| REQUIRE(cudaSuccess == cub::DeviceAdjacentDifference::SubtractRight(nullptr, bytes, d_in, n)); | ||||||
| } | ||||||
|
|
||||||
| 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()); | ||||||
|
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.
Suggested change
Author
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. Applied |
||||||
| 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); | ||||||
|
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.
Suggested change
Author
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. Applied |
||||||
| 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); | ||||||
| } | ||||||
|
|
||||||
| // todo(giannis): extract examples from the docs to literalinclude extracts here | ||||||
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: Please move the new test into the file
catch2_test_device_adjacent_difference_substract_left.cu. The_api.cufiles cover tested API examples for the documentation.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.
Moved the regression test to
catch2_test_device_adjacent_difference_substract_left.cuand restored
catch2_test_device_adjacent_difference_api.cuto its previous scope.The relocated focused test, target build, and targeted pre-commit checks pass locally.