FOM for tests

This commit is contained in:
James McClure 2021-01-05 16:08:03 -05:00
parent d7fc677435
commit 345b43d9f8
4 changed files with 20 additions and 19 deletions

View File

@ -6,7 +6,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "common/ScaLBL.h" #include "common/ScaLBL.h"
#include "common/MPI_Helpers.h" #include "common/MPI.h"
using namespace std; using namespace std;
@ -166,8 +166,8 @@ int main(int argc, char **argv)
// Initialize MPI // Initialize MPI
Utilities::startup( argc, argv ); Utilities::startup( argc, argv );
Utilities::MPI comm( MPI_COMM_WORLD ); Utilities::MPI comm( MPI_COMM_WORLD );
int rank = comm.getRank(); int rank = comm.getRank();
int nprocs = comm.getSize(); int nprocs = comm.getSize();
int check; int check;
{ {
@ -262,14 +262,14 @@ int main(int argc, char **argv)
} }
} }
} }
MPI_Allreduce(&sum_local,&sum,1,MPI_DOUBLE,MPI_SUM,comm); sum = comm.sumReduce( sum_local );
double iVol_global=1.f/double((Nx-2)*(Ny-2)*(Nz-2)*nprocx*nprocy*nprocz); double iVol_global=1.f/double((Nx-2)*(Ny-2)*(Nz-2)*nprocx*nprocy*nprocz);
porosity = 1.0-sum*iVol_global; porosity = 1.0-sum*iVol_global;
if (rank==0) printf("Media porosity = %f \n",porosity); if (rank==0) printf("Media porosity = %f \n",porosity);
//....................................................................... //.......................................................................
//........................................................................... //...........................................................................
MPI_Barrier(comm); comm.barrier();
if (rank == 0) cout << "Domain set." << endl; if (rank == 0) cout << "Domain set." << endl;
//........................................................................... //...........................................................................
@ -354,7 +354,7 @@ int main(int argc, char **argv)
GlobalFlipScaLBL_D3Q19_Init(fq_host, Map, Np, Nx-2, Ny-2, Nz-2, iproc,jproc,kproc,nprocx,nprocy,nprocz); GlobalFlipScaLBL_D3Q19_Init(fq_host, Map, Np, Nx-2, Ny-2, Nz-2, iproc,jproc,kproc,nprocx,nprocy,nprocz);
ScaLBL_CopyToDevice(fq, fq_host, 19*dist_mem_size); ScaLBL_CopyToDevice(fq, fq_host, 19*dist_mem_size);
ScaLBL_DeviceBarrier(); ScaLBL_DeviceBarrier();
MPI_Barrier(comm); comm.barrier();
//************************************************************************* //*************************************************************************
// First timestep // First timestep
ScaLBL_Comm.SendD3Q19AA(fq); //READ FROM NORMAL ScaLBL_Comm.SendD3Q19AA(fq); //READ FROM NORMAL
@ -377,8 +377,8 @@ int main(int argc, char **argv)
//.......create and start timer............ //.......create and start timer............
double starttime,stoptime,cputime; double starttime,stoptime,cputime;
MPI_Barrier(comm); comm.barrier();
starttime = MPI_Wtime(); starttime = Utilities::MPI::time();
//......................................... //.........................................
@ -397,13 +397,13 @@ int main(int argc, char **argv)
//********************************************* //*********************************************
ScaLBL_DeviceBarrier(); ScaLBL_DeviceBarrier();
MPI_Barrier(comm); comm.barrier();
// Iteration completed! // Iteration completed!
timestep++; timestep++;
//................................................................... //...................................................................
} }
//************************************************************************/ //************************************************************************/
stoptime = MPI_Wtime(); stoptime = Utilities::MPI::time();
// cout << "CPU time: " << (stoptime - starttime) << " seconds" << endl; // cout << "CPU time: " << (stoptime - starttime) << " seconds" << endl;
cputime = stoptime - starttime; cputime = stoptime - starttime;
// cout << "Lattice update rate: "<< double(Nx*Ny*Nz*timestep)/cputime/1000000 << " MLUPS" << endl; // cout << "Lattice update rate: "<< double(Nx*Ny*Nz*timestep)/cputime/1000000 << " MLUPS" << endl;
@ -429,5 +429,6 @@ int main(int argc, char **argv)
comm.barrier(); comm.barrier();
Utilities::shutdown(); Utilities::shutdown();
// **************************************************** // ****************************************************
return check; return check;
} }

View File

@ -9,7 +9,7 @@
#include "common/UnitTest.h" #include "common/UnitTest.h"
#include "common/Utilities.h" #include "common/Utilities.h"
#include "common/MPI_Helpers.h" #include "common/MPI.h"
#include "common/Database.h" #include "common/Database.h"
#include "ProfilerApp.h" #include "ProfilerApp.h"

View File

@ -97,13 +97,13 @@ int main(int argc, char **argv)
} }
} }
MPI_Barrier(comm); comm.barrier();
if (rank==0) printf("Initialized! Converting to Signed Distance function \n"); if (rank==0) printf("Initialized! Converting to Signed Distance function \n");
double t1 = MPI_Wtime(); double t1 = Utilities::MPI::time();
DoubleArray Distance(nx,ny,nz); DoubleArray Distance(nx,ny,nz);
CalcDist(Distance,id,Dm,{false,false,false}); CalcDist(Distance,id,Dm,{false,false,false});
double t2 = MPI_Wtime(); double t2 = Utilities::MPI::time();
if (rank==0) if (rank==0)
printf("Total time: %f seconds \n",t2-t1); printf("Total time: %f seconds \n",t2-t1);
@ -115,7 +115,7 @@ int main(int argc, char **argv)
} }
} }
} }
err = sumReduce( Dm.Comm, err ); err = Dm.Comm.sumReduce( err );
err = sqrt( err / (nx*ny*nz*nprocs) ); err = sqrt( err / (nx*ny*nz*nprocs) );
if (rank==0) if (rank==0)
printf("Mean error %0.4f \n", err); printf("Mean error %0.4f \n", err);

View File

@ -172,10 +172,10 @@ int main(int argc, char **argv)
double Ai = Object->A(); double Ai = Object->A();
double Hi = Object->H(); double Hi = Object->H();
double Xi = Object->X(); double Xi = Object->X();
Vi=sumReduce( Dm->Comm, Vi); Vi=Dm->Comm.sumReduce( Vi);
Ai=sumReduce( Dm->Comm, Ai); Ai=Dm->Comm.sumReduce( Ai);
Hi=sumReduce( Dm->Comm, Hi); Hi=Dm->Comm.sumReduce( Hi);
Xi=sumReduce( Dm->Comm, Xi); Xi=Dm->Comm.sumReduce( Xi);
printf("Vi=%f, Ai=%f, Hi=%f, Xi=%f \n", Vi,Ai,Hi,Xi); printf("Vi=%f, Ai=%f, Hi=%f, Xi=%f \n", Vi,Ai,Hi,Xi);
} // Limit scope so variables that contain communicators will free before MPI_Finialize } // Limit scope so variables that contain communicators will free before MPI_Finialize