Files
project_6/cccl_upstream/cudax/test/execution/test_visit.cu
muh-bot dedf08166a [CCCL] Add missing CCCL components: c2h, nvbench_helper, cmake, cudax, AGENTS.md
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
2026-08-06 02:14:18 +00:00

82 lines
2.1 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) 2024 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#include <cuda/std/__algorithm/max.h>
#include <cuda/experimental/execution.cuh>
#include "testing.cuh" // IWYU pragma: keep
namespace
{
struct S0
{};
struct S1
{
int a;
};
struct S2
{
int a, b;
};
static_assert(cudax_async::structured_binding_size<S0> == 0);
static_assert(cudax_async::structured_binding_size<S1> == 1);
static_assert(cudax_async::structured_binding_size<S2> == 2);
template <class Fn>
struct recursive_lambda
{
template <class... Args>
auto operator()(Args&&... args)
{
return fn(*this, cuda::std::forward<Args>(args)...);
}
Fn fn;
};
template <class Fn>
recursive_lambda(Fn) -> recursive_lambda<Fn>;
C2H_TEST("sender visitation API works", "[visit]")
{
int leaves = 0;
int depth = 0;
auto snd = cudax_async::when_all(
cudax_async::just(3), //
cudax_async::just(0.1415),
cudax_async::then(cudax_async::just(0.1415), [](double f) {
return f;
}));
auto snd1 = std::move(snd) | cudax_async::then([](int x, double y, double z) {
return x + y + z;
});
auto count_leaves = recursive_lambda{[](auto& self, int& leaves, auto, auto&, auto&... child) {
leaves += (sizeof...(child) == 0);
((cudax_async::visit(self, child, leaves)), ...);
}};
cudax_async::visit(count_leaves, snd1, leaves);
CHECK(leaves == 3);
auto max_depth = recursive_lambda{[i = 0](auto& self, int& depth, auto, auto&, auto&... child) mutable {
++i;
depth = cuda::std::max(depth, i);
((cudax_async::visit(self, child, depth)), ...);
--i;
}};
cudax_async::visit(max_depth, snd1, depth);
CHECK(depth == 4);
}
} // namespace