Files
project_6/cccl_upstream/cub/test/catch2_test_device_bulk.cu
EngineX CI 56fd68e7dd [INFRA] Import NVIDIA/CCCL upstream as optimization reference library
CCCL (CUDA C++ Core Libraries) provides:
- CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk)
- Thrust: high-level parallel algorithms (transform_reduce, sort, scan)
- libcudacxx: CUDA C++ standard library (atomics, barriers, memory)
- cudax: experimental features (memory resources, allocators)
- Tuning policies: per-SM hardware-specific algorithm parameters

Competition optimization vectors mapped to CCCL:
- Output TPS (83% weight): warp_reduce, block_reduce, device_topk
- Input TPS (14% weight): device_scan, block_load, prefetch
- Cache TPS (3% weight): prefix caching strategy patterns
- Memory (0.9 util): pooled/cached/buddy allocators

Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only)
License: Apache-2.0
2026-07-30 09:35:51 +00:00

59 lines
1.5 KiB
Plaintext

// SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
// SPDX-License-Identifier: BSD-3
#include "insert_nested_NVTX_range_guard.h"
#include <cub/device/device_for.cuh>
#include <thrust/count.h>
#include <thrust/detail/raw_pointer_cast.h>
#include <cuda/std/type_traits>
#include "catch2_test_launch_helper.h"
#include <c2h/catch2_test_helper.h>
// %PARAM% TEST_LAUNCH lid 0:1:2
DECLARE_LAUNCH_WRAPPER(cub::DeviceFor::Bulk, device_bulk);
using offset_type = c2h::type_list<std::int32_t, std::uint32_t, std::uint64_t, std::int64_t>;
template <class T>
struct incrementer_t
{
int* d_counts;
template <class OffsetT>
__device__ void operator()(OffsetT i)
{
static_assert(cuda::std::is_same_v<T, OffsetT>, "T and OffsetT must be the same type");
atomicAdd(d_counts + i, 1); // Check if `i` was served more than once
}
};
C2H_TEST("Device bulk works", "[bulk][device]", offset_type)
{
using offset_t = c2h::get<0, TestType>;
constexpr int max_items = 5000000;
constexpr int min_items = 1;
const auto num_items = static_cast<offset_t>(GENERATE_COPY(
take(3, random(min_items, max_items)),
values({
min_items,
max_items,
})));
c2h::device_vector<int> counts(num_items);
int* d_counts = thrust::raw_pointer_cast(counts.data());
device_bulk(num_items, incrementer_t<offset_t>{d_counts});
const auto num_of_once_marked_items =
static_cast<offset_t>(thrust::count(c2h::device_policy, counts.begin(), counts.end(), 1));
REQUIRE(num_of_once_marked_items == num_items);
}