1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* Copyright 2020 Axel Huebl
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/
#include "Initialization/WarpXAMReXInit.H"
#include <AMReX.H>
#include <AMReX_ParmParse.H>
#include <memory>
namespace {
/** Overwrite defaults in AMReX Inputs
*
* This overwrites defaults in amrex::ParmParse for inputs.
*/
void
overwrite_amrex_parser_defaults ()
{
amrex::ParmParse pp_amrex("amrex");
// https://amrex-codes.github.io/amrex/docs_html/GPU.html#inputs-parameters
bool abort_on_out_of_gpu_memory = true; // AMReX' default: false
pp_amrex.queryAdd("abort_on_out_of_gpu_memory", abort_on_out_of_gpu_memory);
bool the_arena_is_managed = false; // AMReX' default: true
pp_amrex.queryAdd("the_arena_is_managed", the_arena_is_managed);
// Work-around:
// If warpx.numprocs is used for the domain decomposition, we will not use blocking factor
// to generate grids. Nonetheless, AMReX has asserts in place that validate that the
// number of cells is a multiple of blocking factor. We set the blocking factor to 1 so those
// AMReX asserts will always pass.
const amrex::ParmParse pp_warpx("warpx");
if (pp_warpx.contains("numprocs"))
{
amrex::ParmParse pp_amr("amr");
pp_amr.add("blocking_factor", 1);
}
// Here we override the default tiling option for particles, which is always
// "false" in AMReX, to "false" if compiling for GPU execution and "true"
// if compiling for CPU.
{
amrex::ParmParse pp_particles("particles");
#ifdef AMREX_USE_GPU
bool do_tiling = false; // By default, tiling is off on GPU
#else
bool do_tiling = true;
#endif
pp_particles.queryAdd("do_tiling", do_tiling);
}
}
}
namespace warpx::initialization
{
amrex::AMReX*
amrex_init (int& argc, char**& argv, bool build_parm_parse)
{
return amrex::Initialize(
argc,
argv,
build_parm_parse,
MPI_COMM_WORLD,
::overwrite_amrex_parser_defaults
);
}
}
|