Skip to content

Commit ac27beb

Browse files
authored
Merge pull request NVIDIA#1453 from ericniebler/clang-format-20
reformat with clang-format-20
2 parents 184a8ab + 3bf6e4c commit ac27beb

File tree

146 files changed

+926
-1355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+926
-1355
lines changed

.clang-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ AlwaysBreakAfterReturnType: None
2727
AlwaysBreakBeforeMultilineStrings: true
2828
AlwaysBreakTemplateDeclarations: Yes
2929
AttributeMacros: [
30-
'STDEXEC_SYSTEM_CONTEXT_INLINE'
30+
STDEXEC_SYSTEM_CONTEXT_INLINE
3131
]
3232
BinPackArguments: false
3333
BinPackParameters: false
@@ -86,7 +86,7 @@ Macros: [
8686
'STDEXEC_MEMFN_DECL(X)=X',
8787
'STDEXEC_MEMFN_DECL(X,Y)=X,Y',
8888
'STDEXEC_MEMFN_DECL(X,Y,Z)=X,Y,Z',
89-
'STDEXEC_ATTRIBUTE(X)=__attribute__(X) //',
89+
'STDEXEC_ATTRIBUTE(X)=[[]]',
9090
'STDEXEC_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
9191
'STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
9292
'STDEXEC_MISSING_MEMBER(X,Y)=true',

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ ab2a3baef655db23fb7ec11ce7ec49575bbd2807
2121

2222
# Reformat everything with clang-format-18
2323
413749037ac3cd2f66a476fdd593e54e3b4b60b7
24+
25+
# Reformat everything with clang-format-20
26+
aee392a046a26ae2340849fe98e38332d9537397

examples/algorithms/retry.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ struct _retry_sender {
121121
using _value = stdexec::completion_signatures<stdexec::set_value_t(Ts...)>;
122122

123123
template <class Env>
124-
auto get_completion_signatures(Env&&) const
125-
-> stdexec::transform_completion_signatures_of<
126-
S&,
127-
Env,
128-
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
129-
_value,
130-
_error> {
124+
auto get_completion_signatures(Env&&) const -> stdexec::transform_completion_signatures_of<
125+
S&,
126+
Env,
127+
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
128+
_value,
129+
_error> {
131130
return {};
132131
}
133132

examples/benchmark/common.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ void my_main(int argc, char** argv, exec::numa_policy policy = exec::get_numa_po
121121
std::size_t buffer_size = 2000 << 20;
122122
for (std::size_t i = 0; i < static_cast<std::size_t>(nthreads); ++i) {
123123
exec::numa_allocator<char> alloc(policy.thread_index_to_node(i));
124-
buffers.push_back(std::unique_ptr<char, numa_deleter>{
125-
alloc.allocate(buffer_size), numa_deleter{buffer_size, alloc}
124+
buffers.push_back(
125+
std::unique_ptr<char, numa_deleter>{
126+
alloc.allocate(buffer_size), numa_deleter{buffer_size, alloc}
126127
});
127128
}
128129
#endif

examples/hello_world.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ using stdexec::sync_wait;
2626
int main() {
2727
exec::numa_policy numa{exec::no_numa_policy{}};
2828
exec::static_thread_pool ctx{8};
29-
scheduler auto sch = ctx.get_scheduler(); // 1
30-
//
31-
sender auto begin = schedule(sch); // 2
29+
scheduler auto sch = ctx.get_scheduler(); // 1
30+
//
31+
sender auto begin = schedule(sch); // 2
3232
sender auto hi_again = then( // 3
3333
begin, // 3
3434
[] { // 3
3535
std::cout << "Hello world! Have an int.\n"; // 3
3636
return 13; // 3
3737
}); // 3
38-
//
38+
//
3939
sender auto add_42 = then(hi_again, [](int arg) { return arg + 42; }); // 4
4040
auto [i] = sync_wait(std::move(add_42)).value(); // 5
4141
std::cout << "Result: " << i << std::endl;

examples/io_uring.cpp

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,45 @@ int main() {
4040
auto scheduler2 = context2.get_scheduler();
4141
using namespace std::chrono_literals;
4242

43-
stdexec::sync_wait(exec::when_any(
44-
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
45-
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
46-
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));
47-
48-
stdexec::sync_wait(exec::when_any(
49-
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; })
50-
| stdexec::upon_stopped([] { std::cout << "Hello, 1, stopped.\n"; }),
51-
exec::schedule_after(scheduler2, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
52-
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));
53-
54-
stdexec::sync_wait(stdexec::when_all(
55-
stdexec::schedule(scheduler) | stdexec::then([] { std::cout << "Hello, 0!\n"; }),
56-
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
57-
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; }),
58-
exec::schedule_after(scheduler, 3s) | stdexec::then([] { std::cout << "Stop it!\n"; }),
59-
exec::finally(exec::schedule_after(scheduler2, 4s), stdexec::just() | stdexec::then([&] {
60-
context.request_stop();
61-
})),
62-
exec::finally(exec::schedule_after(scheduler, 4s), stdexec::just() | stdexec::then([&] {
63-
context2.request_stop();
64-
})),
65-
exec::schedule_after(scheduler, 10s) //
66-
| stdexec::then([] { //
67-
std::cout << "Hello, world!\n"; //
68-
}) //
69-
| stdexec::upon_stopped([] { //
70-
std::cout << "Hello, stopped.\n"; //
71-
}), //
72-
exec::schedule_after(scheduler2, 10s) //
73-
| stdexec::then([] { //
74-
std::cout << "Hello, world!\n"; //
75-
}) //
76-
| stdexec::upon_stopped([] { //
77-
std::cout << "Hello, stopped.\n"; //
78-
}))); //
43+
stdexec::sync_wait(
44+
exec::when_any(
45+
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
46+
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
47+
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));
48+
49+
stdexec::sync_wait(
50+
exec::when_any(
51+
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; })
52+
| stdexec::upon_stopped([] { std::cout << "Hello, 1, stopped.\n"; }),
53+
exec::schedule_after(scheduler2, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
54+
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));
55+
56+
stdexec::sync_wait(
57+
stdexec::when_all(
58+
stdexec::schedule(scheduler) | stdexec::then([] { std::cout << "Hello, 0!\n"; }),
59+
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
60+
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; }),
61+
exec::schedule_after(scheduler, 3s) | stdexec::then([] { std::cout << "Stop it!\n"; }),
62+
exec::finally(exec::schedule_after(scheduler2, 4s), stdexec::just() | stdexec::then([&] {
63+
context.request_stop();
64+
})),
65+
exec::finally(exec::schedule_after(scheduler, 4s), stdexec::just() | stdexec::then([&] {
66+
context2.request_stop();
67+
})),
68+
exec::schedule_after(scheduler, 10s) //
69+
| stdexec::then([] { //
70+
std::cout << "Hello, world!\n"; //
71+
}) //
72+
| stdexec::upon_stopped([] { //
73+
std::cout << "Hello, stopped.\n"; //
74+
}), //
75+
exec::schedule_after(scheduler2, 10s) //
76+
| stdexec::then([] { //
77+
std::cout << "Hello, world!\n"; //
78+
}) //
79+
| stdexec::upon_stopped([] { //
80+
std::cout << "Hello, stopped.\n"; //
81+
}))); //
7982
io_thread.join();
8083
io_thread2.join();
8184

@@ -96,9 +99,10 @@ int main() {
9699

97100
while (!context.is_running())
98101
;
99-
stdexec::sync_wait(exec::when_any(
100-
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
101-
exec::schedule_after(scheduler, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })));
102+
stdexec::sync_wait(
103+
exec::when_any(
104+
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
105+
exec::schedule_after(scheduler, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })));
102106

103107
auto time_point = std::chrono::steady_clock::now() + 1s;
104108
stdexec::sync_wait(exec::schedule_at(scheduler, time_point) | stdexec::then([] {

examples/nvexec/maxwell/common.cuh

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ struct deleter_t {
5151
};
5252

5353
template <class T>
54-
STDEXEC_ATTRIBUTE((host, device))
55-
inline std::unique_ptr<T, deleter_t> allocate_on(bool gpu, std::size_t elements = 1) {
54+
STDEXEC_ATTRIBUTE((host, device)) inline std::unique_ptr<T, deleter_t> allocate_on(bool gpu, std::size_t elements = 1) {
5655
T *ptr{};
5756

5857
#if defined(_NVHPC_CUDA) || defined(__CUDACC__)
@@ -90,8 +89,7 @@ struct fields_accessor {
9089

9190
float *base_ptr;
9291

93-
STDEXEC_ATTRIBUTE((nodiscard, host, device))
94-
float *get(field_id id) const {
92+
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float *get(field_id id) const {
9593
return base_ptr + static_cast<int>(id) * cells;
9694
}
9795
};
@@ -111,9 +109,10 @@ struct grid_t {
111109
grid_t(std::size_t n, bool gpu)
112110
: n(n)
113111
, cells(n * n)
114-
, fields_(allocate_on<float>(
115-
gpu,
116-
static_cast<std::size_t>(cells) * static_cast<int>(field_id::fields_count))) {
112+
, fields_(
113+
allocate_on<float>(
114+
gpu,
115+
static_cast<std::size_t>(cells) * static_cast<int>(field_id::fields_count))) {
117116
}
118117

119118
[[nodiscard]]
@@ -124,8 +123,8 @@ struct grid_t {
124123

125124
constexpr float C0 = 299792458.0f; // Speed of light [metres per second]
126125

127-
STDEXEC_ATTRIBUTE((host, device))
128-
inline bool is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
126+
STDEXEC_ATTRIBUTE((host, device)) inline bool
127+
is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
129128
const float os2 = object_size * object_size;
130129
return ((x - object_x) * (x - object_x) + (y - object_y) * (y - object_y) <= os2);
131130
}
@@ -139,9 +138,7 @@ struct grid_initializer_t {
139138
float dt;
140139
fields_accessor accessor;
141140

142-
STDEXEC_ATTRIBUTE((host, device))
143-
void
144-
operator()(std::size_t cell_id) const {
141+
STDEXEC_ATTRIBUTE((host, device)) void operator()(std::size_t cell_id) const {
145142
const std::size_t row = cell_id / accessor.n;
146143
const std::size_t column = cell_id % accessor.n;
147144

@@ -184,32 +181,26 @@ inline grid_initializer_t grid_initializer(float dt, fields_accessor accessor) {
184181
return {dt, accessor};
185182
}
186183

187-
STDEXEC_ATTRIBUTE((host, device))
188-
inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
184+
STDEXEC_ATTRIBUTE((host, device)) inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
189185
return col == N - 1 ? cell_id - (N - 1) : cell_id + 1;
190186
}
191187

192-
STDEXEC_ATTRIBUTE((host, device))
193-
inline std::size_t left_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
188+
STDEXEC_ATTRIBUTE((host, device)) inline std::size_t left_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
194189
return col == 0 ? cell_id + N - 1 : cell_id - 1;
195190
}
196191

197-
STDEXEC_ATTRIBUTE((host, device))
198-
inline std::size_t bottom_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
192+
STDEXEC_ATTRIBUTE((host, device)) inline std::size_t bottom_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
199193
return row == 0 ? cell_id + N * (N - 1) : cell_id - N;
200194
}
201195

202-
STDEXEC_ATTRIBUTE((host, device))
203-
inline std::size_t top_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
196+
STDEXEC_ATTRIBUTE((host, device)) inline std::size_t top_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
204197
return row == N - 1 ? cell_id - N * (N - 1) : cell_id + N;
205198
}
206199

207200
struct h_field_calculator_t {
208201
fields_accessor accessor;
209202

210-
STDEXEC_ATTRIBUTE((always_inline, host, device))
211-
void
212-
operator()(std::size_t cell_id) const {
203+
STDEXEC_ATTRIBUTE((always_inline, host, device)) void operator()(std::size_t cell_id) const {
213204
const std::size_t N = accessor.n;
214205
const std::size_t column = cell_id % N;
215206
const std::size_t row = cell_id / N;
@@ -235,21 +226,17 @@ struct e_field_calculator_t {
235226
fields_accessor accessor;
236227
std::size_t source_position;
237228

238-
STDEXEC_ATTRIBUTE((nodiscard, host, device))
239-
float gaussian_pulse(float t, float t_0, float tau) const {
229+
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float gaussian_pulse(float t, float t_0, float tau) const {
240230
return exp(-(((t - t_0) / tau) * (t - t_0) / tau));
241231
}
242232

243-
STDEXEC_ATTRIBUTE((nodiscard, host, device))
244-
float calculate_source(float t, float frequency) const {
233+
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float calculate_source(float t, float frequency) const {
245234
const float tau = 0.5f / frequency;
246235
const float t_0 = 6.0f * tau;
247236
return gaussian_pulse(t, t_0, tau);
248237
}
249238

250-
STDEXEC_ATTRIBUTE((always_inline, host, device))
251-
void
252-
operator()(std::size_t cell_id) const {
239+
STDEXEC_ATTRIBUTE((always_inline, host, device)) void operator()(std::size_t cell_id) const {
253240
const std::size_t N = accessor.n;
254241
const std::size_t column = cell_id % N;
255242
const std::size_t row = cell_id / N;
@@ -364,8 +351,8 @@ class result_dumper_t {
364351

365352
void operator()(bool update_time = true) const {
366353
int rank_ = 0;
367-
const std::string filename = std::string("output_") + std::to_string(rank_) + "_"
368-
+ std::to_string(0) + ".vtk";
354+
const std::string filename =
355+
std::string("output_") + std::to_string(rank_) + "_" + std::to_string(0) + ".vtk";
369356

370357
write_vtk(filename);
371358
}

examples/nvexec/maxwell/snr.cuh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS { //
148148
struct operation_state_t : operation_state_base_t<ReceiverId> {
149149
using PredSender = stdexec::__t<PredecessorSenderId>;
150150
using Receiver = stdexec::__t<ReceiverId>;
151-
using Scheduler =
152-
std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
153-
using InnerSender =
154-
std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
151+
using Scheduler = std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
152+
using InnerSender = std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
155153

156154
using predecessor_op_state_t =
157155
ex::connect_result_t<PredSender, receiver_1_t<operation_state_t>>;
@@ -167,8 +165,7 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS { //
167165
friend void tag_invoke(stdexec::start_t, operation_state_t& op) noexcept {
168166
if (op.stream_provider_.status_ != cudaSuccess) {
169167
// Couldn't allocate memory for operation state, complete with error
170-
op.propagate_completion_signal(
171-
stdexec::set_error, std::move(op.stream_provider_.status_));
168+
op.propagate_completion_signal(stdexec::set_error, std::move(op.stream_provider_.status_));
172169
} else {
173170
if (op.n_) {
174171
stdexec::start(*op.pred_op_state_);
@@ -180,9 +177,9 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS { //
180177

181178
operation_state_t(PredSender&& pred_sender, Closure closure, Receiver&& rcvr, std::size_t n)
182179
: operation_state_base_t<ReceiverId>(
183-
static_cast<Receiver&&>(rcvr),
184-
stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(pred_sender))
185-
.context_state_)
180+
static_cast<Receiver&&>(rcvr),
181+
stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(pred_sender))
182+
.context_state_)
186183
, pred_sender_{static_cast<PredSender&&>(pred_sender)}
187184
, closure_(closure)
188185
, n_(n) {
@@ -290,10 +287,8 @@ namespace repeat_n_detail {
290287
struct operation_state_t {
291288
using PredSender = stdexec::__t<PredecessorSenderId>;
292289
using Receiver = stdexec::__t<ReceiverId>;
293-
using Scheduler =
294-
std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
295-
using InnerSender =
296-
std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
290+
using Scheduler = std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
291+
using InnerSender = std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
297292

298293
using predecessor_op_state_t =
299294
ex::connect_result_t<PredSender, receiver_1_t<operation_state_t>>;
@@ -395,7 +390,11 @@ struct repeat_n_t {
395390
template <stdexec::__sender_adaptor_closure Closure>
396391
auto operator()(std::size_t n, Closure closure) const
397392
-> stdexec::__binder_back<repeat_n_t, std::size_t, Closure> {
398-
return {{n, static_cast<Closure&&>(closure)}, {}, {}};
393+
return {
394+
{n, static_cast<Closure&&>(closure)},
395+
{},
396+
{}
397+
};
399398
}
400399
};
401400

examples/nvexec/maxwell_distributed.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ namespace distributed {
8888
, begin(grid_begin)
8989
, end(grid_end)
9090
, own_cells(end - begin)
91-
, fields_(device_alloc<float>(
92-
static_cast<std::size_t>(own_cells + n * 2) * static_cast<int>(field_id::fields_count))) {
91+
, fields_(
92+
device_alloc<float>(
93+
static_cast<std::size_t>(own_cells + n * 2)
94+
* static_cast<int>(field_id::fields_count))) {
9395
}
9496

9597
[[nodiscard]]

examples/scope.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ int main() {
8484
//
8585
sender auto printFortyTwo = then(
8686
std::move(fortyTwoFuture),
87-
[](int fortyTwo) noexcept { // 9
88-
printf("%d\n", fortyTwo); //
89-
}); //
90-
//
87+
[](int fortyTwo) noexcept { // 9
88+
printf("%d\n", fortyTwo); //
89+
}); //
90+
//
9191
sender auto allDone = then( //
9292
when_all(printEmpty, std::move(printFortyTwo)), //
9393
[](auto&&...) noexcept { printf("\nall done\n"); }); // 10

0 commit comments

Comments
 (0)