Block-Structured AMR Software Framework
amrex::ForkJoin Class Reference

#include <AMReX_ForkJoin.H>

Classes

struct  ComponentSet
 if strategy == split, use this to specify how to split components across tasks More...
 
struct  MFFork
 

Public Types

enum class  Strategy { single , duplicate , split }
 
enum class  Intent { in , out , inout }
 

Public Member Functions

 ForkJoin (const Vector< int > &task_rank_n)
 
 ForkJoin (const Vector< double > &task_rank_pct)
 
 ForkJoin (int ntasks)
 
int NTasks () const
 
int MyTask () const
 
bool Verbose () const
 
void SetVerbose (bool verbose_in)
 
ComponentSet ComponentBounds (const std::string &name, int idx=0) const
 
int NProcsTask (int task) const
 
void reg_mf (MultiFab &mf, const std::string &name, int idx, Strategy strategy, Intent intent, int owner=-1)
 
void reg_mf (MultiFab &mf, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
 
void reg_mf (const MultiFab &mf, const std::string &name, int idx, Strategy strategy, Intent intent, int owner=-1)
 
void reg_mf (const MultiFab &mf, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
 
void reg_mf_vec (const Vector< MultiFab * > &mfs, const std::string &name, Strategy strategy, Intent intent, int owner=-1)
 
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 More...
 
void modify_ngrow (const std::string &name, int idx, IntVect ngrow)
 modify the number of grow cells associated with the multifab More...
 
void modify_ngrow (const std::string &name, IntVect ngrow)
 
void modify_split (const std::string &name, int idx, Vector< ComponentSet > comp_split)
 modify how the multifab is split along components across the tasks More...
 
void modify_split (const std::string &name, Vector< ComponentSet > comp_split)
 
MultiFabget_mf (const std::string &name, int idx=0)
 
Vector< MultiFab * > get_mf_vec (const std::string &name)
 vector of pointers to all MFs under a name More...
 
void set_task_output_dir (const std::string &dir)
 
template<class F >
void fork_join (const F &fn)
 

Static Public Member Functions

static void set_task_output_file (const std::string &filename)
 

Private Member Functions

void init (const Vector< int > &task_rank_n)
 
const DistributionMappingget_dm (const BoxArray &ba, int task_idx, const DistributionMapping &dm_orig)
 
void copy_data_to_tasks ()
 
void copy_data_from_tasks ()
 
MPI_Comm split_tasks ()
 split top frame of stack More...
 
void create_task_output_dir ()
 create the task output directory More...
 
std::string get_io_filename (bool flag_unique=false)
 unique output file for this sub-task More...
 

Private Attributes

bool flag_verbose = false
 for debugging More...
 
bool flag_invoked = false
 track if object has been invoked yet More...
 
Vector< intsplit_bounds
 task i has ranks over the interval [result[i], result[i+1]) More...
 
int task_me = -1
 which forked task the rank belongs to More...
 
std::map< BoxArray::RefID, Vector< std::unique_ptr< DistributionMapping > > > dms
 DM cache. More...
 
std::unordered_map< std::string, Vector< MFFork > > data
 
std::string task_output_dir
 where to write task output More...
 

Member Enumeration Documentation

◆ Intent

Enumerator
in 
out 
inout 

◆ Strategy

Enumerator
single 

one task gets a copy of whole MF

duplicate 

all tasks get a copy of whole MF

split 

split MF components across tasks

Constructor & Destructor Documentation

◆ ForkJoin() [1/3]

amrex::ForkJoin::ForkJoin ( const Vector< int > &  task_rank_n)

◆ ForkJoin() [2/3]

amrex::ForkJoin::ForkJoin ( const Vector< double > &  task_rank_pct)

◆ ForkJoin() [3/3]

amrex::ForkJoin::ForkJoin ( int  ntasks)
inline

Member Function Documentation

◆ ComponentBounds()

ForkJoin::ComponentSet amrex::ForkJoin::ComponentBounds ( const std::string &  name,
int  idx = 0 
) const

◆ copy_data_from_tasks()

void amrex::ForkJoin::copy_data_from_tasks ( )
private

this is called after ParallelContext::unsplit the parent task is the top frame in ParallelContext's stack

◆ copy_data_to_tasks()

void amrex::ForkJoin::copy_data_to_tasks ( )
private

this is called before ParallelContext::split the parent task is the top frame in ParallelContext's stack

◆ create_task_output_dir()

void amrex::ForkJoin::create_task_output_dir ( )
private

create the task output directory

◆ fork_join()

template<class F >
void amrex::ForkJoin::fork_join ( const F &  fn)
inline

◆ get_dm()

const DistributionMapping & amrex::ForkJoin::get_dm ( const BoxArray ba,
int  task_idx,
const DistributionMapping dm_orig 
)
private

multiple MultiFabs may share the same box array only compute the DM once per unique (box array, task) pair and cache it create map from box array RefID to vector of DistributionMapping indexed by task ID

◆ get_io_filename()

std::string amrex::ForkJoin::get_io_filename ( bool  flag_unique = false)
private

unique output file for this sub-task

◆ get_mf()

MultiFab& amrex::ForkJoin::get_mf ( const std::string &  name,
int  idx = 0 
)
inline

◆ get_mf_vec()

Vector<MultiFab *> amrex::ForkJoin::get_mf_vec ( const std::string &  name)
inline

vector of pointers to all MFs under a name

◆ init()

void amrex::ForkJoin::init ( const Vector< int > &  task_rank_n)
private

◆ modify_ngrow() [1/2]

void amrex::ForkJoin::modify_ngrow ( const std::string &  name,
int  idx,
IntVect  ngrow 
)

modify the number of grow cells associated with the multifab

◆ modify_ngrow() [2/2]

void amrex::ForkJoin::modify_ngrow ( const std::string &  name,
IntVect  ngrow 
)
inline

◆ modify_split() [1/2]

void amrex::ForkJoin::modify_split ( const std::string &  name,
int  idx,
Vector< ComponentSet comp_split 
)

modify how the multifab is split along components across the tasks

◆ modify_split() [2/2]

void amrex::ForkJoin::modify_split ( const std::string &  name,
Vector< ComponentSet comp_split 
)
inline

◆ MyTask()

int amrex::ForkJoin::MyTask ( ) const
inline

◆ NProcsTask()

int amrex::ForkJoin::NProcsTask ( int  task) const
inline

◆ NTasks()

int amrex::ForkJoin::NTasks ( ) const
inline

◆ reg_mf() [1/4]

void amrex::ForkJoin::reg_mf ( const MultiFab mf,
const std::string &  name,
int  idx,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)
inline

these overloads are for in case the MultiFab argument is const intent must be in

◆ reg_mf() [2/4]

void amrex::ForkJoin::reg_mf ( const MultiFab mf,
const std::string &  name,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)
inline

◆ reg_mf() [3/4]

void amrex::ForkJoin::reg_mf ( MultiFab mf,
const std::string &  name,
int  idx,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)

◆ reg_mf() [4/4]

void amrex::ForkJoin::reg_mf ( MultiFab mf,
const std::string &  name,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)
inline

◆ reg_mf_vec() [1/2]

void amrex::ForkJoin::reg_mf_vec ( const Vector< MultiFab * > &  mfs,
const std::string &  name,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)
inline

◆ reg_mf_vec() [2/2]

void amrex::ForkJoin::reg_mf_vec ( const Vector< MultiFab const * > &  mfs,
const std::string &  name,
Strategy  strategy,
Intent  intent,
int  owner = -1 
)
inline

overload in case of vector of pointer to const MultiFab

◆ set_task_output_dir()

void amrex::ForkJoin::set_task_output_dir ( const std::string &  dir)
inline

◆ set_task_output_file()

static void amrex::ForkJoin::set_task_output_file ( const std::string &  filename)
inlinestatic

◆ SetVerbose()

void amrex::ForkJoin::SetVerbose ( bool  verbose_in)
inline

◆ split_tasks()

MPI_Comm amrex::ForkJoin::split_tasks ( )
private

split top frame of stack

◆ Verbose()

bool amrex::ForkJoin::Verbose ( ) const
inline

Member Data Documentation

◆ data

std::unordered_map<std::string, Vector<MFFork> > amrex::ForkJoin::data
private

◆ dms

std::map<BoxArray::RefID, Vector<std::unique_ptr<DistributionMapping> > > amrex::ForkJoin::dms
private

DM cache.

◆ flag_invoked

bool amrex::ForkJoin::flag_invoked = false
private

track if object has been invoked yet

◆ flag_verbose

bool amrex::ForkJoin::flag_verbose = false
private

for debugging

◆ split_bounds

Vector<int> amrex::ForkJoin::split_bounds
private

task i has ranks over the interval [result[i], result[i+1])

◆ task_me

int amrex::ForkJoin::task_me = -1
private

which forked task the rank belongs to

◆ task_output_dir

std::string amrex::ForkJoin::task_output_dir
private

where to write task output


The documentation for this class was generated from the following files: