Skip to content

Commit 0238f5e

Browse files
committed
Environment variable: AMREX_THE_ARENA_INIT_SIZE
We can now set the default value of amrex.the_arena_init_size with an environment variable. This is convenient for CI jobs.
1 parent af55290 commit 0238f5e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Docs/sphinx_documentation/source/GPU.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,12 @@ 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.
568+
The default initial size for other arenas is 8388608 (i.e., 8 MB). For
565569
:cpp:`The_Managed_Arena()` and :cpp:`The_Device_Arena()`, it can be changed
566570
with ``amrex.the_managed_arena_init_size`` and
567571
``amrex.the_device_arena_init_size``, respectively, if they are not an alias

Src/Base/AMReX_Arena.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ Arena::Initialize (bool minimal)
362362
the_pinned_arena_release_threshold = Gpu::Device::totalGlobalMem() / Gpu::Device::numDevicePartners() / 2L;
363363
#endif
364364

365+
// Overwrite the initial size with environment variables
366+
if (char const* init_size_p = std::getenv("AMREX_THE_ARENA_INIT_SIZE")) {
367+
the_arena_init_size = std::stoi(init_size_p);
368+
}
369+
365370
ParmParse pp("amrex");
366371
pp.queryAdd( "the_arena_init_size", the_arena_init_size);
367372
pp.queryAdd( "the_device_arena_init_size", the_device_arena_init_size);

0 commit comments

Comments
 (0)