GEOSX
initializeEnvironment.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
15 #ifndef GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
16 #define GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
17 
18 // Source includes
19 #include "DataTypes.hpp"
20 #include "MpiWrapper.hpp"
21 
22 // TPL includes
23 #ifdef GEOSX_USE_CALIPER
24 
25 #ifdef GEOSX_USE_ADIAK
26 #include <adiak.hpp>
27 #endif
28 
29 //Forward declaration of cali::ConfigManager.
30 namespace cali
31 {
32 class ConfigManager;
33 }
34 #endif
35 
36 namespace geos
37 {
38 
43 {
46 
48  bool beginFromRestart = false;
49 
52 
55 
58 
61 
64 
68 
73 
75  string schemaName;
76 
78  string problemName;
79 
81  string outputDirectory = ".";
82 
84  string timerOutput = "";
85 
88 
91 };
92 
96 void setupLogger();
97 
102 
107 
113 
117 void setupMKL();
118 
122 void setupOpenMP();
123 
129 void setupMPI( int argc, char * argv[] );
130 
134 void finalizeMPI();
135 
136 
142 void setupEnvironment( int argc, char * argv[] );
143 
148 
149 #if defined( GEOSX_USE_CALIPER )
150 
156 void setupCaliper( cali::ConfigManager & caliperManager,
157  CommandLineOptions const & commandLineOptions );
158 
159 
160 #endif
161 
169 template< typename T >
170 void pushStatsIntoAdiak( string const & name, T const value )
171 {
172 #if defined( GEOSX_USE_CALIPER ) && defined( GEOSX_USE_ADIAK ) && !defined(__APPLE__)
173  // Apple clang doesn't like adiak.
174  T const total = MpiWrapper::sum( value );
175  adiak::value( name + " sum", total );
176  adiak::value( name + " mean", double( total ) / MpiWrapper::commSize() );
177  adiak::value( name + " min", MpiWrapper::min( value ) );
178  adiak::value( name + " max", MpiWrapper::max( value ) );
179 #else
180  GEOS_UNUSED_VAR( name );
181  GEOS_UNUSED_VAR( value );
182 #endif
183 }
184 
185 } // namespace geos
186 
187 #endif // GEOS_COMMON_INITIALIZEENVIRONMENT_HPP_
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:83
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:432
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
void setupOpenMP()
Setup OpenMP.
void setupLogger()
Initialize the logger.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
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 sum(T const &value, MPI_Comm comm=MPI_COMM_GEOSX)
Convenience function for a MPI_Allreduce using a MPI_SUM operation.
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOSX)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.
static T min(T const &value, MPI_Comm comm=MPI_COMM_GEOSX)
Convenience function for a MPI_Allreduce using a MPI_MIN operation.