Skip to content

Commit

Permalink
Output run start/end/ranks
Browse files Browse the repository at this point in the history
  • Loading branch information
klevzoff committed May 9, 2023
1 parent 7f6fe3e commit 7743e86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/coreComponents/common/Format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifdef GEOSX_USE_FMT
#include <fmt/core.h>
#include <fmt/chrono.h>
#include <fmt/ranges.h>
#define GEOS_FMT_NS ::fmt
#else // use C++20's <format>
#include <format>
Expand Down
6 changes: 6 additions & 0 deletions src/coreComponents/common/initializeEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ void setupMPI( int argc, char * argv[] )
}

MPI_COMM_GEOSX = MpiWrapper::commDup( MPI_COMM_WORLD );

if( MpiWrapper::commRank( MPI_COMM_GEOSX ) == 0 )
{
// Can't use logging macros prior to logger init
std::cout << "Num ranks: " << MpiWrapper::commSize( MPI_COMM_GEOSX ) << std::endl;
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 11 additions & 6 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
*/

// Source includes
#include "common/DataTypes.hpp"
#include "common/Format.hpp"
#include "common/TimingMacros.hpp"
#include "mainInterface/initialization.hpp"
#include "mainInterface/ProblemManager.hpp"
#include "mainInterface/GeosxState.hpp"
#include "common/DataTypes.hpp"
#include "common/TimingMacros.hpp"

// System includes
#include <chrono>
Expand All @@ -33,6 +34,8 @@ int main( int argc, char *argv[] )

std::unique_ptr< CommandLineOptions > commandLineOptions = basicSetup( argc, argv, true );

GEOS_LOG_RANK_0( GEOS_FMT( "Started at {:%Y-%m-%d %H:%M:%S}", startTime ) );

std::chrono::system_clock::duration initTime;
std::chrono::system_clock::duration runTime;
{
Expand All @@ -52,11 +55,13 @@ int main( int argc, char *argv[] )

basicCleanup();

std::chrono::system_clock::duration const totalTime = std::chrono::system_clock::now() - startTime;
std::chrono::system_clock::time_point const endTime = std::chrono::system_clock::now();
std::chrono::system_clock::duration const totalTime = endTime - startTime;

GEOS_LOG_RANK_0( "total time " << durationToString( totalTime ) );
GEOS_LOG_RANK_0( "initialization time " << durationToString( initTime ) );
GEOS_LOG_RANK_0( "run time " << durationToString( runTime ) );
GEOS_LOG_RANK_0( GEOS_FMT( "Finished at {:%Y-%m-%d %H:%M:%S}", endTime ) );
GEOS_LOG_RANK_0( GEOS_FMT( "total time {:%H:%M:%S}", totalTime ) );
GEOS_LOG_RANK_0( GEOS_FMT( "initialization time {:%H:%M:%S}", initTime ) );
GEOS_LOG_RANK_0( GEOS_FMT( "run time {:%H:%M:%S}", runTime ) );

return 0;
}
Expand Down

0 comments on commit 7743e86

Please sign in to comment.