335 {
336 int provided = MPI_THREAD_SINGLE;
338 if (provided < MPI_THREAD_MULTIPLE) {
341 "shared_tile_counter needs MPI initialised with MPI_THREAD_MULTIPLE"
342 )
343 );
344 }
345 auto state = std::make_unique<shared_state>();
346 state->comm = comm;
348 auto const bytes = state->rank == 0 ? static_cast<MPI_Aint>(sizeof(uint64_t)) : 0;
351 MPI_Win_allocate(
352 bytes, sizeof(uint64_t), MPI_INFO_NULL, comm, &state->count, &state->window
353 ),
354 "MPI_Win_allocate"
355 )
356 );
358 state->locked = true;
359 if (state->rank == 0) {
360 *state->count = 0;
363 detail::mpi_try(MPI_Comm_dup(MPI_COMM_SELF, &state->progress_comm),
"MPI_Comm_dup")
364 );
365
366
368 state->progress =
369 std::jthread([comm = state->progress_comm](const std::stop_token& stop) {
370 while (!stop.stop_requested()) {
371 int flag = 0;
372 MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &flag, MPI_STATUS_IGNORE);
373 std::this_thread::yield();
374 }
375 });
376 }
377 }
380 counter.state_ = std::move(state);
382 }
__host__ shared_tile_counter(shared_tile_counter &&other) noexcept
#define CUDDL_TRY(expr)
Propagates a cuddl::Result failure from the enclosing function (GNU statement expression).
constexpr bool ablated(std::string_view) noexcept
Always false: this build compiles the ablation switches out.
Result< void > mpi_try(int status, char const *call)
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
static Error invalid_argument(std::string message)
static Result ok(T value)