MADNESS
0.10.1
|
Lowest level task interface. More...
#include <thread.h>
Classes | |
union | FunctionPointerGrabber |
Object that is used to convert function and member function pointers into void* . More... | |
Public Member Functions | |
PoolTaskInterface () | |
Default constructor. More... | |
PoolTaskInterface (const TaskAttributes &attr) | |
virtual | ~PoolTaskInterface ()=default |
Destructor. More... | |
void | execute () |
virtual void | run (const TaskThreadEnv &info)=0 |
Override this method to implement a multi-threaded task. More... | |
void | set_nthread (int nthread) |
Call this to reset the number of threads before the task is submitted. More... | |
Public Member Functions inherited from madness::TaskAttributes | |
TaskAttributes (const TaskAttributes &attr) | |
Copy constructor. More... | |
TaskAttributes (unsigned long flags=0) | |
Sets the attributes to the desired values. More... | |
virtual | ~TaskAttributes () |
int | get_nthread () const |
Get the number of threads. More... | |
bool | is_generator () const |
Test if the generator attribute is true. More... | |
bool | is_high_priority () const |
Test if the high priority attribute is true. More... | |
bool | is_stealable () const |
Test if the stealable attribute is true. More... | |
template<typename Archive > | |
void | serialize (Archive &ar) |
Serializes the attributes for I/O. More... | |
TaskAttributes & | set_generator (bool generator_hint) |
Sets the generator attribute. More... | |
TaskAttributes & | set_highpriority (bool hipri) |
Sets the high priority attribute. More... | |
void | set_nthread (int nthread) |
Set the number of threads. More... | |
TaskAttributes & | set_stealable (bool stealable) |
Sets the stealable attribute. More... | |
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. More... | |
Private Attributes | |
std::pair< void *, unsigned short > | id_ |
double | submit_time_ |
profiling::TaskEvent * | task_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. More... | |
static const unsigned long | HIGHPRIORITY = GENERATOR<<2 |
Mask for priority bit. More... | |
static const unsigned long | NTHREAD = 0xff |
Mask for nthread byte. More... | |
static const unsigned long | STEALABLE = GENERATOR<<1 |
Mask for stealable bit. More... | |
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.
|
inline |
Default constructor.
|
inlineexplicit |
|
virtualdefault |
Destructor.
|
inline |
References madness::TaskAttributes::get_nthread(), and run().
|
inlineprivatevirtual |
[in,out] | id | Description needed. |
Reimplemented in madness::detail::ForEachRootTask< rangeT, opT >, madness::PoolTaskNull, madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >, madness::SystolicMatrixAlgorithm< T >, madness::SystolicMatrixAlgorithm< double >, and madness::MatrixInnerTask< T, R, NDIM >.
Referenced by submit().
|
inlinestaticprotected |
fnobjT | Description needed. |
[in,out] | id | Description needed. |
References madness::name().
|
inlinestaticprotected |
fnT | Description needed. |
[in,out] | id | Description needed. |
[in] | fn | Description needed. |
References madness::PoolTaskInterface::FunctionPointerGrabber< T >::in, and madness::PoolTaskInterface::FunctionPointerGrabber< T >::out.
Referenced by madness::MatrixInnerTask< T, R, NDIM >::get_id(), madness::SystolicMatrixAlgorithm< T >::get_id(), madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::get_id(), madness::PoolTaskNull::get_id(), and madness::detail::ForEachRootTask< rangeT, opT >::get_id().
|
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).
[in] | info | Description needed. |
Implemented in Adder, Greet, madness::TaskInterface, and madness::PoolTaskNull.
Referenced by execute().
|
inlineprivate |
[in,out] | task_event | Description needed. |
References task_event_.
Referenced by madness::ThreadPool::run_tasks().
|
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().
Referenced by madness::SystolicMatrixAlgorithm< T >::SystolicMatrixAlgorithm().
|
inlineprivate |
Collect info on the task and record the submit time.
References get_id(), submit_time_, and madness::wall_time().
|
friend |
|
private |
|
private |
|
private |
Referenced by set_event().