10#ifdef MOOSE_MFEM_ENABLED
37 int owner(std::int64_t g)
const;
38 std::int64_t
begin(
int rank)
const;
39 std::int64_t
end(
int rank)
const;
40 std::int64_t
size()
const {
return _n; }
52template <
typename T,
typename DestinationFn>
56 DestinationFn destination,
57 std::vector<int> & counts)
61 std::vector<int> destinations(items.size());
62 counts.assign(nprocs, 0);
63 for (
const auto i : index_range(items))
64 counts[destinations[i] = destination(items[i])]++;
66 std::vector<int> offset(nprocs, 0);
67 std::partial_sum(counts.begin(), counts.end() - 1, offset.begin() + 1);
69 std::vector<T> grouped(items.size());
70 for (
const auto i : index_range(items))
71 grouped[offset[destinations[i]]++] = items[i];
82allToAll(
const std::vector<T> & send,
const std::vector<int> & send_counts, MPI_Comm comm)
85 MPI_Comm_size(comm, &nprocs);
87 std::vector<int> recv_counts(nprocs);
88 MPI_Alltoall(send_counts.data(), 1, MPI_INT, recv_counts.data(), 1, MPI_INT, comm);
90 std::vector<int> send_displs(nprocs, 0), recv_displs(nprocs, 0);
91 std::partial_sum(send_counts.begin(), send_counts.end() - 1, send_displs.begin() + 1);
92 std::partial_sum(recv_counts.begin(), recv_counts.end() - 1, recv_displs.begin() + 1);
94 std::vector<T> recv(
static_cast<std::size_t
>(recv_displs.back()) + recv_counts.back());
98 MPI_Datatype item_type;
99 MPI_Type_contiguous(
sizeof(T), MPI_BYTE, &item_type);
100 MPI_Type_commit(&item_type);
101 MPI_Alltoallv(send.data(),
110 MPI_Type_free(&item_type);
157 std::int64_t num_labels,
159 std::vector<int> * selected,
160 std::vector<std::int64_t> * owned_labels =
nullptr);
167std::vector<std::int64_t>
fetchLabels(
const std::vector<std::int64_t> & queries,
168 const std::vector<std::int64_t> & owned_labels,
169 const BlockDistribution & dist,
Block distribution of a dense global index range [0, n) over the ranks of a communicator: rank r owns...
std::int64_t size() const
std::int64_t begin(int rank) const
int _nprocs
Number of ranks the ids are distributed over.
std::int64_t end(int rank) const
int owner(std::int64_t g) const
Owning rank of global id g, which must lie in [0, n).
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
void distributedSpanningForest(std::vector< DistributedEdge > &edges, std::int64_t num_labels, MPI_Comm comm, std::vector< int > *selected, std::vector< std::int64_t > *owned_labels=nullptr)
Distributed Boruvka over the edges held collectively by the ranks of comm.
std::vector< std::int64_t > fetchLabels(const std::vector< std::int64_t > &queries, const std::vector< std::int64_t > &owned_labels, const BlockDistribution &dist, MPI_Comm comm)
Final component representative of each id in queries, looked up from the distributed label array.
std::vector< T > groupByDestination(const std::vector< T > &items, int nprocs, DestinationFn destination, std::vector< int > &counts)
Group items by the destination rank returned by destination, so they can be handed to allToAll.
std::vector< T > allToAll(const std::vector< T > &send, const std::vector< int > &send_counts, MPI_Comm comm)
MPI_Alltoallv over a trivially copyable payload.
An undirected edge of the distributed vertex graph.
int origin_rank
Rank that owns this edge and its index in that rank's edge array, so a selected edge can be routed ba...
bool operator<(const DistributedEdge &o) const
Total order on the (unique) weights, giving Kruskal's processing order.
std::int64_t u
Current component label of each endpoint.
std::int64_t wu
Weight: original canonical endpoint ids, wu < wv. Unique across the graph.