4#include <AMReX_Config.H>
51 constexpr bool NDebug =
false;
52 constexpr bool Debug =
true;
87 [[nodiscard]] std::string
Version ();
111 std::ostream& a_osout = std::cout,
112 std::ostream& a_oserr = std::cerr,
114 int a_device_id = -1);
147 const std::function<
void()>& func_parm_parse,
148 std::ostream& a_osout = std::cout,
149 std::ostream& a_oserr = std::cerr,
151 int a_device_id = -1);
156 void (*func_parm_parse) (),
157 std::ostream& a_osout = std::cout,
158 std::ostream& a_oserr = std::cerr,
160 int a_device_id = -1)
162 return Initialize(argc, argv, std::function<
void()>(func_parm_parse),
163 a_osout, a_oserr, a_errhandler, a_device_id);
201 AMReX*
Initialize (
int& argc,
char**& argv,
bool build_parm_parse=
true,
203 const std::function<
void()>& func_parm_parse = {},
204 std::ostream& a_osout = std::cout,
205 std::ostream& a_oserr = std::cerr,
207 int a_device_id = -1);
271 template <
class... Ts>
279 void Error (
const std::string& msg);
291 void Error_host (
const char* type,
const char* msg);
295 void Error (
const char* msg =
nullptr) {
311 void Warning (
const std::string& msg);
334 void Abort (
const std::string& msg);
338 void Abort (
const char * msg =
nullptr) {
362 void Assert_host (
const char* EX,
const char* file,
int line,
const char* msg,
363 std::size_t msg_size=0);
378 void Assert (
const char* EX,
const char* file,
int line) {
379#if defined(NDEBUG) && !defined(AMREX_USE_ASSERTION)
404 void Assert (
const char* EX,
const char* file,
int line,
const char* msg) {
405#if defined(NDEBUG) && !defined(AMREX_USE_ASSERTION)
410 EX, file, line, msg);
419 void Assert (
const char* EX,
const char* file,
int line,
const std::string& msg) {
445 [[nodiscard]]
int Verbose () noexcept;
453 [[nodiscard]]
bool InitSNaN () noexcept;
476 std::allocator<bool> a_b;
477 std::allocator<char> a_c;
478 std::allocator<int> a_i;
479 std::allocator<long> a_l;
480 std::allocator<long long> a_ll;
481 std::allocator<unsigned char> a_uc;
482 std::allocator<unsigned int> a_ui;
483 std::allocator<unsigned long> a_ul;
484 std::allocator<unsigned long long> a_ull;
485 std::allocator<float> a_f;
486 std::allocator<double> a_d;
487 std::allocator<std::string> a_s;
524 static bool empty () noexcept {
return m_instance.empty(); }
527 static int size () noexcept {
return static_cast<int>(m_instance.size()); }
530 static AMReX*
top () noexcept {
return m_instance.back().get(); }
542 static void push (std::unique_ptr<AMReX> pamrex);
552 static AMREX_EXPORT std::vector<std::unique_ptr<AMReX> > m_instance;
571 using T = std::underlying_type_t<FPExcept>;
573 return static_cast<FPExcept>(
static_cast<T
>(a) |
static_cast<T
>(b));
579 using T = std::underlying_type_t<FPExcept>;
580 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:223
Assertions for GPU device code.
#define AMREX_DEVICE_ASSERT(flag)
Assert flag in CUDA, HIP, or SYCL device code.
Definition AMReX_GpuAssert.H:27
#define AMREX_DEVICE_PRINTF(...)
Definition AMReX_GpuPrint.H:15
#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:514
static bool empty() noexcept
True if no AMReX instances are registered on the stack.
Definition AMReX.H:524
static int size() noexcept
Number of managed instances currently tracked (Initialize depth).
Definition AMReX.H:527
AMReX(AMReX const &)=delete
static void erase(AMReX *pamrex)
Remove a specific instance pointer from the internal stack.
Definition AMReX.cpp:1054
Geometry * getDefaultGeometry() noexcept
Geometry owned by this context (constructed with the AMReX object).
Definition AMReX.H:548
static void push(AMReX *pamrex)
Transfer ownership of an existing AMReX* into the stack.
Definition AMReX.cpp:1035
~AMReX()
Definition AMReX.cpp:1029
AMReX()
Definition AMReX.cpp:1024
AMReX & operator=(AMReX const &)=delete
static AMReX * top() noexcept
Pointer to the most recently pushed instance.
Definition AMReX.H:530
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:85
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:126
bool abort_on_unused_inputs
Definition AMReX.cpp:125
bool handle_crt_reports
Definition AMReX.cpp:121
bool handle_sigfpe
Definition AMReX.cpp:119
bool call_addr2line
Definition AMReX.cpp:122
bool signal_handling
Definition AMReX.cpp:114
bool throw_exception
Definition AMReX.cpp:123
bool handle_sigsegv
Definition AMReX.cpp:115
bool handle_sigint
Definition AMReX.cpp:117
std::ostream * oserr
Definition AMReX.cpp:127
bool regtest_reduction
Definition AMReX.cpp:124
bool handle_sigterm
Definition AMReX.cpp:116
ErrorHandler error_handler
Definition AMReX.cpp:128
bool handle_sigabrt
Definition AMReX.cpp:118
int verbose
Definition AMReX.cpp:113
bool handle_sigill
Definition AMReX.cpp:120
std::string exename
Definition AMReX.cpp:112
constexpr bool NDebug
Definition AMReX.H:48
constexpr bool Debug
Definition AMReX.H:49
bool init_snan
Definition AMReX.cpp:132
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:378
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
std::string get_command()
Get the entire command line including the executable path.
Definition AMReX.cpp:1000
void write_to_stderr_without_buffering(const char *str)
Write directly to stderr after flushing standard I/O buffers.
Definition AMReX.cpp:203
int command_argument_count()
Get the number of command line arguments excluding argv[0].
Definition AMReX.cpp:1006
void SetVerbose(int v) noexcept
Override the verbosity level used by amrex::Print().
Definition AMReX.cpp:186
std::ostream & ErrorStream()
Stream that receives diagnostic output (defaults to std::cerr).
Definition AMReX.cpp:994
FPExcept
Definition AMReX.H:557
void Init_minimal(MPI_Comm mpi_comm)
Minimal initialization for utilities that need only part of AMReX.
Definition AMReX.cpp:1187
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:192
bool InitSNaN() noexcept
Whether new allocations are filled with signaling NaNs when enabled.
Definition AMReX.cpp:188
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:346
std::string get_command_argument(int number)
Fetch a copy of argv[number] (argv[0] is the executable path).
Definition AMReX.cpp:1012
void Finalize()
Convenience overload that finalizes the instance at the top of the stack.
Definition AMReX.cpp:835
void Finalize_minimal()
Finalize a run that was initialized via Init_minimal().
Definition AMReX.cpp:1197
bool any(FPExcept a)
Return true when a is not FPExcept::none (i.e., the mask is non-empty).
Definition AMReX.H:566
FPExcept operator|(FPExcept a, FPExcept b)
Bitwise union of two floating-point exception masks.
Definition AMReX.H:569
void Error_host(const char *type, const char *msg)
Host-side error sink invoked by GPU-friendly overloads.
Definition AMReX.cpp:256
FPExcept setFPExcept(FPExcept excepts)
Definition AMReX.cpp:1134
void GccPlacater()
Definition AMReX.H:474
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:238
void Warning_host(const char *msg)
Print a warning message to the diagnostic stream (host only).
Definition AMReX.cpp:278
void SetInitSNaN(bool v) noexcept
Toggle whether new allocations are initialized with signaling NaNs.
Definition AMReX.cpp:190
FPExcept operator&(FPExcept a, FPExcept b)
Bitwise intersection of two floating-point exception masks.
Definition AMReX.H:577
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:184
void Warning(const std::string &msg)
Print a warning message to the diagnostic stream and keep running.
Definition AMReX.cpp:250
void ExecOnInitialize(std::function< void()> func)
Register a callback invoked early in Initialize().
Definition AMReX.cpp:340
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:244
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:988
FPExcept getFPExcept()
Definition AMReX.cpp:1120
FPExcept disableFPExcept(FPExcept excepts)
Disable FP exceptions. Linux and macOS only; a no-op elsewhere, including musl-based Linux.
Definition AMReX.cpp:1153
FPExcept enableFPExcept(FPExcept excepts)
Enable FP exceptions. Linux and macOS only; a no-op elsewhere, including musl-based Linux.
Definition AMReX.cpp:1170
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:286
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:829
void ExecOnFinalize(std::function< void()> func)
Register a callback invoked during Finalize() (LIFO order).
Definition AMReX.cpp:334