1 #ifndef AMREX_FORKJOIN_H
2 #define AMREX_FORKJOIN_H
3 #include <AMReX_Config.H>
60 reg_mf(mf, name, 0, strategy, intent, owner);
69 "const MultiFab must be registered read-only");
70 reg_mf(
const_cast<MultiFab&
>(mf), name, idx, strategy, intent, owner);
74 reg_mf(mf, name, 0, strategy, intent, owner);
80 for (
int i = 0; i < mfs.
size(); ++i) {
81 reg_mf(*mfs[i], name, i, strategy, intent, owner);
89 for (
int i = 0; i < mfs.
size(); ++i) {
90 reg_mf(*mfs[i], name, i, strategy, intent, owner);
116 int dim =
static_cast<int>(
data.at(name).size());
118 for (
int idx = 0; idx < dim; ++idx) {
119 result[idx] = &
get_mf(name, idx);
138 const int io_rank = 0;
147 MPI_Comm_free(&task_comm);
175 [[nodiscard]]
bool empty()
const {
return orig ==
nullptr; }
182 std::map<BoxArray::RefID, Vector<std::unique_ptr<DistributionMapping>>>
dms;
183 std::unordered_map<std::string, Vector<MFFork>>
data;
#define AMREX_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: AMReX_BLassert.H:37
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
int MPI_Comm
Definition: AMReX_ccse-mpi.H:47
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
Definition: AMReX_ForkJoin.H:12
ForkJoin(const Vector< int > &task_rank_n)
Definition: AMReX_ForkJoin.cpp:46
int NTasks() const
Definition: AMReX_ForkJoin.H:40
std::unordered_map< std::string, Vector< MFFork > > data
Definition: AMReX_ForkJoin.H:183
ForkJoin(int ntasks)
Definition: AMReX_ForkJoin.H:37
void fork_join(const F &fn)
Definition: AMReX_ForkJoin.H:135
void reg_mf(const MultiFab &mf, const std::string &name, int idx, Strategy strategy, Intent intent, int owner=-1)
Definition: AMReX_ForkJoin.H:66
Intent
Definition: AMReX_ForkJoin.H:20
int NProcsTask(int task) const
Definition: AMReX_ForkJoin.H:50
void reg_mf_vec(const Vector< MultiFab * > &mfs, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
Definition: AMReX_ForkJoin.H:77
void reg_mf(MultiFab &mf, const std::string &name, int idx, Strategy strategy, Intent intent, int owner=-1)
Definition: AMReX_ForkJoin.cpp:107
Vector< int > split_bounds
task i has ranks over the interval [result[i], result[i+1])
Definition: AMReX_ForkJoin.H:180
std::map< BoxArray::RefID, Vector< std::unique_ptr< DistributionMapping > > > dms
DM cache.
Definition: AMReX_ForkJoin.H:182
Strategy
Definition: AMReX_ForkJoin.H:15
@ duplicate
all tasks get a copy of whole MF
@ single
one task gets a copy of whole MF
@ split
split MF components across tasks
void copy_data_to_tasks()
Definition: AMReX_ForkJoin.cpp:179
MultiFab & get_mf(const std::string &name, int idx=0)
Definition: AMReX_ForkJoin.H:108
void modify_ngrow(const std::string &name, IntVect ngrow)
Definition: AMReX_ForkJoin.H:96
Vector< MultiFab * > get_mf_vec(const std::string &name)
vector of pointers to all MFs under a name
Definition: AMReX_ForkJoin.H:115
bool flag_verbose
for debugging
Definition: AMReX_ForkJoin.H:178
void modify_ngrow(const std::string &name, int idx, IntVect ngrow)
modify the number of grow cells associated with the multifab
Definition: AMReX_ForkJoin.cpp:141
void set_task_output_dir(const std::string &dir)
Definition: AMReX_ForkJoin.H:124
ComponentSet ComponentBounds(const std::string &name, int idx=0) const
Definition: AMReX_ForkJoin.cpp:171
void reg_mf(const MultiFab &mf, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
Definition: AMReX_ForkJoin.H:72
bool Verbose() const
Definition: AMReX_ForkJoin.H:44
std::string task_output_dir
where to write task output
Definition: AMReX_ForkJoin.H:184
const DistributionMapping & get_dm(const BoxArray &ba, int task_idx, const DistributionMapping &dm_orig)
Definition: AMReX_ForkJoin.cpp:283
int task_me
which forked task the rank belongs to
Definition: AMReX_ForkJoin.H:181
void SetVerbose(bool verbose_in)
Definition: AMReX_ForkJoin.H:46
static void set_task_output_file(const std::string &filename)
Definition: AMReX_ForkJoin.H:129
void modify_split(const std::string &name, int idx, Vector< ComponentSet > comp_split)
modify how the multifab is split along components across the tasks
Definition: AMReX_ForkJoin.cpp:155
void create_task_output_dir()
create the task output directory
Definition: AMReX_ForkJoin.cpp:349
void copy_data_from_tasks()
Definition: AMReX_ForkJoin.cpp:241
bool flag_invoked
track if object has been invoked yet
Definition: AMReX_ForkJoin.H:179
void reg_mf_vec(const Vector< MultiFab const * > &mfs, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
overload in case of vector of pointer to const MultiFab
Definition: AMReX_ForkJoin.H:86
std::string get_io_filename(bool flag_unique=false)
unique output file for this sub-task
Definition: AMReX_ForkJoin.cpp:364
void reg_mf(MultiFab &mf, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
Definition: AMReX_ForkJoin.H:58
int MyTask() const
Definition: AMReX_ForkJoin.H:42
void modify_split(const std::string &name, Vector< ComponentSet > comp_split)
Definition: AMReX_ForkJoin.H:102
MPI_Comm split_tasks()
split top frame of stack
Definition: AMReX_ForkJoin.cpp:327
void init(const Vector< int > &task_rank_n)
Definition: AMReX_ForkJoin.cpp:69
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Long size() const noexcept
Definition: AMReX_Vector.H:50
void push(MPI_Comm c)
Definition: AMReX_ParallelContext.H:102
void pop()
Note that it's the user's responsibility to free the MPI_Comm.
Definition: AMReX_ParallelContext.H:108
void set_last_frame_ofs(const std::string &filename)
Definition: AMReX_ParallelContext.H:104
Definition: AMReX_Amr.cpp:49
if strategy == split, use this to specify how to split components across tasks
Definition: AMReX_ForkJoin.H:23
int lo
inclusive bound
Definition: AMReX_ForkJoin.H:29
ComponentSet(int lo_, int hi_)
Definition: AMReX_ForkJoin.H:28
int hi
exclusive bound
Definition: AMReX_ForkJoin.H:30
Definition: AMReX_ForkJoin.H:155
Vector< ComponentSet > comp_split
if strategy == split, how to split components to tasks
Definition: AMReX_ForkJoin.H:161
Vector< MultiFab > forked
holds new multifab for each task in fork
Definition: AMReX_ForkJoin.H:162
bool empty() const
Definition: AMReX_ForkJoin.H:175
MFFork(MultiFab *omf, Strategy s, Intent i, int own, const IntVect &ng, Vector< ComponentSet > cs)
Definition: AMReX_ForkJoin.H:170
Strategy strategy
Definition: AMReX_ForkJoin.H:157
MFFork(const MFFork &)=delete
MFFork(MFFork &&)=default
int owner_task
only used if strategy == single or duplicate
Definition: AMReX_ForkJoin.H:159
IntVect ngrow
Definition: AMReX_ForkJoin.H:160
MFFork & operator=(const MFFork &)=delete
Intent intent
Definition: AMReX_ForkJoin.H:158
MultiFab * orig
Definition: AMReX_ForkJoin.H:156