From 1c903a3380ceaf9397be5907849ad01828bd532b Mon Sep 17 00:00:00 2001 From: James McClure Date: Sat, 11 Jun 2022 20:49:01 -0400 Subject: [PATCH] add performance counters to ion / poisson solvers --- models/IonModel.cpp | 33 ++++++++++++++++++++------------- models/PoissonSolver.cpp | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/models/IonModel.cpp b/models/IonModel.cpp index 85574ccd..d1bcfe5a 100644 --- a/models/IonModel.cpp +++ b/models/IonModel.cpp @@ -1248,6 +1248,7 @@ void ScaLBL_IonModel::Run(double *Velocity, double *ElectricField) { //ScaLBL_Comm->Barrier(); comm.barrier(); //auto t1 = std::chrono::system_clock::now(); + auto t1 = std::chrono::system_clock::now(); for (size_t ic = 0; ic < number_ion_species; ic++) { timestep = 0; while (timestep < timestepMax[ic]) { @@ -1430,19 +1431,25 @@ void ScaLBL_IonModel::Run(double *Velocity, double *ElectricField) { ScaLBL_Comm->LastExterior(), Np); } //************************************************************************/ - //if (rank==0) printf("-------------------------------------------------------------------\n"); - //// Compute the walltime per timestep - //auto t2 = std::chrono::system_clock::now(); - //double cputime = std::chrono::duration( t2 - t1 ).count() / timestep; - //// Performance obtained from each node - //double MLUPS = double(Np)/cputime/1000000; - - //if (rank==0) printf("********************************************************\n"); - //if (rank==0) printf("CPU time = %f \n", cputime); - //if (rank==0) printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS); - //MLUPS *= nprocs; - //if (rank==0) printf("Lattice update rate (total)= %f MLUPS \n", MLUPS); - //if (rank==0) printf("********************************************************\n"); + if (rank == 0) + printf("---------------------------------------------------------------" + "----\n"); + // Compute the walltime per timestep + auto t2 = std::chrono::system_clock::now(); + double cputime = std::chrono::duration(t2 - t1).count() / timestep; + // Performance obtained from each node + double MLUPS = double(Np) / cputime / 1000000; + if (rank == 0) + printf("********************************************************\n"); + if (rank == 0) + printf("CPU time = %f \n", cputime); + if (rank == 0) + printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS); + MLUPS *= nprocs; + if (rank == 0) + printf("Lattice update rate (total)= %f MLUPS \n", MLUPS); + if (rank == 0) + printf("********************************************************\n"); } void ScaLBL_IonModel::RunMembrane(double *Velocity, double *ElectricField, double *Psi) { diff --git a/models/PoissonSolver.cpp b/models/PoissonSolver.cpp index 55d8d2a2..b516a509 100644 --- a/models/PoissonSolver.cpp +++ b/models/PoissonSolver.cpp @@ -769,6 +769,7 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, bool UseSlippingVelBC, int times host_Error = new double [Np]; timestep=0; + auto t1 = std::chrono::system_clock::now(); while (timestep < timestepMax && error > tolerance) { //************************************************************************/ // *************ODD TIMESTEP*************// @@ -809,7 +810,29 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, bool UseSlippingVelBC, int times } } + if (rank == 0) + printf("---------------------------------------------------------------" + "----\n"); + // Compute the walltime per timestep + auto t2 = std::chrono::system_clock::now(); + double cputime = std::chrono::duration(t2 - t1).count() / timestep; + // Performance obtained from each node + double MLUPS = double(Np) / cputime / 1000000; + + if (rank == 0) + printf("********************************************************\n"); + if (rank == 0) + printf("CPU time = %f \n", cputime); + if (rank == 0) + printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS); + MLUPS *= nprocs; + if (rank == 0) + printf("Lattice update rate (total)= %f MLUPS \n", MLUPS); + if (rank == 0) + printf("********************************************************\n"); } + //************************************************************************/ + if(WriteLog==true){ getConvergenceLog(timestep,error); }