MADNESS 0.10.1
madness::TaskAttributes Class Reference

Contains attributes of a task. More...

#include <thread.h>

Inheritance diagram for madness::TaskAttributes:

Public Member Functions

 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.
TaskAttributes & set_generator (bool generator_hint)
 Sets the generator attribute.
TaskAttributes & set_highpriority (bool hipri)
 Sets the high priority attribute.
void set_nthread (int nthread)
 Set the number of threads.
TaskAttributes & set_stealable (bool stealable)
 Sets the stealable attribute.

Static Public Member Functions

static TaskAttributes generator ()
static TaskAttributes hipri ()
static TaskAttributes multi_threaded (int nthread)

Static Public Attributes

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.

Private Attributes

unsigned long flags
 Byte-string storing the specified attributes.

Detailed Description

Contains attributes of a task.

The current attributes are:

  • generator : Setting this hints that a task will produce additional tasks and is used by the scheduler to increase/throttle parallelism. The default is false.
  • stealable : Setting this indicates that a task may be migrated to another process for dynamic load balancing. The default value is false.
  • highpriority : indicates a high priority task. The default value is false.
  • nthread : indicates number of threads. 0 threads is interpreted as 1 thread for backward compatibility and ease of specifying defaults. The default value is 0 (==1).

Constructor & Destructor Documentation

◆ TaskAttributes() [1/2]

madness::TaskAttributes::TaskAttributes ( unsigned long flags = 0)
inlineexplicit

Sets the attributes to the desired values.

flags, if unspecified sets all attributes to their default values.

Parameters
[in]flagsThe attribute values.

References flags.

Referenced by madness::detail::ForEachRootTask< rangeT, opT >::ForEachRootTask(), madness::PoolTaskInterface::PoolTaskInterface(), madness::PoolTaskInterface::PoolTaskInterface(), TaskAttributes(), generator(), hipri(), multi_threaded(), set_generator(), set_highpriority(), and set_stealable().

◆ TaskAttributes() [2/2]

madness::TaskAttributes::TaskAttributes ( const TaskAttributes & attr)
inline

Copy constructor.

Parameters
[in]attrThe attributes to copy.

References TaskAttributes(), and flags.

◆ ~TaskAttributes()

virtual madness::TaskAttributes::~TaskAttributes ( )
inlinevirtual

Member Function Documentation

◆ generator()

TaskAttributes madness::TaskAttributes::generator ( )
inlinestatic
Todo
Brief description needed.
Todo
Descriptions needed.
Returns
Description needed.

References TaskAttributes(), and GENERATOR.

Referenced by madness::FunctionImpl< T, NDIM >::truncate_spawn().

◆ get_nthread()

int madness::TaskAttributes::get_nthread ( ) const
inline

Get the number of threads.

Returns
The number of threads.

References flags, and NTHREAD.

Referenced by TestBarrier::TestBarrier(), TimeBarrier::TimeBarrier(), madness::PoolTaskInterface::execute(), and madness::PoolTaskInterface::set_nthread().

◆ hipri()

TaskAttributes madness::TaskAttributes::hipri ( )
inlinestatic
Todo
Brief description needed.
Todo
Descriptions needed.
Returns
Description needed.

References TaskAttributes(), and HIGHPRIORITY.

Referenced by madness::detail::ForEachRootTask< rangeT, opT >::ForEachRootTask(), madness::CoeffTracker< T, LDIM >::activate(), madness::FunctionImpl< T, LDIM >::apply_1d_realspace_push_op(), madness::WorldGopInterface::bcast_handler(), madness::WorldGopInterface::bcast_internal(), madness::WorldGopInterface::bcast_internal(), madness::FunctionImpl< T, NDIM >::compress_spawn(), madness::FunctionImpl< T, NDIM >::diff(), madness::FunctionImpl< T, LDIM >::dirac_convolution_op(), madness::FunctionImpl< T, LDIM >::do_apply_kernel(), madness::FunctionImpl< T, LDIM >::do_apply_kernel2(), madness::FunctionImpl< T, LDIM >::do_apply_kernel3(), madness::FunctionImpl< Q, NDIM >::do_print_grid(), madness::FunctionImpl< T, LDIM >::do_project_out(), madness::FunctionImpl< T, NDIM >::eval(), madness::FunctionImpl< T, NDIM >::evaldepthpt(), madness::FunctionImpl< T, NDIM >::evalR(), madness::FunctionImpl< T, NDIM >::find_me(), madness::DerivativeBase< T, NDIM >::find_neighbor(), madness::DerivativeBase< T, NDIM >::forward_do_diff1(), madness::FunctionImpl< T, NDIM >::get_norm_tree_recursive(), madness::WorldGopInterface::group_bcast_handler(), madness::WorldGopInterface::lazy_sync(), madness::WorldGopInterface::lazy_sync(), madness::WorldGopInterface::lazy_sync_internal(), madness::DerivativeBase< T, NDIM >::submit_op::operator()(), madness::FunctionImpl< T, NDIM >::project_out_op< LDIM >::operator()(), madness::FunctionImpl< T, LDIM >::partial_inner_contract(), madness::FunctionImpl< T, LDIM >::project_out2(), madness::WorldGopInterface::reduce_internal(), madness::FunctionImpl< T, LDIM >::refine(), madness::FunctionImpl< T, LDIM >::refine_spawn(), madness::WorldGopInterface::send_internal(), madness::WorldGopInterface::send_internal(), set_highpriority(), madness::FunctionImpl< T, NDIM >::sock_it_to_me_too(), and madness::DerivativeBase< T, NDIM >::stage_halo().

◆ is_generator()

bool madness::TaskAttributes::is_generator ( ) const
inline

Test if the generator attribute is true.

Returns
True if this task is a generator, false otherwise.

References flags, and GENERATOR.

◆ is_high_priority()

bool madness::TaskAttributes::is_high_priority ( ) const
inline

Test if the high priority attribute is true.

Returns
True if this task is a high priority, false otherwise.

References flags, and HIGHPRIORITY.

◆ is_stealable()

bool madness::TaskAttributes::is_stealable ( ) const
inline

Test if the stealable attribute is true.

Returns
True if this task is stealable, false otherwise.

References flags, and STEALABLE.

◆ multi_threaded()

TaskAttributes madness::TaskAttributes::multi_threaded ( int nthread)
inlinestatic
Todo
Brief description needed.
Todo
Descriptions needed.
Returns
Description needed.

References TaskAttributes(), and set_nthread().

Referenced by test_multi().

◆ serialize()

template<typename Archive>
void madness::TaskAttributes::serialize ( Archive & ar)
inline

Serializes the attributes for I/O.

tparam Archive The archive type.

Parameters
[in,out]arThe archive.

References flags.

◆ set_generator()

TaskAttributes & madness::TaskAttributes::set_generator ( bool generator_hint)
inline

Sets the generator attribute.

Parameters
[in]generator_hintThe new value for the generator attribute.

References TaskAttributes(), flags, and GENERATOR.

◆ set_highpriority()

TaskAttributes & madness::TaskAttributes::set_highpriority ( bool hipri)
inline

Sets the high priority attribute.

Parameters
[in]hipriThe new value for the high priority attribute.

References TaskAttributes(), flags, HIGHPRIORITY, and hipri().

◆ set_nthread()

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

Set the number of threads.

Attention
Are you sure this is what you want to call? Only call this for a TaskAttributes that is not a base class of a task object. If you are trying to set the number of threads in an existing task you should call TaskInterface::set_nthread() instead. No doubt there is some virtual/protected/something voodoo to prevent you from doing harm.
Todo
Perhaps investigate a way to make this function only accessible from the intended functions (using the so-called voodoo)?
Parameters
[in]nthreadThe new number of threads.

References flags, MADNESS_ASSERT, and NTHREAD.

Referenced by madness::SystolicMatrixAlgorithm< T >::SystolicMatrixAlgorithm(), multi_threaded(), and madness::PoolTaskInterface::set_nthread().

◆ set_stealable()

TaskAttributes & madness::TaskAttributes::set_stealable ( bool stealable)
inline

Sets the stealable attribute.

Parameters
[in]stealableThe new value for the stealable attribute.

References TaskAttributes(), flags, and STEALABLE.

Referenced by main().

Member Data Documentation

◆ flags

unsigned long madness::TaskAttributes::flags
private

◆ GENERATOR

const unsigned long madness::TaskAttributes::GENERATOR = 1ul<<8
static

Mask for generator bit.

Referenced by generator(), is_generator(), and set_generator().

◆ HIGHPRIORITY

const unsigned long madness::TaskAttributes::HIGHPRIORITY = GENERATOR<<2
static

Mask for priority bit.

Referenced by hipri(), is_high_priority(), and set_highpriority().

◆ NTHREAD

const unsigned long madness::TaskAttributes::NTHREAD = 0xff
static

Mask for nthread byte.

Referenced by get_nthread(), and set_nthread().

◆ STEALABLE

const unsigned long madness::TaskAttributes::STEALABLE = GENERATOR<<1
static

Mask for stealable bit.

Referenced by is_stealable(), and set_stealable().


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