MADNESS 0.10.1
madness::MacroTaskQ Class Reference

#include <macrotaskq.h>

Inheritance diagram for madness::MacroTaskQ:
Collaboration diagram for madness::MacroTaskQ:

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
World & get_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)
void sort_tasks_by_priority ()
Public Member Functions inherited from madness::WorldObject< MacroTaskQ >
 WorldObject (const WorldObject &other)
virtual ~WorldObject ()
WorldObject & operator= (const WorldObject &)=delete
detail::task_result_type< memfnT >::futureT send (ProcessID dest, memfnT memfn) const
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 ()
World & get_world () const
World & get_world_noexcept () const noexcept
 Get the world to which this object belongs, without risking a throw.
const uniqueidT & id () 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< World > create_node_world (World &universe)
 a World spanning the ranks that share memory with this one
static std::shared_ptr< World > create_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< World > nodeworld_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< World > subworld_ptr
MacroTaskBase::taskqT taskq
std::mutex taskq_mutex
nlohmann::json taskq_statistics
 save taskq statistics after run_all()
World & universe

Additional Inherited Members

Public Types inherited from madness::WorldObject< MacroTaskQ >
typedef WorldObject< MacroTaskQ > objT
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.
World & get_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()

◆ ~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

References add_replicated_task(), and universe.

◆ create_node_world()

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 SafeMPI::Intracomm::SHARED_SPLIT_TYPE, and universe.

Referenced by drain_own_output_buffers().

◆ create_worlds()

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::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(), madness::get_hostname(), get_scheduled_task_number(), get_subworld(), madness::World::id(), nsubworld, policy, madness::print(), printdebug(), printprogress(), madness::World::rank(), set_complete(), 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

References madness::print(), taskq, and universe.

Referenced by run_all().

◆ printdebug()

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

◆ printprogress()

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

References printdebug(), and printlevel.

Referenced by execute_tasks(), and run_all().

◆ printtimings()

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

References printlevel, and universe.

◆ printtimings_detail()

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

References printlevel, and universe.

Referenced by replicate_inputs(), and run_all().

◆ replicate_inputs()

void madness::MacroTaskQ::replicate_inputs ( )
inline

run all tasks

Put the cloud where the tasks will read it from. Rank- or node-replication of the cloud, and of the targets that stored pointers refer to. Both are no-ops under a distributed policy.

References cloud, madness::cpu_time(), madness::Distributed, madness::loop_types(), madness::NodeReplicated, policy, madness::print(), printtimings_detail(), madness::RankReplicated, madness::MacroTaskInfo::StoreFunction, and universe.

Referenced by run_all().

◆ run_all()

◆ 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, taskq, and universe.

Referenced by set_complete().

◆ set_pmap()

◆ 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.

◆ sort_tasks_by_priority()

void madness::MacroTaskQ::sort_tasks_by_priority ( )
inline

References a, b, and taskq.

Referenced by run_all().

Member Data Documentation

◆ 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

◆ 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


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