Advanced Multi-Physics (AMP)
On-Line Documentation
AMPManager.h
Go to the documentation of this file.
1#ifndef included_AMP_AMPManager
2#define included_AMP_AMPManager
3
4#include "AMP/utils/AMP_MPI.h"
5
6#include <array>
7#include <functional>
8#include <memory>
9#include <set>
10#include <string>
11#include <vector>
12
13
14namespace StackTrace {
15class abort_error;
16}
17
18
19namespace AMP {
20
21
26{
27public:
30
38 bool use_MPI_Abort = true;
39
41 bool print_times = false;
42
44 bool print_startup = false;
45
47 int print_memory = -1;
48
50 bool initialize_device = true;
51
54
57
66
68 std::set<int> catch_signals;
69
71 bool catch_MPI = true;
72
74 bool catch_PETSc = true;
75
77 bool catch_SAMRAI = true;
78
80 bool catch_HDF5 = true;
81
83 bool catch_exit = true;
84
86 std::function<void( StackTrace::abort_error & )> error_handler = nullptr;
87
97
108
117
118private:
119 friend class AMPManager;
120};
121
122
132{
133public:
139 static void startup( int &argc,
140 char *argv[],
141 const AMPManagerProperties &properties = AMPManagerProperties() );
142
148 static void shutdown();
149
151 static void restart();
152
154 static bool isInitialized();
155
157 static bool isFinalized();
158
162 static std::tuple<int, const char *const *> get_args();
163
166
168 static void terminate_AMP( std::string message );
169
171 static void setHandlers();
172
174 static void clearHandlers();
175
177 static void setMPIErrorHandler();
178
180 static void clearMPIErrorHandler();
181
190 static std::array<int, 3> revision();
191
193 static std::string info();
194
196 static void incrementResource( const std::string &resource );
197
199 static void decrementResource( const std::string &resource );
200
202 static const AMP::AMP_MPI &getCommWorld();
203
205 static void setCommWorld( const AMP::AMP_MPI & );
206
208 static void registerShutdown( std::function<void()> );
209
210private:
211 // Private constructor (we do not actually want to create an object)
212 AMPManager() = delete;
213
214 // Static variables
215 static int d_initialized;
216 static int d_argc;
217 static const char *const *d_argv;
219 static std::vector<std::function<void()>> d_atShutdown;
220
221 // Function to control exit behavior
222 static void exitFun();
223
224 // Functions to start/shutdown the various packages
225 static double start_SAMRAI();
226 static double start_PETSc();
227 static double start_HYPRE();
228 static double initDevices();
229 static double bindDevices();
230 static double start_OpenMP();
231 static double stop_SAMRAI();
232 static double stop_HYPRE();
233 static double stop_PETSc();
234
235 // wrapper for shutting and restarting SAMRAI
236 static void restart_SAMRAI();
237
238 // Functions to set error handlers for specific packages
241};
242
243} // namespace AMP
244
245#endif
Class AMPManagerProperties is a class that contains the various startup options for AMP.
Definition AMPManager.h:26
std::set< int > catch_signals
The set of unhandled signals to set (will be initialized to a default set)
Definition AMPManager.h:68
bool initialize_device
Initialize CUDA/HIP device (default is true)
Definition AMPManager.h:50
bool print_times
Print the time required to initialize or shutdown each package. Default is false.
Definition AMPManager.h:41
AMP_MPI::Comm COMM_WORLD
Definition AMPManager.h:96
bool print_startup
Print version information upon startup (default is false)
Definition AMPManager.h:44
int print_memory
Print memory statistics (default is only if leaks detected)
Definition AMPManager.h:47
AMPManagerProperties()
Empty constructor. This creates the default startup parameters.
bool catch_exit
Catch early exit.
Definition AMPManager.h:83
std::function< void(StackTrace::abort_error &)> error_handler
Set a user-provided function for handling all errors.
Definition AMPManager.h:86
int profile_MPI_level
The default level for the MPI timers. Default is 2.
Definition AMPManager.h:56
bool bind_process_to_accelerator
Associate each accelerator with a single MPI rank (default is true)
Definition AMPManager.h:53
bool catch_HDF5
Set error handlers for HDF5 routines.
Definition AMPManager.h:80
bool catch_PETSc
Set error handlers for PETSc routines.
Definition AMPManager.h:74
bool catch_SAMRAI
Set error handlers for SAMRAI routines.
Definition AMPManager.h:77
bool catch_MPI
Set error handlers for MPI routines.
Definition AMPManager.h:71
Class AMPManager is a utility for managing startup and shutdown for AMP applications and for changing...
Definition AMPManager.h:132
static void setMPIErrorHandler()
Initialize the mpi error handler.
static void shutdown()
static std::array< int, 3 > revision()
AMP version number.
static void decrementResource(const std::string &resource)
Decrement a resource counter.
static double start_PETSc()
static void restart()
Restart as much of AMP as possible restoring it to a like new state.
static void setCommWorld(const AMP::AMP_MPI &)
Set the global comm.
static void terminate_AMP(std::string message)
Static function to terminate AMP.
static void setHandlers()
Set the default signal/terminate handlers (called on startup)
static double start_SAMRAI()
static void set_PETSc_error_handler()
static bool isInitialized()
Function to check if AMP has been initialized.
static std::vector< std::function< void()> > d_atShutdown
Definition AMPManager.h:219
static const AMP::AMP_MPI & getCommWorld()
Get the global comm.
static AMPManagerProperties getAMPManagerProperties()
Function to return the AMPManagerProperties that was used to initialize AMP.
static int d_argc
Definition AMPManager.h:216
static void clear_PETSc_error_handler()
static int d_initialized
Definition AMPManager.h:215
AMPManager()=delete
static double bindDevices()
static void restart_SAMRAI()
static void clearMPIErrorHandler()
Destroy the mpi error handler.
static double start_HYPRE()
static void exitFun()
static void incrementResource(const std::string &resource)
Increment a resource counter.
static double start_OpenMP()
static void clearHandlers()
Clearthe default signal/terminate handlers (called on shutdown)
static double stop_SAMRAI()
static bool isFinalized()
Function to check if AMP has been finalized.
static void registerShutdown(std::function< void()>)
Register a function to perform cleanup at AMP::AMPManager::shutdown.
static const char *const * d_argv
Definition AMPManager.h:217
static void startup(int &argc, char *argv[], const AMPManagerProperties &properties=AMPManagerProperties())
static double stop_HYPRE()
static std::string info()
Return detailed revision information.
static double stop_PETSc()
static std::tuple< int, const char *const * > get_args()
static AMPManagerProperties d_properties
Definition AMPManager.h:218
static double initDevices()
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
MPI_Comm Comm
Definition AMP_MPI.h:68



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page