Skip to content

Commit 1f153e5

Browse files
author
Avirup Sircar
committed
Added timers in the code for analysis
1 parent 0eadecc commit 1f153e5

17 files changed

+246
-227
lines changed

analysis/classicalEnrichmentComparison/PSP/KSDFTClassicalUniformQuad/TestKohnShamDft.cpp

Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,10 @@ int main(int argc, char** argv)
476476

477477
utils::mpi::MPIComm comm = utils::mpi::MPICommWorld;
478478

479-
utils::mpi::MPIBarrier(comm);
480-
auto startTotal = std::chrono::high_resolution_clock::now();
481-
479+
utils::Profiler pTot(comm, "Total Statistics");
480+
utils::Profiler p(comm, "Initilization Breakdown Statistics");
481+
pTot.registerStart("Initilization");
482+
482483
// Get the rank of the process
483484
int rank;
484485
utils::mpi::MPICommRank(comm, &rank);
@@ -718,10 +719,7 @@ int main(int argc, char** argv)
718719

719720
// Set up the quadrature rule
720721

721-
// add device synchronize for gpu
722-
utils::mpi::MPIBarrier(comm);
723-
auto start = std::chrono::high_resolution_clock::now();
724-
722+
p.registerStart("Basis Creation and Basis Data Storages Evaluation");
725723
quadrature::QuadratureRuleAttributes quadAttrElec(quadrature::QuadratureFamily::GAUSS,true,feOrderElec+1);
726724

727725
basis::BasisStorageAttributesBoolMap basisAttrMap;
@@ -949,16 +947,17 @@ std::shared_ptr<linearAlgebra::OperatorContext<double,
949947
setCellValues<Host>(iCell, b);
950948
}
951949

952-
// add device synchronize for gpu
953-
utils::mpi::MPIBarrier(comm);
954-
auto stop = std::chrono::high_resolution_clock::now();
955-
956-
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
957-
958-
rootCout << "Time for all basis storage evaluations including overlap operators(in secs) : " << duration.count()/1e6 << std::endl;
950+
p.registerEnd("Basis Creation and Basis Data Storages Evaluation");
959951

960952
rootCout << "Entering KohnSham DFT Class....\n\n";
961953

954+
p.registerStart("Kohn Sham DFT Class Init");
955+
std::shared_ptr<ksdft::KohnShamDFT<double,
956+
double,
957+
double,
958+
double,
959+
Host,
960+
dim>> dftefeSolve = nullptr;
962961
if(isNumericalNuclearSolve)
963962
{
964963

@@ -977,12 +976,7 @@ std::shared_ptr<linearAlgebra::OperatorContext<double,
977976

978977
std::shared_ptr<const basis::FEBasisDataStorage<double,Host>> feBDNuclearChargeStiffnessMatrix = feBDTotalChargeStiffnessMatrix;
979978

980-
std::shared_ptr<ksdft::KohnShamDFT<double,
981-
double,
982-
double,
983-
double,
984-
Host,
985-
dim>> dftefeSolve =
979+
dftefeSolve =
986980
std::make_shared<ksdft::KohnShamDFT<double,
987981
double,
988982
double,
@@ -1021,31 +1015,11 @@ std::shared_ptr<linearAlgebra::OperatorContext<double,
10211015
*MContextForInv,
10221016
/**MContextForInv,*/
10231017
*MContext,
1024-
*MInvContext);
1025-
1026-
// add device synchronize for gpu
1027-
utils::mpi::MPIBarrier(comm);
1028-
start = std::chrono::high_resolution_clock::now();
1029-
1030-
dftefeSolve->solve();
1031-
1032-
// add device synchronize for gpu
1033-
utils::mpi::MPIBarrier(comm);
1034-
stop = std::chrono::high_resolution_clock::now();
1035-
1036-
duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
1037-
1038-
rootCout << "Time for scf iterations is(in secs) : " << duration.count()/1e6 << std::endl;
1039-
1018+
*MInvContext);
10401019
}
10411020
else
10421021
{
1043-
std::shared_ptr<ksdft::KohnShamDFT<double,
1044-
double,
1045-
double,
1046-
double,
1047-
Host,
1048-
dim>> dftefeSolve =
1022+
dftefeSolve =
10491023
std::make_shared<ksdft::KohnShamDFT<double,
10501024
double,
10511025
double,
@@ -1083,31 +1057,18 @@ std::shared_ptr<linearAlgebra::OperatorContext<double,
10831057
/**MContextForInv,*/
10841058
*MContext,
10851059
*MInvContext);
1086-
1087-
// add device synchronize for gpu
1088-
utils::mpi::MPIBarrier(comm);
1089-
start = std::chrono::high_resolution_clock::now();
1090-
1091-
dftefeSolve->solve();
1092-
1093-
// add device synchronize for gpu
1094-
utils::mpi::MPIBarrier(comm);
1095-
stop = std::chrono::high_resolution_clock::now();
1096-
1097-
duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
1098-
1099-
rootCout << "Time for scf iterations is(in secs) : " << duration.count()/1e6 << std::endl;
1100-
11011060
}
1061+
p.registerEnd("Kohn Sham DFT Class Init");
1062+
p.print();
11021063

1103-
// add device synchronize for gpu
1104-
utils::mpi::MPIBarrier(comm);
1105-
auto stopTotal = std::chrono::high_resolution_clock::now();
1106-
1107-
auto durationTotal = std::chrono::duration_cast<std::chrono::microseconds>(stopTotal - startTotal);
1064+
pTot.registerEnd("Initilization");
1065+
pTot.registerStart("Kohn Sham DFT Solve");
11081066

1109-
rootCout << "Total wall time(in secs) : " << durationTotal.count()/1e6 << std::endl;
1067+
dftefeSolve->solve();
11101068

1069+
pTot.registerEnd("Kohn Sham DFT Solve");
1070+
pTot.print();
1071+
11111072
//gracefully end MPI
11121073

11131074
int mpiFinalFlag = 0;

0 commit comments

Comments
 (0)