Added 863 files from NVIDIA/cccl sparse checkout: - c2h/ (27 files): Catch2 test helpers — generators, validators, runner - nvbench_helper/ (10 files): Benchmark harness utilities - cmake/ (29 files): CMake presets and build helpers - cudax/ (794 files): Experimental CUDA extensions - AGENTS.md: NVIDIA's official AI agent instructions for CCCL - CMakePresets.json: Standardized build configurations - cccl-version.json: Version tracking Also added CCCL_ASSET_MAP.md mapping all 4295 CCCL files to competition value and PRD items. cccl_upstream now covers 100% of competition-critical assets: - 27 tuning headers (SM80/90/100 benchmark data) - 32 dispatch headers (algorithm implementations) - 60 Thrust examples (correctness verification) - 217 CUB Catch2 tests (regression matrix) - 153 CUB benchmarks (parameter space search) - 18 CUB examples (API verification) - 27 test helpers + benchmark harness - 794 cudax experimental extensions
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
// SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
|
|
// SPDX-License-Identifier: BSD-3
|
|
|
|
#pragma once
|
|
|
|
#include <cuda/std/type_traits>
|
|
|
|
template <typename VectorT, typename = void>
|
|
struct scalar_to_vec_t
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ __forceinline__ auto operator()(T scalar) const -> VectorT
|
|
{
|
|
return static_cast<VectorT>(scalar);
|
|
}
|
|
};
|
|
|
|
template <typename VectorT>
|
|
struct scalar_to_vec_t<VectorT, ::cuda::std::void_t<decltype(VectorT::x)>>
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ __forceinline__ auto operator()(T scalar) const -> VectorT
|
|
{
|
|
const auto c = static_cast<decltype(VectorT::x)>(scalar);
|
|
VectorT r;
|
|
constexpr auto components = ::cuda::std::tuple_size_v<VectorT>;
|
|
if constexpr (components >= 1)
|
|
{
|
|
r.x = c;
|
|
}
|
|
if constexpr (components >= 2)
|
|
{
|
|
r.y = c;
|
|
}
|
|
if constexpr (components >= 3)
|
|
{
|
|
r.z = c;
|
|
}
|
|
if constexpr (components >= 4)
|
|
{
|
|
r.w = c;
|
|
}
|
|
return r;
|
|
}
|
|
};
|
|
|
|
template <int LogicalWarpThreads, int ItemsPerThread, int ThreadsPerBlock, typename IteratorT>
|
|
void fill_striped(IteratorT it)
|
|
{
|
|
using T = cub::detail::it_value_t<IteratorT>;
|
|
|
|
constexpr int warps_in_block = ThreadsPerBlock / LogicalWarpThreads;
|
|
constexpr int items_per_warp = LogicalWarpThreads * ItemsPerThread;
|
|
scalar_to_vec_t<T> convert;
|
|
|
|
for (int warp_id = 0; warp_id < warps_in_block; warp_id++)
|
|
{
|
|
const int warp_offset_val = items_per_warp * warp_id;
|
|
|
|
for (int lane_id = 0; lane_id < LogicalWarpThreads; lane_id++)
|
|
{
|
|
const int lane_offset = warp_offset_val + lane_id;
|
|
|
|
for (int item = 0; item < ItemsPerThread; item++)
|
|
{
|
|
*(it++) = convert(lane_offset + item * LogicalWarpThreads);
|
|
}
|
|
}
|
|
}
|
|
}
|