Skip to content
Snippets Groups Projects
Commit f1f4bb85 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Experiment parallel communication to dispatch read mesh

parent 8657417c
Branches
Tags
1 merge request!11Feature/mpi
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include <Messenger.hpp> #include <Messenger.hpp>
#include <Partitioner.hpp> #include <Partitioner.hpp>
#include <ArrayUtils.hpp>
#include <map> #include <map>
#include <regex> #include <regex>
#include <iomanip> #include <iomanip>
...@@ -175,7 +177,52 @@ void GmshReader::_dispatch() ...@@ -175,7 +177,52 @@ void GmshReader::_dispatch()
pout() << "Mesh read by process " << rang::style::bold << reader_rank << rang::style::reset << '\n'; pout() << "Mesh read by process " << rang::style::bold << reader_rank << rang::style::reset << '\n';
Partitioner P; Partitioner P;
Array<int> cell_new_owner = broadcast(P.partition(mesh_graph), reader_rank); Array<int> cell_new_owner = P.partition(mesh_graph);
Array<int> nb_cell_to_send_by_proc(commSize());
for (size_t i=0; i<cell_new_owner.size(); ++i) {
nb_cell_to_send_by_proc[cell_new_owner[i]]++;
}
// for (int i_rank=0; i_rank<commSize(); ++i_rank) {
// if (commRank() == i_rank) {
// for (size_t i_recv=0; i_recv<commSize(); ++i_recv) {
// std::cout << commRank()
// << " gives " << nb_cell_to_send_by_proc[i_recv]
// << " cells to " << i_recv << '\n' << std::flush;
// }
// }
// barrier();
// }
Array<int> nb_cell_to_recv_by_proc = allToAll(nb_cell_to_send_by_proc);
// for (int i_rank=0; i_rank<commSize(); ++i_rank) {
// if (commRank() == i_rank) {
// for (size_t i_send=0; i_send<commSize(); ++i_send) {
// std::cout << commRank()
// << " recv " << nb_cell_to_recv_by_proc[i_send]
// << " cells of " << i_send << '\n';
// }
// }
// barrier();
// }
const size_t cell_number = mesh.numberOfCells();
const size_t new_cell_number
= cell_number
+ Sum(nb_cell_to_recv_by_proc)
- Sum(nb_cell_to_send_by_proc);
std::cout << commRank() << ": " << cell_number << " -> " << new_cell_number << " cells\n";
// now share owner table
cell_new_owner = broadcast(cell_new_owner, reader_rank);
Array<int> cell_new_owner_nb_cell(commSize());
cell_new_owner_nb_cell.fill(0);
for (size_t i=0; i<cell_new_owner.size(); ++i) {
cell_new_owner_nb_cell[cell_new_owner[i]]++;
}
Array<int> node_new_owner(mesh.numberOfNodes()); Array<int> node_new_owner(mesh.numberOfNodes());
if (commRank() == reader_rank) { if (commRank() == reader_rank) {
...@@ -197,17 +244,15 @@ void GmshReader::_dispatch() ...@@ -197,17 +244,15 @@ void GmshReader::_dispatch()
for (int i_rank=0; i_rank<commSize(); ++i_rank) { for (int i_rank=0; i_rank<commSize(); ++i_rank) {
if (commRank() == i_rank) { if (commRank() == i_rank) {
size_t cpt=0;
std::cout << i_rank << " cells -> "; std::cout << i_rank << " cells -> ";
for (size_t i=0; i<cell_new_owner.size(); ++i) { for (size_t i=0; i<cell_new_owner.size(); ++i) {
if (commRank() == cell_new_owner[i]) { if (commRank() == cell_new_owner[i]) {
std::cout << i << ' '; std::cout << i << ' ';
cpt++;
} }
} }
std::cout << " [" << cpt << "]\n" << std::flush; std::cout << " [" << cell_new_owner_nb_cell[i_rank] << "]\n" << std::flush;
} }
barrier(); // barrier();
} }
for (int i_rank=0; i_rank<commSize(); ++i_rank) { for (int i_rank=0; i_rank<commSize(); ++i_rank) {
...@@ -222,7 +267,20 @@ void GmshReader::_dispatch() ...@@ -222,7 +267,20 @@ void GmshReader::_dispatch()
} }
std::cout << " [" << cpt << "]\n" << std::flush; std::cout << " [" << cpt << "]\n" << std::flush;
} }
barrier(); // barrier();
}
for (int i_rank=0; i_rank<commSize(); ++i_rank) {
if (commRank() == i_rank) {
const auto cell_type
= mesh.connectivity().cellType();
std::cout << i_rank << " cell_type -> ";
for (CellId j=0; j<cell_type.size(); ++j) {
std::cout << static_cast<int>(cell_type[j]) << ' ';
}
std::cout << '\n';
}
// barrier();
} }
Messenger::destroy(); Messenger::destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment