//===----------------------------------------------------------------------===// // // 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 reduce access mode * */ #include using namespace cuda::experimental::stf; template void run() { context_t ctx; auto lsum = ctx.logical_data(shape_of>()); size_t N = 100000; ctx.parallel_for(box(N), lsum.reduce(reducer::sum{}))->*[] __device__(size_t i, auto& sum) { sum++; }; size_t res_sum = ctx.wait(lsum); ctx.finalize(); _CCCL_ASSERT(res_sum == N, "Invalid result"); } int main() { run(); run(); }