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
88 lines
2.8 KiB
Plaintext
88 lines
2.8 KiB
Plaintext
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of CUDA Experimental in CUDA C++ Core Libraries,
|
|
// under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include <cuda/devices>
|
|
#include <cuda/hierarchy>
|
|
#include <cuda/launch>
|
|
#include <cuda/std/bit>
|
|
#include <cuda/std/type_traits>
|
|
#include <cuda/stream>
|
|
|
|
#include <cuda/experimental/group.cuh>
|
|
|
|
#include "group_testing.cuh"
|
|
|
|
namespace
|
|
{
|
|
template <class Level, class Config>
|
|
__device__ void test_lane_synchronizer(const Level& level, Config config)
|
|
{
|
|
using Synchronizer = cudax::lane_synchronizer;
|
|
static_assert(cuda::std::is_empty_v<Synchronizer>);
|
|
|
|
// Test default constructor.
|
|
static_assert(cuda::std::is_trivially_default_constructible_v<Synchronizer>);
|
|
|
|
// Test make_instance(...).
|
|
{
|
|
const auto parent_group = cudax::make_this_group(level, config);
|
|
const ThreadsInWarpMappingResult prev_mapping_result;
|
|
|
|
const cudax::group_by mapping{2};
|
|
const Synchronizer synchronizer{};
|
|
|
|
const auto mapping_result = mapping.map(cuda::gpu_thread, parent_group, prev_mapping_result);
|
|
const auto synchronizer_instance =
|
|
synchronizer.make_instance(cuda::gpu_thread, parent_group, mapping, mapping_result);
|
|
|
|
// Test do_sync(...).
|
|
static_assert(cuda::std::is_same_v<void, decltype(synchronizer_instance.do_sync(mapping_result, synchronizer))>);
|
|
static_assert(noexcept(synchronizer_instance.do_sync(mapping_result, synchronizer)));
|
|
synchronizer_instance.do_sync(mapping_result, synchronizer);
|
|
|
|
// Test do_sync_aligned(...).
|
|
static_assert(
|
|
cuda::std::is_same_v<void, decltype(synchronizer_instance.do_sync_aligned(mapping_result, synchronizer))>);
|
|
static_assert(noexcept(synchronizer_instance.do_sync_aligned(mapping_result, synchronizer)));
|
|
synchronizer_instance.do_sync_aligned(mapping_result, synchronizer);
|
|
}
|
|
}
|
|
|
|
struct TestKernel
|
|
{
|
|
template <class Config>
|
|
__device__ void operator()(const Config& config)
|
|
{
|
|
test_lane_synchronizer(cuda::warp, config);
|
|
test_lane_synchronizer(cuda::block, config);
|
|
test_lane_synchronizer(cuda::cluster, config);
|
|
test_lane_synchronizer(cuda::grid, config);
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
C2H_TEST("Lane synchronizer", "[group]")
|
|
{
|
|
const auto device = cuda::devices[0];
|
|
|
|
const cuda::stream stream{device};
|
|
|
|
{
|
|
const auto config = cuda::make_config(cuda::grid_dims<1>(), cuda::block_dims<8, 4>());
|
|
cuda::launch(stream, config, TestKernel{});
|
|
}
|
|
{
|
|
const auto config = cuda::make_config(cuda::grid_dims<1>(), cuda::block_dims(dim3{8, 4}));
|
|
cuda::launch(stream, config, TestKernel{});
|
|
}
|
|
|
|
stream.sync();
|
|
}
|