Skip to content

Commit

Permalink
Output run start/end/ranks (#2426)
Browse files Browse the repository at this point in the history
  • Loading branch information
klevzoff authored May 10, 2023
1 parent ef0b131 commit 8f27920
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/cmake/thirdparty/SetupGeosxThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ if(DEFINED FMT_DIR)

message( " ----> fmt_VERSION = ${fmt_VERSION}")

get_target_property(includeDirs fmt::fmt INTERFACE_INCLUDE_DIRECTORIES)

set_property(TARGET fmt::fmt
APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
${includeDirs})

set(ENABLE_FMT ON CACHE BOOL "")
set(thirdPartyLibs ${thirdPartyLibs} fmt::fmt)
else()
Expand Down
27 changes: 26 additions & 1 deletion src/coreComponents/codingUtilities/EnumStrings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#ifndef GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP
#define GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP

#include "StringUtilities.hpp"
#include "codingUtilities/StringUtilities.hpp"
#include "common/DataTypes.hpp"
#include "common/Logger.hpp"
#include "common/Format.hpp"

#include <iostream>
#include <type_traits>
Expand Down Expand Up @@ -181,4 +182,28 @@ struct TypeRegex< ENUM, std::enable_if_t< internal::HasEnumStrings< ENUM > > >

} // namespace geos

// Formatter specialization for enums
template< typename Enum >
struct GEOS_FMT_NS::formatter< Enum, std::enable_if_t< std::is_enum< Enum >::value && geos::internal::HasEnumStrings< Enum >, char > >
: GEOS_FMT_NS::formatter< std::string >
{
template< typename FormatContext >
auto format( Enum e, FormatContext & ctx ) const
{
return formatter< std::string >::format( toString( e ), ctx );
}
};

// Formatter specialization for enums
template< typename Enum >
struct GEOS_FMT_NS::formatter< Enum, std::enable_if_t< std::is_enum< Enum >::value && !geos::internal::HasEnumStrings< Enum >, char > >
: GEOS_FMT_NS::formatter< std::underlying_type_t< Enum > >
{
template< typename FormatContext >
auto format( Enum e, FormatContext & ctx ) const
{
return GEOS_FMT_NS::formatter< std::underlying_type_t< Enum > >::format( toUnderlying( e ), ctx );
}
};

#endif //GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP
5 changes: 3 additions & 2 deletions src/coreComponents/common/Format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#ifdef GEOSX_USE_FMT
#include <fmt/core.h>
#include <fmt/chrono.h>
#define GEOS_FMT_NS ::fmt
#include <fmt/ranges.h>
#define GEOS_FMT_NS fmt
#else // use C++20's <format>
#include <format>
#define GEOS_FMT_NS ::std
#define GEOS_FMT_NS std
#endif

/**
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 8f27920

Please sign in to comment.