-
Notifications
You must be signed in to change notification settings - Fork 430
Add cudax::distributed and cudax::returned_to specifiers for cooperative algorithms
#9862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davebayer
merged 1 commit into
NVIDIA:main
from
Jacobfaib:jacobf/2026-07-14/cooperative-result-specifiers
Jul 15, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
cudax/include/cuda/experimental/__utility/result_policy.cuh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| _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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.