Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cub/cub/agent/agent_adjacent_difference.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct AgentDifference
OffsetT num_items)
: temp_storage(temp_storage.Alias())
, input_it(input_it)
, load_it(LoadIt(input_it))
, load_it(try_make_cache_modified_iterator<Policy::LOAD_MODIFIER>(input_it))
, first_tile_previous(first_tile_previous)
, result(result)
, difference_op(difference_op)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <cub/device/device_adjacent_difference.cuh>

#include <cuda/buffer>
#include <cuda/devices>
#include <cuda/iterator>
#include <cuda/std/execution>
Expand Down Expand Up @@ -258,6 +259,22 @@ 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());

adjacent_difference_subtract_left_copy(input.begin(), output_it, input.size(), cuda::std::minus<>{}, stream.get());

const c2h::host_vector<type> expected{2, 3, 4, 5, 6};
REQUIRE(output == expected);
Comment on lines +274 to +276

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
const c2h::host_vector<type> expected{2, 3, 4, 5, 6};
REQUIRE(output == expected);
stream.sync();
const c2h::host_vector<type> expected{2, 3, 4, 5, 6};
REQUIRE(output == expected);

}
#endif // TEST_LAUNCH == 0

C2H_TEST("DeviceAdjacentDifference::SubtractLeftCopy works with iterators", "[device][adjacent_difference]", types)
Expand Down