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
61 lines
1.6 KiB
Plaintext
61 lines
1.6 KiB
Plaintext
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//! \file
|
|
//!
|
|
//! \brief Test ctx.wait() on a token: a blocking, value-less synchronization
|
|
|
|
#include <cuda/experimental/stf.cuh>
|
|
|
|
#include <type_traits>
|
|
|
|
using namespace cuda::experimental::stf;
|
|
|
|
__global__ void set_value(int* p, int v)
|
|
{
|
|
*p = v;
|
|
}
|
|
|
|
template <typename context_t>
|
|
void run()
|
|
{
|
|
context_t ctx;
|
|
|
|
// Externally owned buffer: STF only schedules around it, it never owns it.
|
|
int* d_val = nullptr;
|
|
cuda_safe_call(cudaMalloc(&d_val, sizeof(int)));
|
|
|
|
auto tok = ctx.token();
|
|
|
|
ctx.task(tok.write())->*[=](cudaStream_t s) {
|
|
set_value<<<1, 1, 0, s>>>(d_val, 42);
|
|
};
|
|
|
|
// wait(token) has no value to materialize: it must return void and only
|
|
// block the host until the token's producing work has completed.
|
|
static_assert(::std::is_void_v<decltype(ctx.wait(tok))>, "wait(token) must return void");
|
|
ctx.wait(tok);
|
|
|
|
int h_val = 0;
|
|
cuda_safe_call(cudaMemcpy(&h_val, d_val, sizeof(int), cudaMemcpyDeviceToHost));
|
|
_CCCL_ASSERT(h_val == 42, "wait(token) did not synchronize the producing task");
|
|
|
|
ctx.finalize();
|
|
cuda_safe_call(cudaFree(d_val));
|
|
}
|
|
|
|
int main()
|
|
{
|
|
run<stream_ctx>();
|
|
run<graph_ctx>();
|
|
run<context>();
|
|
run<stackable_ctx>();
|
|
}
|