Newer
Older
#ifndef INC_4NEURO_MPIWRAPPER_H
#define INC_4NEURO_MPIWRAPPER_H
#include <mpi.h>
namespace lib4neuro{
extern int mpi_rank;
extern int mpi_nranks;
extern int mpi_msg;
extern int mpi_msg_;
extern MPI_Comm mpi_active_comm;
}
#define MPI_INIT MPI_Init(nullptr, nullptr); MPI_Comm_size( lib4neuro::mpi_active_comm, &lib4neuro::mpi_nranks ); MPI_Comm_rank( lib4neuro::mpi_active_comm, &lib4neuro::mpi_rank );
#define MPI_FINISH MPI_Finalize( );
#define MPI_INTERRUPT lib4neuro::mpi_msg = 1; MPI_Allreduce(&lib4neuro::mpi_msg, &lib4neuro::mpi_msg_, 1, MPI_INT, MPI_SUM, lib4neuro::mpi_active_comm);
#define MPI_ERROR_CHECK lib4neuro::mpi_msg = 0; MPI_Allreduce(&lib4neuro::mpi_msg, &lib4neuro::mpi_msg_, 1, MPI_INT, MPI_SUM, lib4neuro::mpi_active_comm);; if( lib4neuro::mpi_msg_ > 0 ){throw std::runtime_error(" eror " );}