Skip to content

Commit b7bd986

Browse files
committed
Merge branch 'env_init_size' into gitlab-ci
2 parents a1f8adb + 791d7a4 commit b7bd986

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Docs/sphinx_documentation/source/GPU.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,16 @@ to :cpp:`The_Arena()` to reduce memory fragmentation.
560560
In :cpp:`amrex::Initialize`, a large amount of GPU device memory is
561561
allocated and is kept in :cpp:`The_Arena()`. The default is 3/4 of the
562562
total device memory, and it can be changed with a :cpp:`ParmParse`
563-
parameter, ``amrex.the_arena_init_size``, in the unit of bytes. The default
564-
initial size for other arenas is 8388608 (i.e., 8 MB). For
563+
parameter, ``amrex.the_arena_init_size``, in the unit of bytes. The default
564+
can also be changed with an environment variable
565+
``AMREX_THE_ARENA_INIT_SIZE=X``, where ``X`` is the number of bytes. When
566+
both the :cpp:`ParmParse` parameter and the environment variable are
567+
present, the former will override the latter. In both cases, the number
568+
string could have optional single quotes ``'`` as separators (e.g.,
569+
``10'000'000'000``). It may also use floating-point notation (``2.5e10``),
570+
as long as converting it does not introduce any loss of precision.
571+
572+
The default initial size for other arenas is 8388608 (i.e., 8 MB). For
565573
:cpp:`The_Managed_Arena()` and :cpp:`The_Device_Arena()`, it can be changed
566574
with ``amrex.the_managed_arena_init_size`` and
567575
``amrex.the_device_arena_init_size``, respectively, if they are not an alias

Src/Base/AMReX_Arena.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <AMReX.H>
88
#include <AMReX_BLProfiler.H>
9+
#include <AMReX_IParser.H>
910
#include <AMReX_Print.H>
1011
#include <AMReX_ParallelDescriptor.H>
1112
#include <AMReX_ParmParse.H>
@@ -364,7 +365,9 @@ Arena::Initialize (bool minimal)
364365

365366
// Overwrite the initial size with environment variables
366367
if (char const* init_size_p = std::getenv("AMREX_THE_ARENA_INIT_SIZE")) {
367-
the_arena_init_size = std::stoi(init_size_p);
368+
IParser iparser(init_size_p);
369+
auto exe = iparser.compileHost<0>();
370+
the_arena_init_size = exe();
368371
}
369372

370373
ParmParse pp("amrex");

0 commit comments

Comments
 (0)