MADNESS 0.10.1
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
madness::MacroTaskQ Class Reference

#include <macrotaskq.h>

Inheritance diagram for madness::MacroTaskQ:
Inheritance graph
[legend]
Collaboration diagram for madness::MacroTaskQ:
Collaboration graph
[legend]

Public Member Functions

 MacroTaskQ (const MacroTaskQFactory factory)
 create an empty taskq and initialize the subworlds
 
 ~MacroTaskQ ()
 
void add_tasks (MacroTaskBase::taskqT &vtask)
 
void drain_own_output_buffers ()
 Move the results of tasks that accumulated their own output into the universe result.
 
double execute_tasks ()
 Run this rank's share of the queue.
 
nlohmann::json get_cloud_statistics () const
 
long get_nsubworld () const
 
MacroTaskInfo get_policy () const
 
Worldget_subworld ()
 
nlohmann::json get_taskq_statistics () const
 
void print_taskq () const
 
void replicate_inputs ()
 run all tasks
 
void run_all ()
 
void set_printlevel (const long p)
 
- Public Member Functions inherited from madness::WorldObject< MacroTaskQ >
 WorldObject (const WorldObject &other)
 
 WorldObject (World &world)
 Constructor that associates an object (via the derived class) with a globally unique ID.
 
virtual ~WorldObject ()
 
WorldObjectoperator= (const WorldObject &)=delete
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8) const
 
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9) const
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7,a8,a9).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7,a8).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2,a3).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1,a2).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const a1T &a1, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)(a1).
 
detail::task_result_type< memfnT >::futureT task (ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
 Sends task to derived class method returnT (this->*memfn)().
 
- Public Member Functions inherited from madness::WorldObjectBase
virtual ~WorldObjectBase ()
 
Worldget_world () const
 
Worldget_world_noexcept () const noexcept
 Get the world to which this object belongs, without risking a throw.
 
const uniqueidTid () const
 Returns the globally unique object ID.
 
bool world_is_alive () const noexcept
 Reports whether the world to which this object belongs still exists.
 

Static Public Member Functions

static std::shared_ptr< Worldcreate_node_world (World &universe)
 a World spanning the ranks that share memory with this one
 
static std::shared_ptr< Worldcreate_worlds (World &universe, const std::size_t nsubworld)
 
static void set_pmap (World &world)
 

Public Attributes

madness::Cloud cloud
 

Private Member Functions

void add_replicated_task (const std::shared_ptr< MacroTaskBase > &task)
 
long get_scheduled_task_number (World &subworld)
 scheduler is located on universe.rank==0
 
long get_scheduled_task_number_local ()
 
bool printdebug () const
 
bool printprogress () const
 
bool printtimings () const
 
bool printtimings_detail () const
 
void set_complete (const long task_number) const
 scheduler is located on rank==0
 
void set_complete_local (const long task_number) const
 scheduler is located on rank==0
 
std::size_t size () const
 

Private Attributes

nlohmann::json cloud_statistics
 save cloud statistics after run_all()
 
std::shared_ptr< Worldnodeworld_ptr
 node-scoped World for the two-stage finalize; created on first use, reused after
 
long nsubworld =1
 
std::shared_ptr< WorldDCPmapInterface< Key< 1 > > > pmap1
 set the process map for the subworld
 
std::shared_ptr< WorldDCPmapInterface< Key< 2 > > > pmap2
 
std::shared_ptr< WorldDCPmapInterface< Key< 3 > > > pmap3
 
std::shared_ptr< WorldDCPmapInterface< Key< 4 > > > pmap4
 
std::shared_ptr< WorldDCPmapInterface< Key< 5 > > > pmap5
 
std::shared_ptr< WorldDCPmapInterface< Key< 6 > > > pmap6
 
const MacroTaskInfo policy
 storage and distribution policy
 
long printlevel =0
 
std::shared_ptr< Worldsubworld_ptr
 
MacroTaskBase::taskqT taskq
 
std::mutex taskq_mutex
 
nlohmann::json taskq_statistics
 save taskq statistics after run_all()
 
Worlduniverse
 

Additional Inherited Members

- Public Types inherited from madness::WorldObject< MacroTaskQ >
typedef WorldObject< MacroTaskQobjT
 
- Protected Member Functions inherited from madness::WorldObject< MacroTaskQ >
void process_pending ()
 To be called from derived constructor to process pending messages.
 
- Protected Member Functions inherited from madness::WorldObjectBase
 WorldObjectBase (const WorldObjectBase &other)
 Copy constructor; produces an unregistered object.
 
 WorldObjectBase (World &w)
 Construct a new WorldObjectBase.
 
Worldget_world_unchecked () const noexcept
 Unchecked access to the memoized world reference.
 
template<typename DerivedT >
void register_self (DerivedT *this_ptr)
 Registers this object with its world, making it globally addressable.
 

Constructor & Destructor Documentation

◆ MacroTaskQ()

madness::MacroTaskQ::MacroTaskQ ( const MacroTaskQFactory  factory)
inlineexplicit

◆ ~MacroTaskQ()

madness::MacroTaskQ::~MacroTaskQ ( )
inline

Member Function Documentation

◆ add_replicated_task()

void madness::MacroTaskQ::add_replicated_task ( const std::shared_ptr< MacroTaskBase > &  task)
inlineprivate

◆ add_tasks()

void madness::MacroTaskQ::add_tasks ( MacroTaskBase::taskqT vtask)
inline

◆ create_node_world()

static std::shared_ptr< World > madness::MacroTaskQ::create_node_world ( World universe)
inlinestatic

a World spanning the ranks that share memory with this one

Collective, and worth creating only once: the two-stage finalize reduces within a node first, so it needs a World with node scope.

References madness::WorldMpiInterface::comm(), madness::WorldGopInterface::fence(), madness::World::gop, madness::World::mpi, madness::nonlinear_vector_solver(), madness::World::rank(), SafeMPI::Intracomm::SHARED_SPLIT_TYPE, SafeMPI::Intracomm::Split_type(), and universe.

Referenced by drain_own_output_buffers().

◆ create_worlds()

static std::shared_ptr< World > madness::MacroTaskQ::create_worlds ( World universe,
const std::size_t  nsubworld 
)
inlinestatic

◆ drain_own_output_buffers()

void madness::MacroTaskQ::drain_own_output_buffers ( )
inline

Move the results of tasks that accumulated their own output into the universe result.

The ordering here is load-bearing and the comments inside say why. Two stages, so a node-local reduction can sit between them and only one rank per node scatters between nodes.

References cloud, create_node_world(), madness::WorldGopInterface::fence(), get_subworld(), madness::World::gop, nodeworld_ptr, madness::nonlinear_vector_solver(), madness::World::size(), taskq, and universe.

Referenced by run_all().

◆ execute_tasks()

double madness::MacroTaskQ::execute_tasks ( )
inline

Run this rank's share of the queue.

Two ways in: if every task names an owner and there is one subworld per rank, each rank walks the queue and runs what it owns, since the assignment is already decided and the pull scheduler's round trip per task would buy nothing. Otherwise task numbers are handed out dynamically. Both converge on the same accounting.

Returns
the cpu time this rank spent inside task bodies

References cloud, madness::cpu_time(), get_scheduled_task_number(), get_subworld(), madness::World::id(), madness::nonlinear_vector_solver(), nsubworld, policy, madness::print(), printdebug(), printprogress(), madness::World::rank(), set_complete(), madness::World::size(), madness::WorldObject< MacroTaskQ >::task(), taskq, universe, and madness::wall_time().

Referenced by run_all().

◆ get_cloud_statistics()

nlohmann::json madness::MacroTaskQ::get_cloud_statistics ( ) const
inline

References cloud_statistics.

◆ get_nsubworld()

long madness::MacroTaskQ::get_nsubworld ( ) const
inline

References nsubworld.

◆ get_policy()

MacroTaskInfo madness::MacroTaskQ::get_policy ( ) const
inline

References policy.

◆ get_scheduled_task_number()

long madness::MacroTaskQ::get_scheduled_task_number ( World subworld)
inlineprivate

◆ get_scheduled_task_number_local()

long madness::MacroTaskQ::get_scheduled_task_number_local ( )
inlineprivate

◆ get_subworld()

World & madness::MacroTaskQ::get_subworld ( )
inline

◆ get_taskq_statistics()

nlohmann::json madness::MacroTaskQ::get_taskq_statistics ( ) const
inline

References taskq_statistics.

◆ print_taskq()

void madness::MacroTaskQ::print_taskq ( ) const
inline

◆ printdebug()

bool madness::MacroTaskQ::printdebug ( ) const
inlineprivate

◆ printprogress()

bool madness::MacroTaskQ::printprogress ( ) const
inlineprivate

◆ printtimings()

bool madness::MacroTaskQ::printtimings ( ) const
inlineprivate

◆ printtimings_detail()

bool madness::MacroTaskQ::printtimings_detail ( ) const
inlineprivate

◆ replicate_inputs()

void madness::MacroTaskQ::replicate_inputs ( )
inline

◆ run_all()

void madness::MacroTaskQ::run_all ( )
inline

◆ set_complete()

void madness::MacroTaskQ::set_complete ( const long  task_number) const
inlineprivate

scheduler is located on rank==0

References set_complete_local(), and madness::WorldObject< MacroTaskQ >::task().

Referenced by execute_tasks().

◆ set_complete_local()

void madness::MacroTaskQ::set_complete_local ( const long  task_number) const
inlineprivate

scheduler is located on rank==0

References MADNESS_ASSERT, madness::nonlinear_vector_solver(), madness::World::rank(), taskq, and universe.

Referenced by set_complete().

◆ set_pmap()

static void madness::MacroTaskQ::set_pmap ( World world)
inlinestatic

◆ set_printlevel()

void madness::MacroTaskQ::set_printlevel ( const long  p)
inline

References p(), and printlevel.

◆ size()

std::size_t madness::MacroTaskQ::size ( ) const
inlineprivate

References taskq.

Member Data Documentation

◆ cloud

madness::Cloud madness::MacroTaskQ::cloud

◆ cloud_statistics

nlohmann::json madness::MacroTaskQ::cloud_statistics
private

save cloud statistics after run_all()

Referenced by get_cloud_statistics(), and run_all().

◆ nodeworld_ptr

std::shared_ptr<World> madness::MacroTaskQ::nodeworld_ptr
private

node-scoped World for the two-stage finalize; created on first use, reused after

Referenced by drain_own_output_buffers().

◆ nsubworld

long madness::MacroTaskQ::nsubworld =1
private

◆ pmap1

std::shared_ptr< WorldDCPmapInterface< Key<1> > > madness::MacroTaskQ::pmap1
private

set the process map for the subworld

Referenced by run_all().

◆ pmap2

std::shared_ptr< WorldDCPmapInterface< Key<2> > > madness::MacroTaskQ::pmap2
private

Referenced by run_all().

◆ pmap3

std::shared_ptr< WorldDCPmapInterface< Key<3> > > madness::MacroTaskQ::pmap3
private

Referenced by run_all().

◆ pmap4

std::shared_ptr< WorldDCPmapInterface< Key<4> > > madness::MacroTaskQ::pmap4
private

Referenced by run_all().

◆ pmap5

std::shared_ptr< WorldDCPmapInterface< Key<5> > > madness::MacroTaskQ::pmap5
private

Referenced by run_all().

◆ pmap6

std::shared_ptr< WorldDCPmapInterface< Key<6> > > madness::MacroTaskQ::pmap6
private

Referenced by run_all().

◆ policy

const MacroTaskInfo madness::MacroTaskQ::policy
private

storage and distribution policy

Referenced by MacroTaskQ(), execute_tasks(), get_policy(), replicate_inputs(), and run_all().

◆ printlevel

long madness::MacroTaskQ::printlevel =0
private

◆ subworld_ptr

std::shared_ptr<World> madness::MacroTaskQ::subworld_ptr
private

Referenced by MacroTaskQ(), and get_subworld().

◆ taskq

MacroTaskBase::taskqT madness::MacroTaskQ::taskq
private

◆ taskq_mutex

std::mutex madness::MacroTaskQ::taskq_mutex
private

◆ taskq_statistics

nlohmann::json madness::MacroTaskQ::taskq_statistics
private

save taskq statistics after run_all()

Referenced by get_taskq_statistics(), and run_all().

◆ universe

World& madness::MacroTaskQ::universe
private

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