Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__coop/any_of.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cuda/std/__type_traits/is_same.h>
#include <cuda/std/optional>

#include <cuda/experimental/__utility/broadcasted.cuh>
#include <cuda/experimental/__utility/result_policy.cuh>
#include <cuda/experimental/group.cuh>

#include <cuda/std/__cccl/prologue.h>
Expand Down
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__coop/reduce.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <cuda/std/optional>

#include <cuda/experimental/__coop/shuffle_down.cuh>
#include <cuda/experimental/__utility/broadcasted.cuh>
#include <cuda/experimental/__utility/result_policy.cuh>
#include <cuda/experimental/group.cuh>

#include <cuda/std/__cccl/prologue.h>
Expand Down
36 changes: 0 additions & 36 deletions cudax/include/cuda/experimental/__utility/broadcasted.cuh

This file was deleted.

85 changes: 85 additions & 0 deletions cudax/include/cuda/experimental/__utility/result_policy.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//

#ifndef _CUDA_EXPERIMENTAL___UTILITY_RESULT_POLICY_CUH
#define _CUDA_EXPERIMENTAL___UTILITY_RESULT_POLICY_CUH

#include <cuda/std/detail/__config>

#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header

#include <cuda/std/__cccl/prologue.h>

// NOLINTBEGIN(bugprone-reserved-identifier)

namespace cuda::experimental
{
template <class _Derived>
struct __result_policy_base
{
using __derived_type _CCCL_NODEBUG_ALIAS = _Derived;
};

//! @brief Result specifier requesting that only a single rank receives the result.
//!
//! Passed as the leading argument to a cooperative or distributed algorithm to indicate
//! that only the rank `dest` receives the result. Every other participating rank receives
//! either no result or an unspecified value; the precise value seen by the non-destination
//! ranks is defined by the algorithm.
template <class _Tp>
struct returned_to : __result_policy_base<returned_to<_Tp>>
{
_CCCL_HIDE_FROM_ABI returned_to() = delete;
Comment thread
davebayer marked this conversation as resolved.

_CCCL_API constexpr explicit returned_to(_Tp __rank) noexcept
: __rank_{__rank}
{}

_Tp __rank_;
};

template <class _Tp>
_CCCL_DEDUCTION_GUIDE_ATTRIBUTES returned_to(_Tp) -> returned_to<_Tp>;

struct distributed_t : __result_policy_base<distributed_t>
{};

//! @brief Result specifier requesting that each rank receives a slice of the result.
//!
//! Passed as the leading argument to a cooperative or distributed algorithm to indicate
//! that every participating rank receives a portion of the global result rather than the
//! whole. For example, a distributed sort delivers to each rank a slice of the globally
//! sorted sequence, and a distributed scan delivers to each rank its portion of the global
//! scan.
_CCCL_GLOBAL_CONSTANT distributed_t distributed{};

struct broadcasted_t : __result_policy_base<broadcasted_t>
{};

//! @brief Result specifier requesting that every rank receives an identical result.
//!
//! Passed as the leading argument to a cooperative or distributed algorithm to indicate
//! that all participating ranks receive the same complete result.
//!
//! @snippet this_block.cu broadcasted reduce
_CCCL_GLOBAL_CONSTANT broadcasted_t broadcasted{};
} // namespace cuda::experimental

// NOLINTEND(bugprone-reserved-identifier)

#include <cuda/std/__cccl/epilogue.h>

#endif // _CUDA_EXPERIMENTAL___UTILITY_RESULT_POLICY_CUH
3 changes: 3 additions & 0 deletions cudax/test/coop/reduce/this_block.cu
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ struct ReduceKernel

if constexpr (Broadcasted)
{
//! [broadcasted reduce]
// Every thread in the block receives the same reduction result.
const auto result = cudax::coop::reduce(cudax::broadcasted, block, thread_data, red_op);
//! [broadcasted reduce]

d_out[cuda::gpu_thread.rank(block)] = result;
}
Expand Down
3 changes: 2 additions & 1 deletion docs/cudax/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ EXCLUDE_SYMBOLS = *detail* *RESERVED* *reserved* *__* _A* _B* _C* _D* _E*

# Path for @snippet references to test/example files
EXAMPLE_PATH = ../../cudax/include/cuda/experimental/__stf/utility \
../../cudax/test/multi_gpu/algorithms
../../cudax/test/multi_gpu/algorithms \
../../cudax/test/coop/reduce

FILE_PATTERNS = *.h *.hpp *.cuh
EXTENSION_MAPPING = cuh=C++ cu=C++
Expand Down
Loading