MADNESS  0.10.1
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
madness::WorldTaskQueue Class Reference

Multi-threaded queue to manage and run tasks. More...

#include <world_task_queue.h>

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

Classes

struct  ProbeAllDone
 

Public Member Functions

 WorldTaskQueue (World &world)
 Constructor requiring a communication context (World). More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T)>::type add (fnT fn, 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())
 Create a local task with nine arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T)>::type add (fnT fn, 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())
 Create a local task with eight arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T)>::type add (fnT fn, 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())
 Create a local task with seven arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T, a5T, a6T)>::type add (fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
 Create a local task with six arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T, a5T)>::type add (fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes())
 Create a local task with five arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T >
detail::function_enabler< fnT(a1T, a2T, a3T, a4T)>::type add (fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
 Create a local task with four arguments. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T >
detail::function_enabler< fnT(a1T, a2T, a3T)>::type add (fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
 Create a local task with three arguments. More...
 
template<typename fnT , typename a1T , typename a2T >
detail::function_enabler< fnT(a1T, a2T)>::type add (fnT fn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
 Create a local task with two arguments. More...
 
template<typename fnT , typename a1T >
detail::function_enabler< fnT(a1T)>::type add (fnT fn, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
 Create a local task with one argument. More...
 
template<typename fnT >
detail::function_enabler< fnT()>::type add (fnT fn, const TaskAttributes &attr=TaskAttributes())
 Create a local task with no arguments. More...
 
template<typename objT , typename memfnT , typename... argT>
detail::memfunc_enabler< objT, memfnT >::type add (objT &&obj, memfnT memfn, argT &&... args)
 Invoke resultT (obj.*memfn)(args...) as a local task. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, 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())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T,a9T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, 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())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, 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())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T,a2T,a3T,a4T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T,a2T,a3T) as a task, local or remote. More...
 
template<typename fnT , typename a1T , typename a2T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T,a2T) as a task, local or remote. More...
 
template<typename fnT , typename a1T >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
 Invoke resultT (*fn)(a1T) as a task, local or remote. More...
 
template<typename fnT >
detail::function_enabler< fnT >::type add (ProcessID dest, fnT fn, const TaskAttributes &attr=TaskAttributes())
 Create a remote task. More...
 
template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
TaskFn< fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T >::futureT add (TaskFn< fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T > *t)
 
void add (TaskInterface *t)
 Add a new local task, taking ownership of the pointer. More...
 
void fence ()
 Returns after all local tasks have completed. More...
 
template<typename rangeT , typename opT >
Future< bool > for_each (const rangeT &range, const opT &op)
 Apply op(item) on all items in range. More...
 
template<typename resultT , typename rangeT , typename opT >
Future< resultT > reduce (const rangeT &range, const opT &op)
 Reduce op(item) for all items in range using op(sum,op(item)). More...
 
size_t size () const
 Returns the number of pending tasks. More...
 
- Public Member Functions inherited from madness::CallbackInterface
virtual ~CallbackInterface ()
 
virtual void notify_debug (const char *caller)
 Same as notify(), but tracks how many times called from each caller. More...
 

Private Types

typedef detail::voidT voidT
 

Private Member Functions

template<typename T >
const Tam_arg (const Future< T > &f)
 
template<typename T >
const Tam_arg (const T &t)
 
void notify ()
 
template<typename taskT , typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
taskT::futureT send_task (ProcessID where, fnT fn, 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)
 
- Private Member Functions inherited from NO_DEFAULTS
 NO_DEFAULTS ()
 
 NO_DEFAULTS (const NO_DEFAULTS &)=delete
 
 NO_DEFAULTS (NO_DEFAULTS &&)=delete
 
NO_DEFAULTSoperator= (const NO_DEFAULTS &)=delete
 
NO_DEFAULTSoperator= (NO_DEFAULTS &&)=delete
 

Static Private Member Functions

template<typename taskT >
static void remote_task_handler (const AmArg &arg)
 
template<typename resultT , typename opT >
static resultT sum (const resultT &left, const resultT &right, const opT &op)
 

Private Attributes

const ProcessID me
 This process. More...
 
AtomicInt nregistered
 Count of pending tasks. More...
 
Worldworld
 The communication context. More...
 

Friends

class TaskInterface
 

Additional Inherited Members

- Protected Member Functions inherited from madness::CallbackInterface
virtual void notify_debug_impl (const char *caller)
 

Detailed Description

Multi-threaded queue to manage and run tasks.

Todo:
A concise description of the inner workings...

Member Typedef Documentation

◆ voidT

Todo:
Brief description needed.

Constructor & Destructor Documentation

◆ WorldTaskQueue()

madness::WorldTaskQueue::WorldTaskQueue ( World world)

Constructor requiring a communication context (World).

Parameters
[in,out]worldThe communication context.

References nregistered.

Member Function Documentation

◆ add() [1/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T)>::type madness::WorldTaskQueue::add ( fnT  fn,
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() 
)
inline

Create a local task with nine arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
a9TType of argument 9.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]a8Argument 8.
[in]a9Argument 9.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [2/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T)>::type madness::WorldTaskQueue::add ( fnT  fn,
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() 
)
inline

Create a local task with eight arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]a8Argument 8.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [3/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T, a5T, a6T, a7T)>::type madness::WorldTaskQueue::add ( fnT  fn,
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() 
)
inline

Create a local task with seven arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [4/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T, a5T, a6T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const a5T &  a5,
const a6T &  a6,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with six arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [5/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T, a5T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const a5T &  a5,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with five arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [6/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T >
detail::function_enabler<fnT(a1T, a2T, a3T, a4T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with four arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [7/23]

template<typename fnT , typename a1T , typename a2T , typename a3T >
detail::function_enabler<fnT(a1T, a2T, a3T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with three arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [8/23]

template<typename fnT , typename a1T , typename a2T >
detail::function_enabler<fnT(a1T, a2T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const a2T &  a2,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with two arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
a2TType of argument 2.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, a2, and add().

◆ add() [9/23]

template<typename fnT , typename a1T >
detail::function_enabler<fnT(a1T)>::type madness::WorldTaskQueue::add ( fnT  fn,
const a1T &  a1,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with one argument.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
a1TType of argument 1.
Parameters
[in,out]fnThe function to be called in the task.
[in]a1Argument 1.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References a1, and add().

◆ add() [10/23]

template<typename fnT >
detail::function_enabler<fnT()>::type madness::WorldTaskQueue::add ( fnT  fn,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a local task with no arguments.

Creates a task in this process. An argument that is a future may be used to carry dependencies.

Template Parameters
fnTA function pointer or functor.
Parameters
[in,out]fnThe function to be called in the task.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is returned that may be ignored.

References add().

◆ add() [11/23]

template<typename objT , typename memfnT , typename... argT>
detail::memfunc_enabler<objT, memfnT>::type madness::WorldTaskQueue::add ( objT &&  obj,
memfnT  memfn,
argT &&...  args 
)
inline

Invoke resultT (obj.*memfn)(args...) as a local task.

Todo:
Verify this documentation. A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.
Template Parameters
objTThe object type.
memfnTThe member function type.
argTVariadic template for arguments.
Parameters
[in]objThe associated object for invoking the member function pointer.
[in]memfnThe member function pointer.
[in]argsThe argument pack.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References add(), and madness::detail::wrap_mem_fn().

◆ add() [12/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
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() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T,a9T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
a9TType of argument 9.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]a8Argument 8.
[in]a9Argument 9.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.
Todo:
Could we use metaprogramming or variadic templates to reduce all of these instances to one template that generates versions for one more (less) parameter?

References a1, a2, add(), am_arg(), and me.

◆ add() [13/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
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() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]a8Argument 8.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [14/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
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() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [15/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const a5T &  a5,
const a6T &  a6,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [16/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const a5T &  a5,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T,a5T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [17/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const a4T &  a4,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T,a4T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [18/23]

template<typename fnT , typename a1T , typename a2T , typename a3T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const a2T &  a2,
const a3T &  a3,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T,a2T,a3T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [19/23]

template<typename fnT , typename a1T , typename a2T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const a2T &  a2,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T,a2T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
a2TType of argument 2.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]a2Argument 2.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, a2, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [20/23]

template<typename fnT , typename a1T >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const a1T &  a1,
const TaskAttributes attr = TaskAttributes() 
)
inline

Invoke resultT (*fn)(a1T) as a task, local or remote.

A future is returned to hold the eventual result of the task. Future<void> is an empty class that may be ignored.

Template Parameters
fnTA function pointer or functor type.
a1TType of argument 1.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]a1Argument 1.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject are automatically handled. Anything else is your problem.

References a1, add(), am_arg(), me, and madness::Future< void >::value.

◆ add() [21/23]

template<typename fnT >
detail::function_enabler<fnT>::type madness::WorldTaskQueue::add ( ProcessID  dest,
fnT  fn,
const TaskAttributes attr = TaskAttributes() 
)
inline

Create a remote task.

Creates a task in process dest, which may or may not be this process. An argument that is a future may be used to carry dependencies for local tasks. A future that is not ready cannot be used as an argument for remote tasks – i.e., remote tasks must be ready to execute (you can work around this by making a local task to submit the remote task once everything is ready).

Template Parameters
fnTA function pointer or functor type.
Parameters
[in]destThe process where the task will be created.
[in]fnThe function to be called in the task.
[in]attrThe task attributes.
Returns
A future to the result. If the task function return type is void, a Future<void> object is return that may be ignored.
Note
Arguments must be (de)serializable and must of course make sense at the remote destination. Fundamental types, simple STL containers, and pointers to World, WorldContainer, and user-defined types derived from WorldObject<> are automatically handled. Anything else is your problem.

References add(), me, and madness::Future< void >::value.

◆ add() [22/23]

template<typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
TaskFn<fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T>::futureT madness::WorldTaskQueue::add ( TaskFn< fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T > *  t)
inline
Todo:
Brief description needed.
Todo:
Descriptions needed.
Template Parameters
fnTDescription needed.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
a9TType of argument 9.
Parameters
[in]tDescription needed.
Returns
Description needed.

References add(), and madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::result().

◆ add() [23/23]

void madness::WorldTaskQueue::add ( TaskInterface t)
inline

Add a new local task, taking ownership of the pointer.

The task pointer (t) is assumed to have been created with new and when the task is eventually run the queue will call the task's destructor using delete.

Once the task is complete it will execute task_complete_callback to decrement the number of pending tasks and be deleted.

Parameters
[in]tPointer to the task.

References nregistered, madness::TaskInterface::register_submit_callback(), madness::TaskInterface::set_info(), and world.

Referenced by madness::CubicInterpolationTable< T >::CubicInterpolationTable(), madness::CoeffTracker< T, NDIM >::activate(), madness::FunctionImpl< T, NDIM >::multiply_op< LDIM >::activate(), madness::FunctionImpl< T, NDIM >::add_op::activate(), madness::FunctionImpl< T, NDIM >::hartree_op< LDIM, leaf_opT >::activate(), madness::FunctionImpl< T, NDIM >::Vphi_op_NS< opT, LDIM >::activate(), madness::FunctionImpl< T, NDIM >::recursive_apply_op< opT, LDIM >::activate(), madness::FunctionImpl< T, NDIM >::recursive_apply_op2< opT >::activate(), madness::FunctionImpl< T, NDIM >::project_out_op< LDIM >::activate(), add(), madness::WorldGopInterface::bcast_internal(), madness::distributed_localize_PM(), for_each(), madness::WorldGopInterface::lazy_sync(), madness::WorldGopInterface::lazy_sync_internal(), main(), madness::FunctionImpl< T, NDIM >::multi_to_multi_op_values(), madness::FunctionImpl< T, NDIM >::multiop_values(), reduce(), madness::WorldGopInterface::reduce_internal(), Task::run(), madness::WorldGopInterface::send_internal(), madness::WorldObject< Derived >::task(), test10(), test5(), test9(), test_multi(), and madness::FunctionImpl< T, NDIM >::vtransform().

◆ am_arg() [1/2]

template<typename T >
const T& madness::WorldTaskQueue::am_arg ( const Future< T > &  f)
inlineprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Template Parameters
TDescription needed.
Parameters
[in]fDescription needed.

References madness::f, and MADNESS_ASSERT.

Referenced by add().

◆ am_arg() [2/2]

template<typename T >
const T& madness::WorldTaskQueue::am_arg ( const T t)
inlineprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Template Parameters
TDescription needed.
Parameters
[in]tDescription needed.
Returns
Description needed.

◆ fence()

void madness::WorldTaskQueue::fence ( )
inline

Returns after all local tasks have completed.

While waiting, the calling thread will run tasks.

References madness::ThreadPool::await(), and nregistered.

Referenced by madness::CubicInterpolationTable< T >::CubicInterpolationTable(), madness::distributed_localize_PM(), madness::WorldGopInterface::fence_impl(), madness::inner(), main(), and test9().

◆ for_each()

template<typename rangeT , typename opT >
Future<bool> madness::WorldTaskQueue::for_each ( const rangeT &  range,
const opT &  op 
)
inline

Apply op(item) on all items in range.

The operation must provide the following interface, of which the operator() method is required by for_each() and the rest by the task interface.

struct opT {
opT(const opT&);
bool operator()(const rangeT::iterator& it) const;
};
Note
The serialize method does not actually have to work unless you want to have the task be stealable.

Adjust the chunksize in the range to control granularity.

Your operation should return true/false for success failure and the logical and of all results is returned as the future result.

You can ignore the result if you are interested in neither synchronization nor result status.

Todo:
Descriptions needed and/or verified.
Template Parameters
rangeTDescription needed.
opTFuntion type of the operation. This function should have a return type of bool.
Parameters
[in]rangeThe range of items.
[in]opThe operation.
Returns
Future for a bool which is the logical and of all op(item) calls.

References add(), op(), madness::detail::ForEachRootTask< rangeT, opT >::result(), and world.

Referenced by madness::FunctionImpl< T, NDIM >::flo_unary_op_node_inplace(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::redistribute_phase2(), and madness::FunctionImpl< T, NDIM >::unary_op_value_inplace().

◆ notify()

void madness::WorldTaskQueue::notify ( )
inlineprivatevirtual
Todo:
Brief description needed.

Implements madness::CallbackInterface.

References nregistered.

◆ reduce()

template<typename resultT , typename rangeT , typename opT >
Future<resultT> madness::WorldTaskQueue::reduce ( const rangeT &  range,
const opT &  op 
)
inline

Reduce op(item) for all items in range using op(sum,op(item)).

The operation must provide the following interface, of which the operator() methods are required by reduce() and the rest by the task interface.

struct opT {
opT();
opT(const &opT);
resultT operator()(const rangeT::iterator& it) const;
resultT operator()(const resultT& left, const resultT& right);
template <typename Archive> void serialize(const Archive& ar);
}
std::enable_if_t< ! is_default_serializable< Archive, T >::value &&is_archive< Archive >::value, void > serialize(const Archive &ar, const T *t, unsigned int n)
Serialize (or deserialize) an array of non-fundamental stuff.
Definition: archive.h:497
Note
The serialize method does not actually have to work unless you want to have the task be stealable.

Adjust the chunksize in the range to control granularity.

Todo:
Descriptions needed and/or verified.
Template Parameters
resultTThe result type of the operation.
rangeTDescription needed.
opTFunction type of the operation.
Parameters
[in]rangeThe range of items.
[in]opThe operation.
Returns
Description needed.

References add(), op(), and sum().

Referenced by madness::FunctionImpl< T, NDIM >::errsq_local(), madness::FunctionImpl< T, NDIM >::inner_adaptive_local(), and madness::FunctionImpl< T, NDIM >::inner_ext_local().

◆ remote_task_handler()

template<typename taskT >
static void madness::WorldTaskQueue::remote_task_handler ( const AmArg arg)
inlinestaticprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Template Parameters
taskTDescription needed.
Parameters
argDescription needed.

References madness::arg(), MADNESS_ASSERT, and task().

◆ send_task()

template<typename taskT , typename fnT , typename a1T , typename a2T , typename a3T , typename a4T , typename a5T , typename a6T , typename a7T , typename a8T , typename a9T >
taskT::futureT madness::WorldTaskQueue::send_task ( ProcessID  where,
fnT  fn,
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 
)
inlineprivate
Todo:
Brief description needed.
Todo:
Descriptions needed.
Template Parameters
taskTDescription needed.
fnTDescription needed.
a1TType of argument 1.
a2TType of argument 2.
a3TType of argument 3.
a4TType of argument 4.
a5TType of argument 5.
a6TType of argument 6.
a7TType of argument 7.
a8TType of argument 8.
a9TType of argument 9.
Parameters
whereDescription needed.
fnDescription needed.
[in]a1Argument 1.
[in]a2Argument 2.
[in]a3Argument 3.
[in]a4Argument 4.
[in]a5Argument 5.
[in]a6Argument 6.
[in]a7Argument 7.
[in]a8Argument 8.
[in]a9Argument 9.
[in]attrDescription needed.
Returns
Description needed.

References a1, a2, madness::World::am, madness::RMI::ATTR_UNORDERED, madness::new_am_arg(), madness::WorldAmInterface::send(), and world.

◆ size()

size_t madness::WorldTaskQueue::size ( ) const
inline

Returns the number of pending tasks.

Returns
The number of pending tasks.

References nregistered.

Referenced by madness::WorldGopInterface::fence_impl().

◆ sum()

template<typename resultT , typename opT >
static resultT madness::WorldTaskQueue::sum ( const resultT &  left,
const resultT &  right,
const opT &  op 
)
inlinestaticprivate
Todo:
Brief description needed.

This template is used in the reduce kernel.

Todo:
Template parameter descriptions need verification.
Template Parameters
resultTReturn type of the operation.
opTThe operation.
Parameters
[in]leftDescription needed.
[in]rightDescription needed.
[in]opThe operation used in the reduce.
Returns
Reduce of left and right using op.

References op().

Referenced by reduce().

Friends And Related Function Documentation

◆ TaskInterface

friend class TaskInterface
friend

Member Data Documentation

◆ me

const ProcessID madness::WorldTaskQueue::me
private

This process.

Referenced by add().

◆ nregistered

AtomicInt madness::WorldTaskQueue::nregistered
private

◆ world

World& madness::WorldTaskQueue::world
private

The communication context.

Referenced by add(), for_each(), and send_task().


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