Adding MPI wrapper class

This commit is contained in:
Mark Berrill committed 2020-01-28 08:51:32 -05:00
1 parent acb2d30454
commit d1f714a82e
125 files changed
+8530 -2541

No files matched your search

+14 -20
View File
@@ -6,7 +6,7 @@
#include <fstream>
#include "common/Communication.h"
#include "common/MPI_Helpers.h"
#include "common/MPI.h"
#include "common/Array.h"
using namespace std;
@@ -15,11 +15,9 @@ using namespace std;
//***************************************************************************************
int test_communication( MPI_Comm comm, int nprocx, int nprocy, int nprocz )
int test_communication( const Utilities::MPI& comm, int nprocx, int nprocy, int nprocz )
{
int rank,nprocs;
MPI_Comm_rank(comm,&rank);
MPI_Comm_size(comm,&nprocs);
int rank = comm.getRank();
int iproc,jproc,kproc;
int sendtag,recvtag;
if (rank==0) printf("\nRunning test %i %i %i\n",nprocx,nprocy,nprocz);
@@ -38,7 +36,7 @@ int test_communication( MPI_Comm comm, int nprocx, int nprocy, int nprocz )
rank_xy, rank_XY, rank_xY, rank_Xy,
rank_xz, rank_XZ, rank_xZ, rank_Xz,
rank_yz, rank_YZ, rank_yZ, rank_Yz );
MPI_Barrier(comm);
comm.barrier();
//**********************************
@@ -85,7 +83,7 @@ int test_communication( MPI_Comm comm, int nprocx, int nprocy, int nprocz )
sendCount_xy = sendCount_yz = sendCount_xz = sendCount_Xy = sendCount_Yz = sendCount_xZ = 0;
sendCount_xY = sendCount_yZ = sendCount_Xz = sendCount_XY = sendCount_YZ = sendCount_XZ = 0;
MPI_Barrier(comm);
comm.barrier();
if (rank==0) printf ("SendLists are ready on host\n");
//......................................................................................
// Use MPI to fill in the recvCounts form the associated processes
@@ -158,7 +156,7 @@ int test_communication( MPI_Comm comm, int nprocx, int nprocy, int nprocz )
recvCount_yz, recvCount_YZ, recvCount_yZ, recvCount_Yz,
rank_x, rank_y, rank_z, rank_X, rank_Y, rank_Z, rank_xy, rank_XY, rank_xY,
rank_Xy, rank_xz, rank_XZ, rank_xZ, rank_Xz, rank_yz, rank_YZ, rank_yZ, rank_Yz );
MPI_Barrier(comm);
comm.barrier();
if (rank==0) printf ("RecvLists finished\n");
// Free memory
@@ -181,11 +179,9 @@ int test_communication( MPI_Comm comm, int nprocx, int nprocy, int nprocz )
template<class TYPE>
int testHalo( MPI_Comm comm, int nprocx, int nprocy, int nprocz, int depth )
int testHalo( const Utilities::MPI& comm, int nprocx, int nprocy, int nprocz, int depth )
{
int rank,nprocs;
MPI_Comm_rank(comm,&rank);
MPI_Comm_size(comm,&nprocs);
int rank = comm.getRank();
if ( rank==0 )
printf("\nRunning Halo test %i %i %i %i\n",nprocx,nprocy,nprocz,depth);
@@ -255,11 +251,10 @@ int testHalo( MPI_Comm comm, int nprocx, int nprocy, int nprocz, int depth )
int main(int argc, char **argv)
{
// Initialize MPI
int rank,nprocs;
MPI_Init(&argc,&argv);
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank(comm,&rank);
MPI_Comm_size(comm,&nprocs);
Utilities::MPI comm( MPI_COMM_WORLD );
int rank = comm.getRank();
int nprocs = comm.getSize();
// Run the test with different domains
int N_errors = 0;
@@ -289,10 +284,9 @@ int main(int argc, char **argv)
}
// Finished
MPI_Barrier(comm);
int N_errors_global=0;
MPI_Allreduce( &N_errors, &N_errors_global, 1, MPI_INT, MPI_SUM, comm );
MPI_Barrier(comm);
comm.barrier();
int N_errors_global = comm.sumReduce( N_errors );
comm.barrier();
MPI_Finalize();
if ( rank==0 ) {
if ( N_errors_global==0 )