MADNESS 0.10.1
Classes | Public Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
madness::PoolTaskInterface Class Referenceabstract

Lowest level task interface. More...

#include <thread.h>

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

Classes

union  FunctionPointerGrabber
 Object that is used to convert function and member function pointers into void*. More...
 

Public Member Functions

 PoolTaskInterface ()
 Default constructor.
 
 PoolTaskInterface (const TaskAttributes &attr)
 
virtual ~PoolTaskInterface ()=default
 Destructor.
 
void execute ()
 
virtual void run (const TaskThreadEnv &info)=0
 Override this method to implement a multi-threaded task.
 
void set_nthread (int nthread)
 Call this to reset the number of threads before the task is submitted.
 
- Public Member Functions inherited from madness::TaskAttributes
 TaskAttributes (const TaskAttributes &attr)
 Copy constructor.
 
 TaskAttributes (unsigned long flags=0)
 Sets the attributes to the desired values.
 
virtual ~TaskAttributes ()
 
int get_nthread () const
 Get the number of threads.
 
bool is_generator () const
 Test if the generator attribute is true.
 
bool is_high_priority () const
 Test if the high priority attribute is true.
 
bool is_stealable () const
 Test if the stealable attribute is true.
 
template<typename Archive >
void serialize (Archive &ar)
 Serializes the attributes for I/O.
 
TaskAttributesset_generator (bool generator_hint)
 Sets the generator attribute.
 
TaskAttributesset_highpriority (bool hipri)
 Sets the high priority attribute.
 
void set_nthread (int nthread)
 Set the number of threads.
 
TaskAttributesset_stealable (bool stealable)
 Sets the stealable attribute.
 

Static Protected Member Functions

template<typename fnobjT >
static std::enable_if<!(detail::function_traits< fnobjT >::value||detail::memfunc_traits< fnobjT >::value)>::type make_id (std::pair< void *, unsigned short > &id, const fnobjT &)
 
template<typename fnT >
static std::enable_if< detail::function_traits< fnT >::value||detail::memfunc_traits< fnT >::value >::type make_id (std::pair< void *, unsigned short > &id, fnT fn)
 

Private Member Functions

virtual void get_id (std::pair< void *, unsigned short > &id) const
 
void set_event (profiling::TaskEvent *task_event)
 
void submit ()
 Collect info on the task and record the submit time.
 

Private Attributes

std::pair< void *, unsigned short > id_
 
double submit_time_
 
profiling::TaskEventtask_event_
 

Friends

class ThreadPool
 

Additional Inherited Members

- Static Public Member Functions inherited from madness::TaskAttributes
static TaskAttributes generator ()
 
static TaskAttributes hipri ()
 
static TaskAttributes multi_threaded (int nthread)
 
- Static Public Attributes inherited from madness::TaskAttributes
static const unsigned long GENERATOR = 1ul<<8
 Mask for generator bit.
 
static const unsigned long HIGHPRIORITY = GENERATOR<<2
 Mask for priority bit.
 
static const unsigned long NTHREAD = 0xff
 Mask for nthread byte.
 
static const unsigned long STEALABLE = GENERATOR<<1
 Mask for stealable bit.
 

Detailed Description

Lowest level task interface.

The pool invokes run_multi_threaded(), which does any necessary setup for multiple threads, and then invokes the user's run() method.

Constructor & Destructor Documentation

◆ PoolTaskInterface() [1/2]

madness::PoolTaskInterface::PoolTaskInterface ( )
inline

Default constructor.

◆ PoolTaskInterface() [2/2]

madness::PoolTaskInterface::PoolTaskInterface ( const TaskAttributes attr)
inlineexplicit
Todo:
Brief description needed.
Todo:
Descriptions needed.
Parameters
[in]attrDescription needed.

◆ ~PoolTaskInterface()

virtual madness::PoolTaskInterface::~PoolTaskInterface ( )
virtualdefault

Destructor.

Member Function Documentation

◆ execute()

void madness::PoolTaskInterface::execute ( )
inline
Todo:
Brief description needed.
Todo:
Descriptions needed.
Returns
Description needed.

References madness::TaskAttributes::get_nthread(), and run().

◆ get_id()

virtual void madness::PoolTaskInterface::get_id ( std::pair< void *, unsigned short > &  id) const
inlineprivatevirtual

◆ make_id() [1/2]

template<typename fnobjT >
static std::enable_if<!(detail::function_traits< fnobjT >::value||detail::memfunc_traits< fnobjT >::value)>::type madness::PoolTaskInterface::make_id ( std::pair< void *, unsigned short > &  id,
const fnobjT &   
)
inlinestaticprotected
Todo:
Brief description needed.
Todo:
Descriptions needed. What is the purpose of the second argument?
Template Parameters
fnobjTDescription needed.
Parameters
[in,out]idDescription needed.

References madness::name().

◆ make_id() [2/2]

template<typename fnT >
static std::enable_if< detail::function_traits< fnT >::value||detail::memfunc_traits< fnT >::value >::type madness::PoolTaskInterface::make_id ( std::pair< void *, unsigned short > &  id,
fnT  fn 
)
inlinestaticprotected

◆ run()

virtual void madness::PoolTaskInterface::run ( const TaskThreadEnv info)
pure virtual

Override this method to implement a multi-threaded task.

info.nthread() will be the number of threads collaborating on this task.

info.id() will be the index of the current thread id=0,...,nthread-1.

info.barrier() will be a barrier for all of the threads, and returns true for the last thread to enter the barrier (other threads get false).

Todo:
Description needed.
Parameters
[in]infoDescription needed.

Implemented in madness::PoolTaskNull, madness::TaskInterface, Greet, and Adder.

Referenced by execute().

◆ set_event()

void madness::PoolTaskInterface::set_event ( profiling::TaskEvent task_event)
inlineprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Parameters
[in,out]task_eventDescription needed.

References task_event_.

Referenced by madness::ThreadPool::run_tasks().

◆ set_nthread()

void madness::PoolTaskInterface::set_nthread ( int  nthread)
inline

Call this to reset the number of threads before the task is submitted.

Once a task has been constructed /c TaskAttributes::set_nthread() is insufficient because a multithreaded task includes a barrier that needs to know the number of threads.

References madness::TaskAttributes::get_nthread(), and madness::TaskAttributes::set_nthread().

◆ submit()

void madness::PoolTaskInterface::submit ( )
inlineprivate

Collect info on the task and record the submit time.

References get_id(), submit_time_, and madness::wall_time().

Friends And Related Symbol Documentation

◆ ThreadPool

friend class ThreadPool
friend

Member Data Documentation

◆ id_

std::pair<void*, unsigned short> madness::PoolTaskInterface::id_
private
Todo:
Description needed.

◆ submit_time_

double madness::PoolTaskInterface::submit_time_
private
Todo:
Description needed.

Referenced by submit().

◆ task_event_

profiling::TaskEvent* madness::PoolTaskInterface::task_event_
private
Todo:
Description needed.

Referenced by set_event().


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