#include "ep_lib.hpp" #include #include "ep_declaration.hpp" #include "ep_mpi.hpp" namespace ep_lib { int MPI_Barrier(MPI_Comm comm) { if(comm->is_intercomm) return MPI_Barrier_intercomm(comm); if(comm->is_ep) { return MPI_Barrier_intracomm(comm); } return MPI_Barrier_mpi(comm); } int MPI_Barrier_intracomm(MPI_Comm comm) { int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; MPI_Barrier_local(comm); if(ep_rank_loc == 0) { ::MPI_Comm mpi_comm = to_mpi_comm(comm->mpi_comm); ::MPI_Barrier(mpi_comm); } MPI_Barrier_local(comm); return 0; } int MPI_Barrier2(MPI_Comm comm) { int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; MPI_Barrier_local(comm); if(ep_rank_loc == 0) { ::MPI_Comm mpi_comm = to_mpi_comm(comm->mpi_comm); ::MPI_Barrier(mpi_comm); } MPI_Barrier_local(comm); return 0; } int MPI_Barrier_intercomm(MPI_Comm comm) { MPI_Barrier_local(comm); if(comm->ep_comm_ptr->intercomm->size_rank_info[1].first == 0) ::MPI_Barrier(to_mpi_comm(comm->ep_comm_ptr->intercomm->mpi_inter_comm)); MPI_Barrier_local(comm); } int MPI_Barrier_mpi(MPI_Comm comm) { return ::MPI_Barrier(to_mpi_comm(comm->mpi_comm)); } int MPI_Barrier_local(MPI_Comm comm) { comm->ep_barrier->wait(); } }