Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umpire logs refactor - table output + adding percentages #3052

Merged
merged 128 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
751a919
Table function creation
arng40 Feb 9, 2024
c84a06e
add title off case
arng40 Feb 9, 2024
57bc055
setMargin function added
arng40 Feb 12, 2024
6255f9b
add comments + test for tiny table
arng40 Feb 12, 2024
601a2c5
value default optionnal variable changed
arng40 Feb 13, 2024
59a9bc8
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Feb 13, 2024
677fdb6
add log to wellGeneratorBase
arng40 Feb 13, 2024
623b6ad
uncrustify + missing doc
arng40 Feb 13, 2024
37dc5dd
first review with correction
arng40 Feb 14, 2024
8678fc0
constness modification, doc/test updated
arng40 Feb 15, 2024
9475286
const declaration updated
arng40 Feb 15, 2024
1320651
doc + minor restructuring
arng40 Feb 19, 2024
f78bd83
doc + method for row from vector
arng40 Feb 20, 2024
294f075
clean code + doc + add test for rows from vector
arng40 Feb 21, 2024
36dd7a4
doc updated
arng40 Feb 22, 2024
8f74cfa
Merge commit 'c11ad8ecd2d0d0aba5cd0661eb6e72951252409d' into feature/…
arng40 Feb 22, 2024
ebb9fc0
Revert "Merge commit 'c11ad8ecd2d0d0aba5cd0661eb6e72951252409d' into …
arng40 Feb 22, 2024
cb41359
revert last merge and Merge remote-tracking branch 'origin/develop' i…
arng40 Feb 22, 2024
e11a2bf
CI correction ( uncrustify, missing doc )
arng40 Feb 23, 2024
a8f9271
optionnal added to datatype
arng40 Feb 23, 2024
9ff17b9
update doxygen for ci
arng40 Feb 27, 2024
958d542
remove static_assert + constness
arng40 Feb 28, 2024
550ca26
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Feb 28, 2024
f67e3d9
remove unused code
arng40 Feb 29, 2024
aa2f789
remove unused code + add drawtostring method
arng40 Mar 5, 2024
8ff95c2
uncrustify
arng40 Mar 5, 2024
957c7d7
refacto Table first part
arng40 Mar 8, 2024
70d0a01
refortor still going up (missing doc and some minor refacto)
arng40 Mar 11, 2024
f5251f5
uncrustify + perfo example addded
arng40 Mar 11, 2024
1bec18e
update test + margin correction
arng40 Mar 11, 2024
1e45501
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 11, 2024
2054bd4
added Formatter function, correction on TableData
arng40 Mar 12, 2024
37e18b4
Delete table..cpp/hpp
arng40 Mar 12, 2024
5ff7c68
small correction
arng40 Mar 12, 2024
b360a16
doc updated
arng40 Mar 13, 2024
dd5f42f
TableData2D small refacto + opti
arng40 Mar 13, 2024
769beab
uncrustify + small correction
arng40 Mar 13, 2024
5fa478c
csv format / function correction
arng40 Mar 13, 2024
85494c7
remove dataToString with 2D table parameter
arng40 Mar 13, 2024
46e8d23
code opti
arng40 Mar 13, 2024
c1ba824
add 2D table test
arng40 Mar 13, 2024
14ea4f5
uncrustify
arng40 Mar 13, 2024
1271875
Alignment::middle by center and compile time verifcation added
arng40 Mar 14, 2024
d39fa00
PR review
arng40 Mar 14, 2024
c58be1e
2nd wave of pr review
arng40 Mar 14, 2024
1d4bdb4
update compile time verification for table value
arng40 Mar 15, 2024
429920c
add missing doc + uncrustify
arng40 Mar 15, 2024
965a972
constness update + refacto on text formatter
arng40 Mar 18, 2024
6e49ebc
PR correction
arng40 Mar 18, 2024
c1fb3dd
move has_formatter to format.hpp, doc correction
arng40 Mar 19, 2024
e0c6ca2
log level correction
arng40 Mar 19, 2024
7221c0f
perfo log correctly displayed
arng40 Mar 20, 2024
82098d8
remove ; to scope bracket
arng40 Mar 21, 2024
75ed072
doc correction format.hpp
arng40 Mar 21, 2024
3469920
format.hpp doc
arng40 Mar 21, 2024
052f1fa
last correction
arng40 Mar 21, 2024
fae723e
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 21, 2024
84d4df4
umpire stat first test
arng40 Mar 21, 2024
d1dd2a3
first test with CI
arng40 Mar 25, 2024
542062f
uncrustify
arng40 Mar 25, 2024
cfc2901
fix fmt
arng40 Mar 25, 2024
838f36e
cmake fix
arng40 Mar 25, 2024
1139117
test return string
arng40 Mar 25, 2024
13a6d09
fix hpp
arng40 Mar 25, 2024
cfeec17
fix error with string_view
arng40 Mar 25, 2024
7a03e83
fix ci
arng40 Mar 25, 2024
1f4aa29
uncrustify
arng40 Mar 25, 2024
f735cd1
uncrustify
arng40 Mar 25, 2024
bbdf260
test string_view
arng40 Mar 26, 2024
cd4cbe8
last PR correction
arng40 Mar 26, 2024
755805a
Correction melvin PR
arng40 Mar 26, 2024
6264d87
correction review PR
arng40 Mar 27, 2024
21021c7
setMargin private
arng40 Mar 27, 2024
3a34e27
uncrustify
arng40 Mar 27, 2024
76789ba
remove constructor vector string
arng40 Mar 28, 2024
2d1cded
Table Data logs
arng40 Mar 28, 2024
6885754
wip - adding stat + memoryInfos class
arng40 Mar 28, 2024
95f6f3e
percentage recalculation
arng40 Mar 28, 2024
8fedfd8
move table to common + pr correction
arng40 Mar 29, 2024
f7dbdcf
minor correction
arng40 Mar 29, 2024
916d1a0
add warning for compile issue
arng40 Apr 2, 2024
5389d2c
rework empire log header
arng40 Apr 2, 2024
0100b33
Merge remote-tracking branch 'origin/feature/rey/transmissibilityOutp…
arng40 Apr 4, 2024
7375665
refactor method to convert 2Dtable => 1D table
arng40 Apr 4, 2024
d590513
CI correction
arng40 Apr 4, 2024
33d77f2
modification on empire table
arng40 Apr 4, 2024
7f6b79b
move table to fileIO
arng40 Apr 4, 2024
5871443
remove debug log
arng40 Apr 4, 2024
73f8374
update some doc
arng40 Apr 4, 2024
ae4968b
first part test 2D table crash
arng40 Apr 4, 2024
92a1644
add test/warning for table conversion 2D => 1D and warning for fillin…
arng40 Apr 5, 2024
e6b2e6d
ci correction
arng40 Apr 8, 2024
18db533
test ci correction for c++ < 17
arng40 Apr 9, 2024
31126e1
test ci table2D example 1
arng40 Apr 9, 2024
d481454
test ci Table2D test 1 & 2
arng40 Apr 9, 2024
6a7bfe8
test ci Table2D test 1 & 2 & 3
arng40 Apr 9, 2024
e01523b
add virtual destructor TableFormatter + minor variable refacto
arng40 Apr 10, 2024
978674e
bug correction + missing doc + test small refacto
arng40 Apr 10, 2024
da95c91
missig doc ...
arng40 Apr 10, 2024
79acc00
start management logError in table + todo refacto functions in TableF…
arng40 Apr 11, 2024
24f92d9
TableFormatter refacto + clean up
arng40 Apr 12, 2024
5a70c33
uncrustify
arng40 Apr 12, 2024
95f3a9d
small doc update
arng40 Apr 15, 2024
77351b9
some error management update
arng40 Apr 15, 2024
da67c05
renaming & simplifying
arng40 Apr 17, 2024
a9612bb
add case for fill all column in case of table 2D
arng40 Apr 17, 2024
0f1bbe2
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Apr 17, 2024
89f859a
simplification
arng40 Apr 17, 2024
ef5085c
code optimization
arng40 Apr 18, 2024
294db78
remove useless std::move
arng40 Apr 18, 2024
9f23f62
refacto build separator + reviews
arng40 Apr 19, 2024
9809699
final review correction
arng40 Apr 19, 2024
46a6abe
method display layout added
arng40 Apr 22, 2024
a714faa
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Apr 22, 2024
c9cf6be
small correction after merging
arng40 Apr 22, 2024
fe80c59
review correction #1
arng40 May 13, 2024
abb994e
variables renamed
arng40 May 17, 2024
c851b38
uncrustify + doc
arng40 May 23, 2024
0ae0c74
doc
arng40 May 23, 2024
86c0130
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 May 23, 2024
e9639ea
remove unused code
arng40 May 24, 2024
a6b5901
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 May 27, 2024
ed32d73
doxygen
arng40 May 27, 2024
87e5e67
Merge remote-tracking branch 'origin/develop' into feature/dudes/umpi…
arng40 Jun 10, 2024
6e71033
merge correction
arng40 Jun 10, 2024
abd6214
Merge remote-tracking branch 'origin/develop' into feature/dudes/umpi…
arng40 Jun 19, 2024
516013a
Merge remote-tracking branch 'origin/develop' into feature/dudes/umpi…
arng40 Jun 26, 2024
c16d7e6
Merge branch 'develop' into feature/dudes/umpire-stat-log
rrsettgast Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/coreComponents/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set( common_headers
Format.hpp
GEOS_RAJA_Interface.hpp
GeosxMacros.hpp
MemoryInfos.hpp
Logger.hpp
MpiWrapper.hpp
Path.hpp
Expand Down Expand Up @@ -40,6 +41,7 @@ endif( )
set( common_sources
BufferAllocator.cpp
DataTypes.cpp
MemoryInfos.cpp
Logger.cpp
MpiWrapper.cpp
Path.cpp
Expand Down Expand Up @@ -93,6 +95,8 @@ if( ENABLE_CALIPER )
endif()
endif()

set( dependencyList ${dependencyList} fileIO codingUtilities )

blt_add_library( NAME common
SOURCES ${common_sources}
HEADERS ${common_headers}
Expand Down
68 changes: 68 additions & 0 deletions src/coreComponents/common/MemoryInfos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-LiCense-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

#include "MemoryInfos.hpp"

namespace geos
{
MemoryInfos::MemoryInfos( umpire::MemoryResourceTraits::resource_type resourceType ):
m_totalMemory( 0 ),
m_availableMemory( 0 ),
m_physicalMemoryHandled( 1 )
{
switch( resourceType )
{
case umpire::MemoryResourceTraits::resource_type::host:
case umpire::MemoryResourceTraits::resource_type::pinned:
#if defined( _SC_PHYS_PAGES ) && defined( _SC_PAGESIZE )
m_totalMemory = sysconf( _SC_PHYS_PAGES ) * sysconf( _SC_PAGESIZE );
m_availableMemory = sysconf( _SC_AVPHYS_PAGES ) * sysconf( _SC_PAGESIZE );
#else
GEOS_WARNING( "Unknown device physical memory size getter for this compiler." );
m_physicalMemoryHandled = 0;
#endif
break;
case umpire::MemoryResourceTraits::resource_type::device:

Check warning on line 36 in src/coreComponents/common/MemoryInfos.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/MemoryInfos.cpp#L36

Added line #L36 was not covered by tests
case umpire::MemoryResourceTraits::resource_type::device_const:
case umpire::MemoryResourceTraits::resource_type::um:
#if defined( GEOS_USE_CUDA )
cudaMemGetInfo( &m_availableMemory, &m_totalMemory );
#else
GEOS_WARNING( "Unknown device physical memory size getter for this compiler." );
m_physicalMemoryHandled = 0;

Check warning on line 43 in src/coreComponents/common/MemoryInfos.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/MemoryInfos.cpp#L42-L43

Added lines #L42 - L43 were not covered by tests
#endif
break;
default:
GEOS_WARNING( "Physical memory lookup not implemented" );
m_physicalMemoryHandled = 0;
break;

Check warning on line 49 in src/coreComponents/common/MemoryInfos.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/MemoryInfos.cpp#L45-L49

Added lines #L45 - L49 were not covered by tests
}
}

size_t MemoryInfos::getTotalMemory() const
{
return m_totalMemory;
}

size_t MemoryInfos::getAvailableMemory() const

Check warning on line 58 in src/coreComponents/common/MemoryInfos.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/MemoryInfos.cpp#L58

Added line #L58 was not covered by tests
{
return m_availableMemory;

Check warning on line 60 in src/coreComponents/common/MemoryInfos.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/MemoryInfos.cpp#L60

Added line #L60 was not covered by tests
}

bool MemoryInfos::isPhysicalMemoryHandled() const
{
return m_physicalMemoryHandled;
}

}
72 changes: 72 additions & 0 deletions src/coreComponents/common/MemoryInfos.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-LiCense-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

#ifndef GEOS_COMMON_MemoryInfos_HPP_
#define GEOS_COMMON_MemoryInfos_HPP_

#include "umpire/util/MemoryResourceTraits.hpp"
#include "common/Logger.hpp"
#include <unistd.h>
#include <iostream>
#if defined( GEOS_USE_CUDA )
#include <cuda.h>
#endif

namespace geos
{

/**
* @class MemoryInfos
* @brief Class to fetch and store memory information for different resource types.
*/
class MemoryInfos
{
public:

/**
* @brief Constructor for MemoryInfos.
* @param resourceType The type of memory resource.
*/
MemoryInfos( umpire::MemoryResourceTraits::resource_type resourceType );

/**
* @brief Get the total memory available for the resource type.
* @return Total memory in bytes.
*/
size_t getTotalMemory() const;

/**
* @brief Get the available memory for the resource type.
* @return Available memory in bytes.
*/
size_t getAvailableMemory() const;

/**
* @brief Check if physical memory is handled.
* @return True if physical memory is handled, false otherwise.
*/
bool isPhysicalMemoryHandled() const;
private:

///total memory available.
size_t m_totalMemory;
///Available memory.
size_t m_availableMemory;
///Flag indicating if physical memory is handled.
bool m_physicalMemoryHandled;
};

}

#endif
91 changes: 70 additions & 21 deletions src/coreComponents/common/initializeEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@
#include "TimingMacros.hpp"
#include "Path.hpp"
#include "LvArray/src/system.hpp"

#include "fileIO/Table/TableLayout.hpp"
#include "fileIO/Table/TableData.hpp"
#include "fileIO/Table/TableFormatter.hpp"
#include "common/LifoStorageCommon.hpp"
#include "common/MemoryInfos.hpp"
#include <umpire/TypedAllocator.hpp>
// TPL includes
#include <umpire/ResourceManager.hpp>
#include <umpire/Allocator.hpp>
#include <umpire/strategy/AllocationStrategy.hpp>
#include "umpire/util/MemoryResourceTraits.hpp"
#include "umpire/util/Platform.hpp"

#if defined( GEOSX_USE_CALIPER )
#include <caliper/cali-manager.h>
Expand All @@ -46,13 +55,11 @@
#if defined( GEOS_USE_HIP )
#include <hip/hip_runtime.h>
#endif

#include <cfenv>

namespace geos
{


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setupLogger()
{
Expand Down Expand Up @@ -248,7 +255,9 @@
static void addUmpireHighWaterMarks()
{
umpire::ResourceManager & rm = umpire::ResourceManager::getInstance();

integer size;
MPI_Comm_size( MPI_COMM_WORLD, &size );
size_t nbRank = (std::size_t)size;
// Get a list of all the allocators and sort it so that it's in the same order on each rank.
std::vector< string > allocatorNames = rm.getAllocatorNames();
std::sort( allocatorNames.begin(), allocatorNames.end() );
Expand All @@ -264,43 +273,84 @@
}

// Loop over the allocators.
constexpr int MAX_NAME_LENGTH = 100;
char allocatorNameBuffer[ MAX_NAME_LENGTH + 1 ];
char allocatorNameMinCharsBuffer[ MAX_NAME_LENGTH + 1 ];
unsigned MAX_NAME_LENGTH = 100;

TableData tableData;
for( string const & allocatorName : allocatorNames )
{
// Skip umpire internal allocators.
if( allocatorName.rfind( "__umpire_internal", 0 ) == 0 )
continue;

GEOS_ERROR_IF_GT( allocatorName.size(), MAX_NAME_LENGTH );
string allocatorNameFixedSize = allocatorName;
allocatorNameFixedSize.resize( MAX_NAME_LENGTH, '\0' );
string allocatorNameMinChars = string( MAX_NAME_LENGTH, '\0' );

memset( allocatorNameBuffer, '\0', sizeof( allocatorNameBuffer ) );
memcpy( allocatorNameBuffer, allocatorName.data(), allocatorName.size() );
// Make sure that each rank is looking at the same allocator.
MpiWrapper::allReduce( allocatorNameFixedSize.c_str(), &allocatorNameMinChars.front(), MAX_NAME_LENGTH, MPI_MIN, MPI_COMM_GEOSX );
if( allocatorNameFixedSize != allocatorNameMinChars )
{
GEOS_WARNING( "Not all ranks have an allocator named " << allocatorNameFixedSize << ", cannot compute high water mark." );
continue;

Check warning on line 295 in src/coreComponents/common/initializeEnvironment.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/initializeEnvironment.cpp#L294-L295

Added lines #L294 - L295 were not covered by tests
}

memset( allocatorNameMinCharsBuffer, '\0', sizeof( allocatorNameMinCharsBuffer ) );
umpire::Allocator allocator = rm.getAllocator( allocatorName );
umpire::strategy::AllocationStrategy const * allocationStrategy = allocator.getAllocationStrategy();
umpire::MemoryResourceTraits const traits = allocationStrategy->getTraits();
umpire::MemoryResourceTraits::resource_type resourceType = traits.resource;
MemoryInfos const memInfos( resourceType );

// Make sure that each rank is looking at the same allocator.
MpiWrapper::allReduce( allocatorNameBuffer, allocatorNameMinCharsBuffer, MAX_NAME_LENGTH, MPI_MIN, MPI_COMM_GEOSX );
if( strcmp( allocatorNameBuffer, allocatorNameMinCharsBuffer ) != 0 )
if( !memInfos.isPhysicalMemoryHandled() )
{
GEOS_WARNING( "Not all ranks have an allocator named " << allocatorNameBuffer << ", cannot compute high water mark." );
continue;
}

// Get the total number of bytes allocated with this allocator across ranks.
// This is a little redundant since
std::size_t const mark = rm.getAllocator( allocatorName ).getHighWatermark();
std::size_t const totalMark = MpiWrapper::sum( mark );
std::size_t const mark = allocator.getHighWatermark();
std::size_t const minMark = MpiWrapper::min( mark );
std::size_t const maxMark = MpiWrapper::max( mark );
GEOS_LOG_RANK_0( "Umpire " << std::setw( 15 ) << allocatorName << " sum across ranks: " <<
std::setw( 9 ) << LvArray::system::calculateSize( totalMark ) );
GEOS_LOG_RANK_0( "Umpire " << std::setw( 15 ) << allocatorName << " rank max: " <<
std::setw( 9 ) << LvArray::system::calculateSize( maxMark ) );
std::size_t const sumMark = MpiWrapper::sum( mark );

string percentage;
if( memInfos.getTotalMemory() == 0 )
{
percentage = 0.0;
GEOS_WARNING( "umpire memory percentage could not be resolved" );

Check warning on line 320 in src/coreComponents/common/initializeEnvironment.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/common/initializeEnvironment.cpp#L319-L320

Added lines #L319 - L320 were not covered by tests
}
else
{
percentage = GEOS_FMT( "({:.1f}%)", ( 100.0f * (float)mark ) / (float)memInfos.getTotalMemory() );
}

string const minMarkValue = GEOS_FMT( "{} {:>8}",
LvArray::system::calculateSize( minMark ), percentage );
string const maxMarkValue = GEOS_FMT( "{} {:>8}",
LvArray::system::calculateSize( maxMark ), percentage );
string const avgMarkValue = GEOS_FMT( "{} {:>8}",
LvArray::system::calculateSize( sumMark / nbRank ), percentage );
string const sumMarkValue = GEOS_FMT( "{} {:>8}",
LvArray::system::calculateSize( sumMark ), percentage );

tableData.addRow( allocatorName,
minMarkValue,
maxMarkValue,
avgMarkValue,
sumMarkValue );

pushStatsIntoAdiak( allocatorName + " sum across ranks", mark );
pushStatsIntoAdiak( allocatorName + " rank max", mark );
}

TableLayout const memoryStatLayout ( {"Umpire Memory Pool\n(reserved / % over total)",
"Min over ranks",
"Max over ranks",
"Avg over ranks",
"Sum over ranks" } );
TableTextFormatter const memoryStatLog( memoryStatLayout );

GEOS_LOG_RANK_0( memoryStatLog.toString( tableData ));
}


Expand All @@ -324,5 +374,4 @@
finalizeMPI();
}


} // namespace geos