69void MetisGraphGather::
73 MPI_Comm comm = _getMPICommunicator(m_parallel_mng);
74 info() <<
"Metis: gather graph";
76 const Int32 io_rank = m_parallel_mng->masterIORank();
77 const Int32 nb_rank = m_nb_rank;
78 const bool is_master_io = m_parallel_mng->isMasterIO();
87 if (m_my_rank == io_rank) {
89 graph.have_vsize = my_graph.have_vsize;
90 graph.have_adjwgt = my_graph.have_adjwgt;
92 graph.nb_vertices = 0;
93 graph.have_vsize =
false;
94 graph.have_adjwgt =
false;
100 if (m_my_rank == io_rank) {
102 buffer.
resize(2 * nb_rank);
105 my_buffer[0] = my_graph.nb_vertices;
106 my_buffer[1] = my_graph.adjncy.
size();
108 MPI_Gather((
void*)my_buffer.
data(), 2, MPI_INT, (
void*)buffer.
data(), 2, MPI_INT, io_rank, comm);
115 for (
int rank = 0; rank < nb_rank; ++rank) {
116 nb_vertices_per_rank[rank] = buffer[2 * rank];
117 adjncy_size_per_rank[rank] = buffer[2 * rank + 1];
118 nb_vertice_cons_per_rank[rank] = nb_vertices_per_rank[rank] * ncon;
119 adjcny_size += adjncy_size_per_rank[rank];
125 int max_buffer_size = my_graph.nb_vertices * ncon;
126 max_buffer_size = std::max(my_graph.adjncy.
size(), max_buffer_size);
127 my_buffer.
resize(max_buffer_size);
129 max_buffer_size = graph.nb_vertices * ncon;
130 max_buffer_size = std::max(adjcny_size, max_buffer_size);
131 buffer.
resize(max_buffer_size);
138 for (
int rank = 1; rank < nb_rank; ++rank) {
139 offset[rank] = offset[rank - 1] + adjncy_size_per_rank[rank - 1];
141 graph.adjncy.
resize(adjcny_size);
144 _convertVector(my_graph.adjncy.
size(), my_graph.adjncy.
constView(), my_buffer.
view());
146 MPI_Gatherv(my_buffer.
data(), my_graph.adjncy.
size(), MPI_INT,
147 buffer.
data(), adjncy_size_per_rank.
data(),
148 offset.
data(), MPI_INT, io_rank, comm);
150 _convertVector(adjcny_size, buffer.
constView(), graph.adjncy.
view());
154 if (my_graph.have_adjwgt) {
156 graph.adjwgt.
resize(adjcny_size);
159 _convertVector(my_graph.adjwgt.
size(), my_graph.adjwgt.
constView(), my_buffer.
view());
161 MPI_Gatherv(my_buffer.
data(), my_graph.adjwgt.
size(), MPI_INT,
162 buffer.
data(), adjncy_size_per_rank.
data(),
163 offset.
data(), MPI_INT, io_rank, comm);
165 _convertVector(adjcny_size, buffer.
constView(), graph.adjwgt.
view());
174 graph.xadj.
resize(graph.nb_vertices + 1);
175 graph.xadj[graph.nb_vertices] = graph.adjncy.
size();
177 for (
int rank = 1; rank < nb_rank; ++rank) {
178 offset[rank] = offset[rank - 1] + nb_vertices_per_rank[rank - 1];
182 _convertVector(my_graph.nb_vertices, my_graph.xadj.
constView(), my_buffer.
view());
184 MPI_Gatherv(my_buffer.
data(), my_graph.nb_vertices, MPI_INT,
185 buffer.
data(), nb_vertices_per_rank.
data(),
186 offset.
data(), MPI_INT, io_rank, comm);
188 _convertVector(graph.nb_vertices, buffer.
constView(), graph.xadj.
view());
193 int start_adjncy_index = 0;
194 for (
int rank = 1; rank < nb_rank; ++rank) {
195 start_adjncy_index += adjncy_size_per_rank[rank-1];
199 for (
Int32 ixadj = vtxdist_rank; ixadj < vtxdist_rank_plus_one; ++ixadj) {
200 graph.xadj[ixadj] += start_adjncy_index;
207 if (my_graph.have_vsize) {
209 graph.vsize.
resize(graph.nb_vertices);
212 _convertVector(my_graph.nb_vertices, my_graph.vsize.
constView(), my_buffer.
view());
214 MPI_Gatherv(my_buffer.
data(), my_graph.nb_vertices, MPI_INT,
215 buffer.
data(), nb_vertices_per_rank.
data(),
216 offset.
data(), MPI_INT, io_rank, comm);
218 _convertVector(graph.nb_vertices, buffer.
constView(), graph.vsize.
view());
224 graph.part.
resize(graph.nb_vertices);
229 _convertVector(my_graph.nb_vertices, my_graph.part.
constView(), my_buffer.
view());
231 MPI_Gatherv(my_buffer.
data(), my_graph.nb_vertices, MPI_INT,
232 buffer.
data(), nb_vertices_per_rank.
data(),
233 offset.
data(), MPI_INT, io_rank, comm);
235 _convertVector(graph.nb_vertices, buffer.
constView(), graph.part.
view());
241 graph.vwgt.
resize(graph.nb_vertices * ncon);
242 for (
auto& x : offset) {
247 _convertVector(my_graph.nb_vertices * ncon, my_graph.vwgt.
constView(), my_buffer.
view());
249 MPI_Gatherv(my_buffer.
data(), my_graph.nb_vertices * ncon, MPI_INT,
250 buffer.
data(), nb_vertice_cons_per_rank.
data(),
251 offset.
data(), MPI_INT, io_rank, comm);
253 _convertVector(graph.nb_vertices * ncon, buffer.
constView(), graph.vwgt.
view());