4#include <AMReX_Config.H>
51 constexpr bool NDebug =
false;
52 constexpr bool Debug =
true;
86 [[nodiscard]] std::string
Version ();
110 std::ostream& a_osout = std::cout,
111 std::ostream& a_oserr = std::cerr,
113 int a_device_id = -1);
146 const std::function<
void()>& func_parm_parse,
147 std::ostream& a_osout = std::cout,
148 std::ostream& a_oserr = std::cerr,
150 int a_device_id = -1);
187 AMReX*
Initialize (
int& argc,
char**& argv,
bool build_parm_parse=
true,
189 const std::function<
void()>& func_parm_parse = {},
190 std::ostream& a_osout = std::cout,
191 std::ostream& a_oserr = std::cerr,
193 int a_device_id = -1);
257 template <
class... Ts>
265 void Error (
const std::string& msg);
277 void Error_host (
const char* type,
const char* msg);
281 void Error (
const char* msg =
nullptr) {
297 void Warning (
const std::string& msg);
320 void Abort (
const std::string& msg);
324 void Abort (
const char * msg =
nullptr) {
348 void Assert_host (
const char* EX,
const char* file,
int line,
const char* msg,
349 std::size_t msg_size=0);
364 void Assert (
const char* EX,
const char* file,
int line) {
365#if defined(NDEBUG) && !defined(AMREX_USE_ASSERTION)
390 void Assert (
const char* EX,
const char* file,
int line,
const char* msg) {
391#if defined(NDEBUG) && !defined(AMREX_USE_ASSERTION)
396 EX, file, line, msg);
405 void Assert (
const char* EX,
const char* file,
int line,
const std::string& msg) {
431 [[nodiscard]]
int Verbose () noexcept;
439 [[nodiscard]]
bool InitSNaN () noexcept;
462 std::allocator<bool> a_b;
463 std::allocator<char> a_c;
464 std::allocator<int> a_i;
465 std::allocator<long> a_l;
466 std::allocator<long long> a_ll;
467 std::allocator<unsigned char> a_uc;
468 std::allocator<unsigned int> a_ui;
469 std::allocator<unsigned long> a_ul;
470 std::allocator<unsigned long long> a_ull;
471 std::allocator<float> a_f;
472 std::allocator<double> a_d;
473 std::allocator<std::string> a_s;
510 static bool empty () noexcept {
return m_instance.empty(); }
513 static int size () noexcept {
return static_cast<int>(m_instance.size()); }
516 static AMReX*
top () noexcept {
return m_instance.back().get(); }
528 static void push (std::unique_ptr<AMReX> pamrex);
538 static AMREX_EXPORT std::vector<std::unique_ptr<AMReX> > m_instance;
557 using T = std::underlying_type_t<FPExcept>;
559 return static_cast<FPExcept>(
static_cast<T
>(a) |
static_cast<T
>(b));
565 using T = std::underlying_type_t<FPExcept>;
566 return static_cast<FPExcept>(
static_cast<T
>(a) &
static_cast<T
>(b));
Compiler- and backend-specific extension macros (e.g., restrict, SIMD, inline).
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_EXPORT
Definition AMReX_Extension.H:196
#define AMREX_DEVICE_ASSERT(flag)
Definition AMReX_GpuAssert.H:16
#define AMREX_DEVICE_PRINTF(...)
Definition AMReX_GpuPrint.H:21
#define AMREX_IF_ON_DEVICE(CODE)
Definition AMReX_GpuQualifiers.H:56
#define AMREX_IF_ON_HOST(CODE)
Definition AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Runtime context stored for each active amrex::Initialize() call.
Definition AMReX.H:500
static bool empty() noexcept
True if no AMReX instances are registered on the stack.
Definition AMReX.H:510
static int size() noexcept
Number of managed instances currently tracked (Initialize depth).
Definition AMReX.H:513
AMReX(AMReX const &)=delete
static void erase(AMReX *pamrex)
Remove a specific instance pointer from the internal stack.
Definition AMReX.cpp:1030
Geometry * getDefaultGeometry() noexcept
Geometry owned by this context (constructed with the AMReX object).
Definition AMReX.H:534
static void push(AMReX *pamrex)
Transfer ownership of an existing AMReX* into the stack.
Definition AMReX.cpp:1011
~AMReX()
Definition AMReX.cpp:1005
AMReX()
Definition AMReX.cpp:1000
AMReX & operator=(AMReX const &)=delete
static AMReX * top() noexcept
Pointer to the most recently pushed instance.
Definition AMReX.H:516
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:75
int MPI_Comm
Definition AMReX_ccse-mpi.H:51
static constexpr int MPI_COMM_WORLD
Definition AMReX_ccse-mpi.H:58
std::ostream * osout
Definition AMReX.cpp:123
bool abort_on_unused_inputs
Definition AMReX.cpp:122
bool handle_sigfpe
Definition AMReX.cpp:117
bool call_addr2line
Definition AMReX.cpp:119
bool signal_handling
Definition AMReX.cpp:112
bool throw_exception
Definition AMReX.cpp:120
bool handle_sigsegv
Definition AMReX.cpp:113
bool handle_sigint
Definition AMReX.cpp:115
std::ostream * oserr
Definition AMReX.cpp:124
bool regtest_reduction
Definition AMReX.cpp:121
bool handle_sigterm
Definition AMReX.cpp:114
ErrorHandler error_handler
Definition AMReX.cpp:125
bool handle_sigabrt
Definition AMReX.cpp:116
int verbose
Definition AMReX.cpp:111
bool handle_sigill
Definition AMReX.cpp:118
std::string exename
Definition AMReX.cpp:110
constexpr bool NDebug
Definition AMReX.H:48
constexpr bool Debug
Definition AMReX.H:49
bool init_snan
Definition AMReX.cpp:129
Definition AMReX_Amr.cpp:50
__host__ __device__ void Assert(const char *EX, const char *file, int line)
Device/host assertion helper used by BL_ASSERT.
Definition AMReX.H:364
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
std::string get_command()
Get the entire command line including the executable path.
Definition AMReX.cpp:976
void write_to_stderr_without_buffering(const char *str)
Write directly to stderr after flushing standard I/O buffers.
Definition AMReX.cpp:200
int command_argument_count()
Get the number of command line arguments excluding argv[0].
Definition AMReX.cpp:982
void SetVerbose(int v) noexcept
Override the verbosity level used by amrex::Print().
Definition AMReX.cpp:183
std::ostream & ErrorStream()
Stream that receives diagnostic output (defaults to std::cerr).
Definition AMReX.cpp:970
FPExcept
Definition AMReX.H:543
void Init_minimal(MPI_Comm mpi_comm)
Minimal initialization for utilities that need only part of AMReX.
Definition AMReX.cpp:1099
void(*)() PTR_TO_VOID_FUNC
Definition AMReX.H:41
void SetErrorHandler(ErrorHandler f)
Install a custom error handler invoked by amrex::Error_host.
Definition AMReX.cpp:189
bool InitSNaN() noexcept
Whether new allocations are filled with signaling NaNs when enabled.
Definition AMReX.cpp:185
AMReX * Initialize(MPI_Comm mpi_comm, std::ostream &a_osout=std::cout, std::ostream &a_oserr=std::cerr, ErrorHandler a_errhandler=nullptr, int a_device_id=-1)
Initialize AMReX using an existing MPI communicator.
Definition AMReX.cpp:343
std::string get_command_argument(int number)
Fetch a copy of argv[number] (argv[0] is the executable path).
Definition AMReX.cpp:988
void Finalize()
Convenience overload that finalizes the instance at the top of the stack.
Definition AMReX.cpp:818
void Finalize_minimal()
Finalize a run that was initialized via Init_minimal().
Definition AMReX.cpp:1109
bool any(FPExcept a)
Return true when a is not FPExcept::none (i.e., the mask is non-empty).
Definition AMReX.H:552
FPExcept operator|(FPExcept a, FPExcept b)
Bitwise union of two floating-point exception masks.
Definition AMReX.H:555
void Error_host(const char *type, const char *msg)
Host-side error sink invoked by GPU-friendly overloads.
Definition AMReX.cpp:253
FPExcept setFPExcept(FPExcept excepts)
Definition AMReX.cpp:1052
void GccPlacater()
Definition AMReX.H:460
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:235
void Warning_host(const char *msg)
Print a warning message to the diagnostic stream (host only).
Definition AMReX.cpp:275
void SetInitSNaN(bool v) noexcept
Toggle whether new allocations are initialized with signaling NaNs.
Definition AMReX.cpp:187
FPExcept operator&(FPExcept a, FPExcept b)
Bitwise intersection of two floating-point exception masks.
Definition AMReX.H:563
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:181
void Warning(const std::string &msg)
Print a warning message to the diagnostic stream and keep running.
Definition AMReX.cpp:247
void ExecOnInitialize(std::function< void()> func)
Register a callback invoked early in Initialize().
Definition AMReX.cpp:337
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
std::string Version()
Return the AMReX version string reported by git describe.
Definition AMReX_Version.cpp:9
std::ostream & OutStream()
Stream that receives informational output (defaults to std::cout).
Definition AMReX.cpp:964
FPExcept getFPExcept()
Return currently enabled FP exceptions. Linux only.
Definition AMReX.cpp:1040
FPExcept disableFPExcept(FPExcept excepts)
Disable FP exceptions. Linux Only.
Definition AMReX.cpp:1069
FPExcept enableFPExcept(FPExcept excepts)
Enable FP exceptions. Linux Only.
Definition AMReX.cpp:1084
void Assert_host(const char *EX, const char *file, int line, const char *msg, std::size_t msg_size=0)
Host-side assertion helper used by BL_ASSERT().
Definition AMReX.cpp:283
void(*)(const char *) ErrorHandler
Definition AMReX.H:42
bool Initialized()
Returns true if there are any currently-active and initialized AMReX instances (i....
Definition AMReX.cpp:812
void ExecOnFinalize(std::function< void()> func)
Register a callback invoked during Finalize() (LIFO order).
Definition AMReX.cpp:331