Skip to content

Commit

Permalink
Amend tests after reverting arguments order
Browse files Browse the repository at this point in the history
  • Loading branch information
gonidelis committed Jul 11, 2024
1 parent 018fb91 commit d58b375
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
19 changes: 1 addition & 18 deletions cub/test/catch2_test_device_scan.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,7 @@
#include "catch2_test_helper.h"
#include "catch2_test_launch_helper.h"

// Circumvate DECLARE_LAUNCH_WRAPPER appending stream as the last argument
// by default since init_value needs to be the last argument.
template <typename InputIteratorT, typename OutputIteratorT, typename ScanOpT, typename InitT>
CUB_RUNTIME_FUNCTION static cudaError_t inclusive_scan_init_wrapper(
void* d_temp_storage,
size_t& temp_storage_bytes,
InputIteratorT d_in,
OutputIteratorT d_out,
ScanOpT scan_op,
InitT init,
int num_items,
cudaStream_t stream = 0)
{
return cub::DeviceScan::InclusiveScanInit(
d_temp_storage, temp_storage_bytes, d_in, d_out, scan_op, init, num_items, stream);
}

DECLARE_LAUNCH_WRAPPER(inclusive_scan_init_wrapper, device_inclusive_scan_with_init);
DECLARE_LAUNCH_WRAPPER(cub::DeviceScan::InclusiveScanInit, device_inclusive_scan_with_init);
DECLARE_LAUNCH_WRAPPER(cub::DeviceScan::ExclusiveSum, device_exclusive_sum);
DECLARE_LAUNCH_WRAPPER(cub::DeviceScan::ExclusiveScan, device_exclusive_scan);
DECLARE_LAUNCH_WRAPPER(cub::DeviceScan::InclusiveSum, device_inclusive_sum);
Expand Down
18 changes: 9 additions & 9 deletions cub/test/catch2_test_device_scan_api.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@

CUB_TEST("Device inclusive scan works", "[scan][device]")
{
// Determine temporary device storage requirements for inclusive scan
cudaStream_t stream{};
REQUIRE(cudaSuccess == cudaStreamCreate(&stream));
// example-begin device-inclusive-scan
thrust::device_vector<int> input{0, -1, 2, -3, 4, -5, 6};
thrust::device_vector<int> out(input.size());

void* d_temp_storage{};
size_t temp_storage_bytes{};

int init = 1;
size_t temp_storage_bytes{};

cub::DeviceScan::InclusiveScanInit(
d_temp_storage, temp_storage_bytes, input.begin(), out.begin(), cub::Max{}, init, static_cast<int>(input.size()));
nullptr, temp_storage_bytes, input.begin(), out.begin(), cub::Max{}, init, static_cast<int>(input.size()));

// Allocate temporary storage for inclusive scan
thrust::device_vector<std::uint8_t> temp_storage(temp_storage_bytes);
d_temp_storage = thrust::raw_pointer_cast(temp_storage.data());

// Run inclusive prefix sum
cub::DeviceScan::InclusiveScanInit(
d_temp_storage, temp_storage_bytes, input.begin(), out.begin(), cub::Max{}, init, static_cast<int>(input.size()));
thrust::raw_pointer_cast(temp_storage.data()),
temp_storage_bytes,
input.begin(),
out.begin(),
cub::Max{},
init,
static_cast<int>(input.size()));

thrust::host_vector<int> expected{1, 1, 2, 2, 4, 4, 6};
// example-end device-inclusive-scan
Expand Down

0 comments on commit d58b375

Please sign in to comment.