11// ===----------------------------------------------------------------------===//
22//
3- // Part of CUDA Experimental in CUDA C++ Core Libraries ,
3+ // Part of libcu++, the C++ Standard Library for your entire system ,
44// under the Apache License v2.0 with LLVM Exceptions.
55// See https://llvm.org/LICENSE.txt for license information.
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
88//
99// ===----------------------------------------------------------------------===//
10+ #include < cuda/__launch/host_launch.h>
11+ #include < cuda/__stream/stream.h>
1012#include < cuda/atomic>
1113#include < cuda/memory>
1214
13- #include < cuda/experimental/launch.cuh>
14- #include < cuda/experimental/stream.cuh>
15-
1615#include < cooperative_groups.h>
1716#include < testing.cuh>
1817
19- void block_stream (cudax ::stream_ref stream, cuda::atomic<int >& atomic)
18+ void block_stream (cuda ::stream_ref stream, cuda::atomic<int >& atomic)
2019{
2120 auto block_lambda = [&]() {
2221 while (atomic != 1 )
2322 ;
2423 };
25- cudax ::host_launch (stream, block_lambda);
24+ cuda ::host_launch (stream, block_lambda);
2625}
2726
28- void unblock_and_wait_stream (cudax ::stream_ref stream, cuda::atomic<int >& atomic)
27+ void unblock_and_wait_stream (cuda ::stream_ref stream, cuda::atomic<int >& atomic)
2928{
30- CUDAX_REQUIRE (!stream.is_done ());
29+ CCCLRT_REQUIRE (!stream.is_done ());
3130 atomic = 1 ;
3231 stream.sync ();
3332 atomic = 0 ;
3433}
3534
36- void launch_local_lambda (cudax ::stream_ref stream, int & set, int set_to)
35+ void launch_local_lambda (cuda ::stream_ref stream, int & set, int set_to)
3736{
3837 auto lambda = [&set, set_to]() {
3938 set = set_to;
4039 };
41- cudax ::host_launch (stream, lambda);
40+ cuda ::host_launch (stream, lambda);
4241}
4342
4443template <typename Lambda>
@@ -58,7 +57,7 @@ struct lambda_wrapper
5857 if constexpr (cuda::std::is_same_v<cuda::std::invoke_result_t <Lambda>, void *>)
5958 {
6059 // If lambda returns the address it captured, confirm this object wasn't moved
61- CUDAX_REQUIRE (lambda () == this );
60+ CCCLRT_REQUIRE (lambda () == this );
6261 }
6362 else
6463 {
@@ -69,7 +68,7 @@ struct lambda_wrapper
6968 // Make sure we fail if const is added to this wrapper anywhere
7069 void operator ()() const
7170 {
72- CUDAX_REQUIRE (false );
71+ CCCLRT_REQUIRE (false );
7372 }
7473};
7574
@@ -107,13 +106,13 @@ private:
107106 MoveOnlyCallable () = default ;
108107};
109108
110- C2H_TEST (" Host launch" , " " )
109+ C2H_CCCLRT_TEST (" Host launch" , " " )
111110{
112111 cuda::device_ref device{0 };
113112 device.init ();
114113
115114 cuda::atomic<int > atomic = 0 ;
116- cudax ::stream stream{device};
115+ cuda ::stream stream{device};
117116 int i = 0 ;
118117
119118 auto set_lambda = [&](int set) {
@@ -124,35 +123,35 @@ C2H_TEST("Host launch", "")
124123 {
125124 block_stream (stream, atomic);
126125
127- cudax ::host_launch (stream, set_lambda, 2 );
126+ cuda ::host_launch (stream, set_lambda, 2 );
128127
129128 unblock_and_wait_stream (stream, atomic);
130- CUDAX_REQUIRE (i == 2 );
129+ CCCLRT_REQUIRE (i == 2 );
131130 }
132131
133132 SECTION (" Can launch multiple functions" )
134133 {
135134 block_stream (stream, atomic);
136135 auto check_lambda = [&]() {
137- CUDAX_REQUIRE (i == 4 );
136+ CCCLRT_REQUIRE (i == 4 );
138137 };
139138
140- cudax ::host_launch (stream, set_lambda, 3 );
141- cudax ::host_launch (stream, set_lambda, 4 );
142- cudax ::host_launch (stream, check_lambda);
143- cudax ::host_launch (stream, set_lambda, 5 );
139+ cuda ::host_launch (stream, set_lambda, 3 );
140+ cuda ::host_launch (stream, set_lambda, 4 );
141+ cuda ::host_launch (stream, check_lambda);
142+ cuda ::host_launch (stream, set_lambda, 5 );
144143 unblock_and_wait_stream (stream, atomic);
145- CUDAX_REQUIRE (i == 5 );
144+ CCCLRT_REQUIRE (i == 5 );
146145 }
147146
148147 SECTION (" Non trivially copyable" )
149148 {
150149 std::string s = " hello" ;
151150
152- cudax ::host_launch (
151+ cuda ::host_launch (
153152 stream,
154153 [&](auto str_arg) {
155- CUDAX_REQUIRE (s == str_arg);
154+ CCCLRT_REQUIRE (s == str_arg);
156155 },
157156 s);
158157 stream.sync ();
@@ -164,17 +163,17 @@ C2H_TEST("Host launch", "")
164163 i = 21 ;
165164 });
166165
167- cudax ::host_launch (stream, wrapped_lambda);
166+ cuda ::host_launch (stream, wrapped_lambda);
168167 stream.sync ();
169- CUDAX_REQUIRE (i == 21 )
168+ CCCLRT_REQUIRE (i == 21 );
170169 }
171170
172171 SECTION (" Can launch a local function and return" )
173172 {
174173 block_stream (stream, atomic);
175174 launch_local_lambda (stream, i, 42 );
176175 unblock_and_wait_stream (stream, atomic);
177- CUDAX_REQUIRE (i == 42 );
176+ CCCLRT_REQUIRE (i == 42 );
178177 }
179178
180179 SECTION (" Launch by reference" )
@@ -188,9 +187,9 @@ C2H_TEST("Host launch", "")
188187 wrapper_ptr = static_cast <void *>(&another_lambda_setter);
189188
190189 block_stream (stream, atomic);
191- host_launch (stream, cuda::std::ref (another_lambda_setter));
190+ cuda:: host_launch (stream, cuda::std::ref (another_lambda_setter));
192191 unblock_and_wait_stream (stream, atomic);
193- CUDAX_REQUIRE (i == 84 );
192+ CCCLRT_REQUIRE (i == 84 );
194193 }
195194
196195 SECTION (" Launch by reference with arguments" )
@@ -201,9 +200,9 @@ C2H_TEST("Host launch", "")
201200 result = j;
202201 };
203202 block_stream (stream, atomic);
204- host_launch (stream, cuda::std::ref (lambda), i);
203+ cuda:: host_launch (stream, cuda::std::ref (lambda), i);
205204 unblock_and_wait_stream (stream, atomic);
206- CUDAX_REQUIRE (result == 10 );
205+ CCCLRT_REQUIRE (result == 10 );
207206 }
208207
209208 SECTION (" Launch by reference with arguments captured by reference" )
@@ -213,14 +212,14 @@ C2H_TEST("Host launch", "")
213212 j = 10 ;
214213 };
215214 block_stream (stream, atomic);
216- host_launch (stream, cuda::std::ref (lambda), cuda::std::ref (i));
215+ cuda:: host_launch (stream, cuda::std::ref (lambda), cuda::std::ref (i));
217216 unblock_and_wait_stream (stream, atomic);
218- CUDAX_REQUIRE (i == 10 );
217+ CCCLRT_REQUIRE (i == 10 );
219218 }
220219
221220 SECTION (" Check that host_launch works with move only callables and arguments" )
222221 {
223- cudax ::host_launch (stream, MoveOnlyCallable::make (), MoveOnlyArg::make ());
222+ cuda ::host_launch (stream, MoveOnlyCallable::make (), MoveOnlyArg::make ());
224223 stream.sync ();
225224 }
226225}
0 commit comments