GEOS
initializeEnvironment.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
16 #ifndef GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
17 #define GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
18 
19 // Source includes
20 #include "DataTypes.hpp"
21 #include "MpiWrapper.hpp"
22 
23 // TPL includes
24 #ifdef GEOS_USE_CALIPER
25 
26 #ifdef GEOS_USE_ADIAK
27 #include <adiak.hpp>
28 #endif
29 
30 //Forward declaration of cali::ConfigManager.
31 namespace cali
32 {
33 class ConfigManager;
34 }
35 #endif
36 
37 namespace geos
38 {
39 
44 {
47 
49  bool beginFromRestart = false;
50 
53 
56 
59 
62 
65 
69 
74 
76  string schemaName;
77 
79  string problemName;
80 
82  string outputDirectory = ".";
83 
85  string timerOutput = "";
86 
89 
92 };
93 
97 void setupLogger();
98 
103 
108 
114 
118 void setupMKL();
119 
123 void setupOpenMP();
124 
130 void setupMPI( int argc, char * argv[] );
131 
135 void finalizeMPI();
136 
137 
143 void setupEnvironment( int argc, char * argv[] );
144 
149 
150 #if defined( GEOS_USE_CALIPER )
151 
157 void setupCaliper( cali::ConfigManager & caliperManager,
158  CommandLineOptions const & commandLineOptions );
159 
160 
161 #endif
162 
170 template< typename T >
171 void pushStatsIntoAdiak( string const & name, T const value )
172 {
173 #if defined( GEOS_USE_CALIPER ) && defined( GEOS_USE_ADIAK ) && !defined(__APPLE__)
174  // Apple clang doesn't like adiak.
175  T const total = MpiWrapper::sum( value );
176  adiak::value( name + " sum", total );
177  adiak::value( name + " mean", double( total ) / MpiWrapper::commSize() );
178  adiak::value( name + " min", MpiWrapper::min( value ) );
179  adiak::value( name + " max", MpiWrapper::max( value ) );
180 #else
181  GEOS_UNUSED_VAR( name );
182  GEOS_UNUSED_VAR( value );
183 #endif
184 }
185 
186 } // namespace geos
187 
188 #endif // GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
void setupOpenMP()
Setup OpenMP.
void setupLogger()
Initialize the logger.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
void finalizeLogger()
Finalize the logger.
void setupEnvironment(int argc, char *argv[])
Setup/init the environment.
void pushStatsIntoAdiak(string const &name, T const value)
Compute the sum, mean, min, and max of value across ranks and push them into Adiak using name.
void setupMPI(int argc, char *argv[])
Setup MPI.
void setupLvArray()
Setup the LvArray library. This initializes signal handling and the floating point environment.
void setupMKL()
Setup MKL if in use.
void finalizeCaliper()
Finalize Caliper and Adiak.
void cleanupEnvironment()
Cleanup/finalize the environment.
void finalizeMPI()
Finalize MPI.
string outputDirectory
The directory to put all output.
string schemaName
The name of the schema.
bool beginFromRestart
True iff restarting from the middle of an existing run.
string restartFileName
The path to the restart file, if specified.
integer overridePartitionNumbers
True if using the partition override.
string timerOutput
The string used to initialize caliper.
string problemName
The name of the problem being run.
string_array inputFileNames
The paths to the input xml files.
integer xPartitionsOverride
The number of partitions in the x direction.
real64 printMemoryUsage
Print memory usage in data repository.
integer traceDataMigration
Trace host-device data migration.
integer yPartitionsOverride
The number of partitions in the y direction.
integer zPartitionsOverride
The number of partitions in the z direction.
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.
static T sum(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_SUM operation.
static T min(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MIN operation.