Skip to content

Commit

Permalink
Merge pull request #1453 from ericniebler/clang-format-20
Browse files Browse the repository at this point in the history
reformat with clang-format-20
  • Loading branch information
ericniebler authored Dec 19, 2024
2 parents 184a8ab + 3bf6e4c commit ac27beb
Show file tree
Hide file tree
Showing 146 changed files with 926 additions and 1,355 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: [
'STDEXEC_SYSTEM_CONTEXT_INLINE'
STDEXEC_SYSTEM_CONTEXT_INLINE
]
BinPackArguments: false
BinPackParameters: false
Expand Down Expand Up @@ -86,7 +86,7 @@ Macros: [
'STDEXEC_MEMFN_DECL(X)=X',
'STDEXEC_MEMFN_DECL(X,Y)=X,Y',
'STDEXEC_MEMFN_DECL(X,Y,Z)=X,Y,Z',
'STDEXEC_ATTRIBUTE(X)=__attribute__(X) //',
'STDEXEC_ATTRIBUTE(X)=[[]]',
'STDEXEC_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
'STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
'STDEXEC_MISSING_MEMBER(X,Y)=true',
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ ab2a3baef655db23fb7ec11ce7ec49575bbd2807

# Reformat everything with clang-format-18
413749037ac3cd2f66a476fdd593e54e3b4b60b7

# Reformat everything with clang-format-20
aee392a046a26ae2340849fe98e38332d9537397
13 changes: 6 additions & 7 deletions examples/algorithms/retry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ struct _retry_sender {
using _value = stdexec::completion_signatures<stdexec::set_value_t(Ts...)>;

template <class Env>
auto get_completion_signatures(Env&&) const
-> stdexec::transform_completion_signatures_of<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
auto get_completion_signatures(Env&&) const -> stdexec::transform_completion_signatures_of<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
return {};
}

Expand Down
5 changes: 3 additions & 2 deletions examples/benchmark/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ void my_main(int argc, char** argv, exec::numa_policy policy = exec::get_numa_po
std::size_t buffer_size = 2000 << 20;
for (std::size_t i = 0; i < static_cast<std::size_t>(nthreads); ++i) {
exec::numa_allocator<char> alloc(policy.thread_index_to_node(i));
buffers.push_back(std::unique_ptr<char, numa_deleter>{
alloc.allocate(buffer_size), numa_deleter{buffer_size, alloc}
buffers.push_back(
std::unique_ptr<char, numa_deleter>{
alloc.allocate(buffer_size), numa_deleter{buffer_size, alloc}
});
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions examples/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ using stdexec::sync_wait;
int main() {
exec::numa_policy numa{exec::no_numa_policy{}};
exec::static_thread_pool ctx{8};
scheduler auto sch = ctx.get_scheduler(); // 1
//
sender auto begin = schedule(sch); // 2
scheduler auto sch = ctx.get_scheduler(); // 1
//
sender auto begin = schedule(sch); // 2
sender auto hi_again = then( // 3
begin, // 3
[] { // 3
std::cout << "Hello world! Have an int.\n"; // 3
return 13; // 3
}); // 3
//
//
sender auto add_42 = then(hi_again, [](int arg) { return arg + 42; }); // 4
auto [i] = sync_wait(std::move(add_42)).value(); // 5
std::cout << "Result: " << i << std::endl;
Expand Down
82 changes: 43 additions & 39 deletions examples/io_uring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,45 @@ int main() {
auto scheduler2 = context2.get_scheduler();
using namespace std::chrono_literals;

stdexec::sync_wait(exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));

stdexec::sync_wait(exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 1, stopped.\n"; }),
exec::schedule_after(scheduler2, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));

stdexec::sync_wait(stdexec::when_all(
stdexec::schedule(scheduler) | stdexec::then([] { std::cout << "Hello, 0!\n"; }),
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; }),
exec::schedule_after(scheduler, 3s) | stdexec::then([] { std::cout << "Stop it!\n"; }),
exec::finally(exec::schedule_after(scheduler2, 4s), stdexec::just() | stdexec::then([&] {
context.request_stop();
})),
exec::finally(exec::schedule_after(scheduler, 4s), stdexec::just() | stdexec::then([&] {
context2.request_stop();
})),
exec::schedule_after(scheduler, 10s) //
| stdexec::then([] { //
std::cout << "Hello, world!\n"; //
}) //
| stdexec::upon_stopped([] { //
std::cout << "Hello, stopped.\n"; //
}), //
exec::schedule_after(scheduler2, 10s) //
| stdexec::then([] { //
std::cout << "Hello, world!\n"; //
}) //
| stdexec::upon_stopped([] { //
std::cout << "Hello, stopped.\n"; //
}))); //
stdexec::sync_wait(
exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));

stdexec::sync_wait(
exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 1, stopped.\n"; }),
exec::schedule_after(scheduler2, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })
| stdexec::upon_stopped([] { std::cout << "Hello, 2, stopped.\n"; })));

stdexec::sync_wait(
stdexec::when_all(
stdexec::schedule(scheduler) | stdexec::then([] { std::cout << "Hello, 0!\n"; }),
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler2, 2s) | stdexec::then([] { std::cout << "Hello, 2!\n"; }),
exec::schedule_after(scheduler, 3s) | stdexec::then([] { std::cout << "Stop it!\n"; }),
exec::finally(exec::schedule_after(scheduler2, 4s), stdexec::just() | stdexec::then([&] {
context.request_stop();
})),
exec::finally(exec::schedule_after(scheduler, 4s), stdexec::just() | stdexec::then([&] {
context2.request_stop();
})),
exec::schedule_after(scheduler, 10s) //
| stdexec::then([] { //
std::cout << "Hello, world!\n"; //
}) //
| stdexec::upon_stopped([] { //
std::cout << "Hello, stopped.\n"; //
}), //
exec::schedule_after(scheduler2, 10s) //
| stdexec::then([] { //
std::cout << "Hello, world!\n"; //
}) //
| stdexec::upon_stopped([] { //
std::cout << "Hello, stopped.\n"; //
}))); //
io_thread.join();
io_thread2.join();

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

while (!context.is_running())
;
stdexec::sync_wait(exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })));
stdexec::sync_wait(
exec::when_any(
exec::schedule_after(scheduler, 1s) | stdexec::then([] { std::cout << "Hello, 1!\n"; }),
exec::schedule_after(scheduler, 500ms) | stdexec::then([] { std::cout << "Hello, 2!\n"; })));

auto time_point = std::chrono::steady_clock::now() + 1s;
stdexec::sync_wait(exec::schedule_at(scheduler, time_point) | stdexec::then([] {
Expand Down
51 changes: 19 additions & 32 deletions examples/nvexec/maxwell/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ struct deleter_t {
};

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

#if defined(_NVHPC_CUDA) || defined(__CUDACC__)
Expand Down Expand Up @@ -90,8 +89,7 @@ struct fields_accessor {

float *base_ptr;

STDEXEC_ATTRIBUTE((nodiscard, host, device))
float *get(field_id id) const {
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float *get(field_id id) const {
return base_ptr + static_cast<int>(id) * cells;
}
};
Expand All @@ -111,9 +109,10 @@ struct grid_t {
grid_t(std::size_t n, bool gpu)
: n(n)
, cells(n * n)
, fields_(allocate_on<float>(
gpu,
static_cast<std::size_t>(cells) * static_cast<int>(field_id::fields_count))) {
, fields_(
allocate_on<float>(
gpu,
static_cast<std::size_t>(cells) * static_cast<int>(field_id::fields_count))) {
}

[[nodiscard]]
Expand All @@ -124,8 +123,8 @@ struct grid_t {

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

STDEXEC_ATTRIBUTE((host, device))
inline bool is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
STDEXEC_ATTRIBUTE((host, device)) inline bool
is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
const float os2 = object_size * object_size;
return ((x - object_x) * (x - object_x) + (y - object_y) * (y - object_y) <= os2);
}
Expand All @@ -139,9 +138,7 @@ struct grid_initializer_t {
float dt;
fields_accessor accessor;

STDEXEC_ATTRIBUTE((host, device))
void
operator()(std::size_t cell_id) const {
STDEXEC_ATTRIBUTE((host, device)) void operator()(std::size_t cell_id) const {
const std::size_t row = cell_id / accessor.n;
const std::size_t column = cell_id % accessor.n;

Expand Down Expand Up @@ -184,32 +181,26 @@ inline grid_initializer_t grid_initializer(float dt, fields_accessor accessor) {
return {dt, accessor};
}

STDEXEC_ATTRIBUTE((host, device))
inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
STDEXEC_ATTRIBUTE((host, device)) inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
return col == N - 1 ? cell_id - (N - 1) : cell_id + 1;
}

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

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

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

struct h_field_calculator_t {
fields_accessor accessor;

STDEXEC_ATTRIBUTE((always_inline, host, device))
void
operator()(std::size_t cell_id) const {
STDEXEC_ATTRIBUTE((always_inline, host, device)) void operator()(std::size_t cell_id) const {
const std::size_t N = accessor.n;
const std::size_t column = cell_id % N;
const std::size_t row = cell_id / N;
Expand All @@ -235,21 +226,17 @@ struct e_field_calculator_t {
fields_accessor accessor;
std::size_t source_position;

STDEXEC_ATTRIBUTE((nodiscard, host, device))
float gaussian_pulse(float t, float t_0, float tau) const {
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float gaussian_pulse(float t, float t_0, float tau) const {
return exp(-(((t - t_0) / tau) * (t - t_0) / tau));
}

STDEXEC_ATTRIBUTE((nodiscard, host, device))
float calculate_source(float t, float frequency) const {
STDEXEC_ATTRIBUTE((nodiscard, host, device)) float calculate_source(float t, float frequency) const {
const float tau = 0.5f / frequency;
const float t_0 = 6.0f * tau;
return gaussian_pulse(t, t_0, tau);
}

STDEXEC_ATTRIBUTE((always_inline, host, device))
void
operator()(std::size_t cell_id) const {
STDEXEC_ATTRIBUTE((always_inline, host, device)) void operator()(std::size_t cell_id) const {
const std::size_t N = accessor.n;
const std::size_t column = cell_id % N;
const std::size_t row = cell_id / N;
Expand Down Expand Up @@ -364,8 +351,8 @@ class result_dumper_t {

void operator()(bool update_time = true) const {
int rank_ = 0;
const std::string filename = std::string("output_") + std::to_string(rank_) + "_"
+ std::to_string(0) + ".vtk";
const std::string filename =
std::string("output_") + std::to_string(rank_) + "_" + std::to_string(0) + ".vtk";

write_vtk(filename);
}
Expand Down
27 changes: 13 additions & 14 deletions examples/nvexec/maxwell/snr.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS { //
struct operation_state_t : operation_state_base_t<ReceiverId> {
using PredSender = stdexec::__t<PredecessorSenderId>;
using Receiver = stdexec::__t<ReceiverId>;
using Scheduler =
std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
using InnerSender =
std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
using Scheduler = std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
using InnerSender = std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;

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

operation_state_t(PredSender&& pred_sender, Closure closure, Receiver&& rcvr, std::size_t n)
: operation_state_base_t<ReceiverId>(
static_cast<Receiver&&>(rcvr),
stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(pred_sender))
.context_state_)
static_cast<Receiver&&>(rcvr),
stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(pred_sender))
.context_state_)
, pred_sender_{static_cast<PredSender&&>(pred_sender)}
, closure_(closure)
, n_(n) {
Expand Down Expand Up @@ -290,10 +287,8 @@ namespace repeat_n_detail {
struct operation_state_t {
using PredSender = stdexec::__t<PredecessorSenderId>;
using Receiver = stdexec::__t<ReceiverId>;
using Scheduler =
std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
using InnerSender =
std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;
using Scheduler = std::invoke_result_t<stdexec::get_scheduler_t, stdexec::env_of_t<Receiver>>;
using InnerSender = std::invoke_result_t<Closure, stdexec::schedule_result_t<Scheduler>>;

using predecessor_op_state_t =
ex::connect_result_t<PredSender, receiver_1_t<operation_state_t>>;
Expand Down Expand Up @@ -395,7 +390,11 @@ struct repeat_n_t {
template <stdexec::__sender_adaptor_closure Closure>
auto operator()(std::size_t n, Closure closure) const
-> stdexec::__binder_back<repeat_n_t, std::size_t, Closure> {
return {{n, static_cast<Closure&&>(closure)}, {}, {}};
return {
{n, static_cast<Closure&&>(closure)},
{},
{}
};
}
};

Expand Down
6 changes: 4 additions & 2 deletions examples/nvexec/maxwell_distributed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ namespace distributed {
, begin(grid_begin)
, end(grid_end)
, own_cells(end - begin)
, fields_(device_alloc<float>(
static_cast<std::size_t>(own_cells + n * 2) * static_cast<int>(field_id::fields_count))) {
, fields_(
device_alloc<float>(
static_cast<std::size_t>(own_cells + n * 2)
* static_cast<int>(field_id::fields_count))) {
}

[[nodiscard]]
Expand Down
8 changes: 4 additions & 4 deletions examples/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ int main() {
//
sender auto printFortyTwo = then(
std::move(fortyTwoFuture),
[](int fortyTwo) noexcept { // 9
printf("%d\n", fortyTwo); //
}); //
//
[](int fortyTwo) noexcept { // 9
printf("%d\n", fortyTwo); //
}); //
//
sender auto allDone = then( //
when_all(printEmpty, std::move(printFortyTwo)), //
[](auto&&...) noexcept { printf("\nall done\n"); }); // 10
Expand Down
Loading

0 comments on commit ac27beb

Please sign in to comment.