Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions include/samurai/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@
namespace mpi = boost::mpi;
#endif

#ifdef SAMURAI_WITH_MPI
// Résolution d'un bug : S'il y a trop de rangs MPI et un min_level trop faible, alors il est parfois
// impossible de décomposer le problème (--> segfault). Il faut alors imposer un min_level limite le temps d'un fix
bool is_invalid_mpi_size(std::size_t min_level)
{
boost::mpi::communicator world;
int mpi_size = world.size();

// à vérifier :
// - en 1d ?
return (mpi_size > std::pow(2, min_level));
}

void validate_mpi_min_level(std::size_t min_level)
{
if (is_invalid_mpi_size(min_level))
{
std::cerr << "ERROR: MPI size (" << boost::mpi::communicator().size() << ") is too large for min_level = " << min_level
<< ". Please ensure that mpi_size <= 2^min_level." << std::endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
}
#endif

namespace samurai
{

Expand Down Expand Up @@ -246,6 +270,7 @@ namespace samurai
#ifdef SAMURAI_WITH_MPI
partition_mesh(start_level, b);
// load_balancing();
validate_mpi_min_level(min_level);
#else
this->m_cells[mesh_id_t::cells][start_level] = {start_level, b, approx_box_tol, scaling_factor_};
#endif
Expand Down Expand Up @@ -277,6 +302,8 @@ namespace samurai
#ifdef SAMURAI_WITH_MPI
partition_mesh(start_level, b);
// load_balancing();

validate_mpi_min_level(min_level);
#else
this->m_cells[mesh_id_t::cells][start_level] = {start_level, b, approx_box_tol, scaling_factor_};
#endif
Expand Down
Loading