37#ifdef BERTINI2_HAVE_MPI
62template<
typename TaskT,
typename ResultT>
65 std::function<
void(TaskT
const&)> track_fn,
66 std::function<ResultT(TaskT
const&)> pack_fn)
82 ResultT result = pack_fn(task);
83 mpi_send_serialized(comm, 0,
TAG_RESULT, result);
115template<
typename TaskT,
typename ResultT,
typename StateFactory,
typename TrackFn>
116void RunWorkerLoopThreaded(
118 StateFactory state_factory,
122 int capacity = n_threads;
128 bool got_sentinel =
false;
130 while (!got_sentinel || in_flight > 0)
132 bool did_work =
false;
135 while (
auto opt = pool.try_collect())
137 mpi_send_serialized(comm, 0,
TAG_RESULT, *opt);
157 pool.submit(std::move(task));
167 std::this_thread::sleep_for(std::chrono::microseconds(200));
Thread pool for parallel path tracking within a single MPI worker rank.
Definition thread_pool.hpp:198
Single include point for the MPI C API.
Serialization-aware MPI send/recv helpers using plain C MPI + Boost.Serialization.
bool is_sentinel(std::size_t v)
Query whether a plain index value is the sentinel.
Definition path_result.hpp:186
Definition initialize_finalize.hpp:43
constexpr int TAG_CAPACITY
MPI message tag: worker -> manager, max tasks in flight on that rank.
Definition path_result.hpp:49
constexpr int TAG_RESULT
MPI message tag: worker -> manager result.
Definition path_result.hpp:48
constexpr int TAG_WORK_ITEM
MPI message tag: manager -> worker work item.
Definition path_result.hpp:47
Definition algorithm_builder.hpp:36
Result struct used in the manager-worker MPI protocol for ZeroDim.
Thread-safe queue and worker thread pool for MPI+thread hybrid parallelism.