Skip to content

Commit faf0a63

Browse files
committed
fix bug in domain handling that permits when_all(a,b) when a and b have different completion domains
1 parent 6b83131 commit faf0a63

4 files changed

Lines changed: 51 additions & 15 deletions

File tree

include/nvexec/stream/common.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace nv::execution
142142
{
143143
// The stream_domain is how the stream scheduler customizes the sender algorithms. All of the
144144
// algorithms use the current scheduler's domain to transform senders before starting them.
145-
struct stream_domain : STDEXEC::default_domain
145+
struct stream_domain
146146
{
147147
template <::exec::sender_for Sender, class Tag = STDEXEC::tag_of_t<Sender>, class Env>
148148
requires _strm::has_stream_transform<Sender, Env>

include/stdexec/__detail/__domain.hpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,10 @@ namespace STDEXEC
9696
//! @c default_domain when passed the same arguments. The concept is modeled when either
9797
//! of the following is
9898
template <class _Domain, class _OpTag, class _Sndr, class _Env>
99-
concept __default_domain_like = __same_as<
100-
__decay_t<__detail::__transform_sender_result_t<default_domain, _OpTag, _Sndr, _Env>>,
101-
__decay_t<__mcall<
102-
__mtry_catch_q<
103-
__detail::__transform_sender_result_t,
104-
__mconst<__detail::__transform_sender_result_t<default_domain, _OpTag, _Sndr, _Env>>>,
105-
_Domain,
106-
_OpTag,
107-
_Sndr,
108-
_Env>>>;
99+
concept __default_domain_like =
100+
(!__detail::__has_transform_sender<_Domain, _OpTag, _Sndr, _Env>)
101+
|| __same_as<__detail::__transform_sender_result_t<_Domain, _OpTag, _Sndr, _Env>,
102+
__detail::__transform_sender_result_t<default_domain, _OpTag, _Sndr, _Env>>;
109103

110104
template <class... _Domains>
111105
struct indeterminate_domain
@@ -127,15 +121,14 @@ namespace STDEXEC
127121
//! same arguments. If this check fails, the @c static_assert triggers with: "ERROR:
128122
//! indeterminate domains: cannot pick an algorithm customization"
129123
template <class _OpTag, class _Sndr, class _Env>
130-
requires __detail::__has_transform_sender<tag_of_t<_Sndr>, _OpTag, _Sndr, _Env>
131124
[[nodiscard]]
132125
static constexpr auto transform_sender(_OpTag, _Sndr &&__sndr, _Env const &__env)
133-
noexcept(__detail::__has_nothrow_transform_sender<tag_of_t<_Sndr>, _OpTag, _Sndr, _Env>)
134-
-> __detail::__transform_sender_result_t<tag_of_t<_Sndr>, _OpTag, _Sndr, _Env>
126+
noexcept(__detail::__has_nothrow_transform_sender<default_domain, _OpTag, _Sndr, _Env>)
127+
-> __detail::__transform_sender_result_t<default_domain, _OpTag, _Sndr, _Env>
135128
{
136129
static_assert((__default_domain_like<_Domains, _OpTag, _Sndr, _Env> && ...),
137130
"ERROR: indeterminate domains: cannot pick an algorithm customization");
138-
return tag_of_t<_Sndr>{}.transform_sender(_OpTag{}, static_cast<_Sndr &&>(__sndr), __env);
131+
return default_domain().transform_sender(_OpTag{}, static_cast<_Sndr &&>(__sndr), __env);
139132
}
140133
};
141134

test/nvexec/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ target_link_libraries(test.nvexec
6262
# endif()
6363

6464
catch_discover_tests(test.nvexec PROPERTIES TIMEOUT 30)
65+
66+
icm_add_build_failure_test(
67+
NAME when_all_fail
68+
TARGET when_all_fail
69+
SOURCES PARSE when_all_fail.cu
70+
LIBRARIES stdexec nvexec
71+
FOLDER test
72+
)

test/nvexec/when_all_fail.cu

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2021-2024 NVIDIA Corporation
3+
*
4+
* Licensed under the Apache License Version 2.0 with LLVM Exceptions
5+
* (the "License"); you may not use this file except in compliance with
6+
* the License. You may obtain a copy of the License at
7+
*
8+
* https://llvm.org/LICENSE.txt
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <stdexec/execution.hpp>
18+
19+
#include <exec/single_thread_context.hpp>
20+
#include <nvexec/stream_context.cuh>
21+
22+
namespace ex = STDEXEC;
23+
24+
auto main() -> int
25+
{
26+
nvexec::stream_context stream_ctx{};
27+
exec::single_thread_context thread_ctx{};
28+
29+
auto sndr = ex::when_all(ex::schedule(stream_ctx.get_scheduler()),
30+
ex::schedule(thread_ctx.get_scheduler()))
31+
| ex::continues_on(thread_ctx.get_scheduler());
32+
33+
// build error: ERROR: indeterminate domains: cannot pick an algorithm customization
34+
ex::sync_wait(std::move(sndr));
35+
}

0 commit comments

Comments
 (0)