Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::TaskFactory Class Reference

Factory for tasks. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/concurrency/arccore/concurrency/TaskFactory.h>

Collaboration diagram for Arcane::TaskFactory:

Static Public Member Functions

template<typename InstanceType>
static ITaskcreateTask (InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
 Creates a task. During execution, the task will call the method function via the instance instance.
template<typename InstanceType>
static ITaskcreateTask (InstanceType *instance, void(InstanceType::*function)())
 Creates a task. During execution, the task will call the method function via the instance instance.
template<typename InstanceType>
static ITaskcreateChildTask (ITask *parent_task, InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
 Creates a child task.
template<typename InstanceType>
static ITaskcreateChildTask (ITask *parent_task, InstanceType *instance, void(InstanceType::*function)())
 Creates a child task.
static void executeParallelFor (Integer begin, Integer size, const ParallelLoopOptions &options, IRangeFunctor *f)
 Executes the functor f in parallel.
static void executeParallelFor (Integer begin, Integer size, Integer block_size, IRangeFunctor *f)
 Executes the functor f in parallel.
static void executeParallelFor (Integer begin, Integer size, IRangeFunctor *f)
 Executes the functor f in parallel.
static void executeParallelFor (const ParallelFor1DLoopInfo &loop_info)
 Executes the loop loop_info in parallel.
static void executeParallelFor (const ComplexForLoopRanges< 1 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 1 > *functor)
 Executes a simple loop.
static void executeParallelFor (const ComplexForLoopRanges< 1 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 1 > *functor)
 Executes a simple loop.
static void executeParallelFor (const ComplexForLoopRanges< 2 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 2 > *functor)
 Executes a 2D loop.
static void executeParallelFor (const ComplexForLoopRanges< 2 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 2 > *functor)
 Executes a 2D loop.
static void executeParallelFor (const ComplexForLoopRanges< 3 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 3 > *functor)
 Executes a 3D loop.
static void executeParallelFor (const ComplexForLoopRanges< 3 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 3 > *functor)
 Executes a 3D loop.
static void executeParallelFor (const ComplexForLoopRanges< 4 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 4 > *functor)
 Executes a 4D loop.
static void executeParallelFor (const ComplexForLoopRanges< 4 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 4 > *functor)
 Executes a 4D loop.
static Int32 nbAllowedThread ()
 Maximum number of threads used to manage tasks.
static Int32 currentTaskThreadIndex ()
 Index (between 0 and nbAllowedThread()-1) of the thread executing the current task.
static Int32 currentTaskIndex ()
 Index (between 0 and nbAllowedThread()-1) of the current task.
static void setDefaultParallelLoopOptions (const ParallelLoopOptions &v)
 Sets the default parallel loop execution options.
static const ParallelLoopOptionsdefaultParallelLoopOptions ()
 Default parallel loop execution options.
static bool isActive ()
 Indicates whether tasks are active. Tasks are active if an implementation is available and if the requested number of threads is strictly greater than 1.
static void printInfos (std::ostream &o)
 Prints information about the implementation.
static IObservablecreateThreadObservable ()
 Observable called when a thread is created for a task.
static IObservabledestroyThreadObservable ()
 Observable called when a thread is destroyed for a task.
static void terminate ()
 Indicates that threads will no longer be used. This method must not be called when tasks are active.
static void setVerboseLevel (Integer v)
 Sets the verbosity level (0 for no output, which is the default).
static Integer verboseLevel ()
 Verbosity level.
static void _internalSetImplementation (ITaskImplementation *task_impl)

Private Attributes

friend TaskFactoryInternal

Static Private Attributes

static ITaskImplementationm_impl = &NullTaskImplementation::singleton
static Int32 m_verbose_level = 0

Detailed Description

Factory for tasks.

Definition at line 34 of file TaskFactory.h.

Member Function Documentation

◆ _internalSetImplementation()

void Arcane::TaskFactory::_internalSetImplementation ( ITaskImplementation * task_impl)
static

Definition at line 235 of file ConcurrencyUtils.cc.

◆ createChildTask() [1/2]

template<typename InstanceType>
ITask * Arcane::TaskFactory::createChildTask ( ITask * parent_task,
InstanceType * instance,
void(InstanceType::* function )() )
inlinestatic

Creates a child task.

During execution, the task will call the method function via the instance instance.

Definition at line 89 of file TaskFactory.h.

References ARCCORE_CHECK_POINTER.

◆ createChildTask() [2/2]

template<typename InstanceType>
ITask * Arcane::TaskFactory::createChildTask ( ITask * parent_task,
InstanceType * instance,
void(InstanceType::* function )(const TaskContext &tc) )
inlinestatic

Creates a child task.

During execution, the task will call the method function via the instance instance.

Definition at line 75 of file TaskFactory.h.

References ARCCORE_CHECK_POINTER.

◆ createTask() [1/2]

template<typename InstanceType>
ITask * Arcane::TaskFactory::createTask ( InstanceType * instance,
void(InstanceType::* function )() )
inlinestatic

Creates a task. During execution, the task will call the method function via the instance instance.

Definition at line 62 of file TaskFactory.h.

◆ createTask() [2/2]

template<typename InstanceType>
ITask * Arcane::TaskFactory::createTask ( InstanceType * instance,
void(InstanceType::* function )(const TaskContext &tc) )
inlinestatic

Creates a task. During execution, the task will call the method function via the instance instance.

Definition at line 50 of file TaskFactory.h.

◆ createThreadObservable()

IObservable * Arcane::TaskFactory::createThreadObservable ( )
static

Observable called when a thread is created for a task.

Warning
The observable instance is created during the first call to this method. It is therefore not thread-safe. Similarly, modifying the observable (adding/removing observers) is not thread-safe.

Definition at line 244 of file ConcurrencyUtils.cc.

◆ currentTaskIndex()

Int32 Arcane::TaskFactory::currentTaskIndex ( )
inlinestatic

Index (between 0 and nbAllowedThread()-1) of the current task.

This index is the same as currentTaskThreadIndex() except when we are in an executeParallelFor() with deterministic partitioning (ParallelLoopOptions::Partitioner::Deterministic). In the latter case, the task number is assigned deterministically, depending only on the number of threads allocated for the task and ParallelLoopOptions::grainSize().

If the current thread is not executing a task associated with this implementation, it returns (-1).

Definition at line 213 of file TaskFactory.h.

◆ currentTaskThreadIndex()

Int32 Arcane::TaskFactory::currentTaskThreadIndex ( )
inlinestatic

Index (between 0 and nbAllowedThread()-1) of the thread executing the current task.

For performance reasons, it is preferable to call this method as little as possible. Ideally, it should only be called at the beginning of the task execution and then the returned value should be used.

Definition at line 195 of file TaskFactory.h.

◆ defaultParallelLoopOptions()

const ParallelLoopOptions & Arcane::TaskFactory::defaultParallelLoopOptions ( )
inlinestatic

Default parallel loop execution options.

Definition at line 230 of file TaskFactory.h.

References Arcane::ConcurrencyBase::defaultParallelLoopOptions().

Referenced by Arcane::TBBTaskImplementation::_executeMDParallelFor(), Arcane::arcaneParallelForeach(), Arcane::arcaneParallelForeach(), Arcane::TBBTaskImplementation::executeParallelFor(), Arcane::TBBTaskImplementation::executeParallelFor(), and Arcane::TBBTaskImplementation::initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyThreadObservable()

IObservable * Arcane::TaskFactory::destroyThreadObservable ( )
static

Observable called when a thread is destroyed for a task.

Warning
The observable instance is created during the first call to this method. It is therefore not thread-safe. Similarly, modifying the observable (adding/removing observers) is not thread-safe.

Definition at line 254 of file ConcurrencyUtils.cc.

◆ executeParallelFor() [1/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 1 > & loop_ranges,
const ForLoopRunInfo & run_info,
IMDRangeFunctor< 1 > * functor )
inlinestatic

Executes a simple loop.

Definition at line 129 of file TaskFactory.h.

◆ executeParallelFor() [2/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 1 > & loop_ranges,
const ParallelLoopOptions & options,
IMDRangeFunctor< 1 > * functor )
inlinestatic

Executes a simple loop.

Definition at line 121 of file TaskFactory.h.

◆ executeParallelFor() [3/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 2 > & loop_ranges,
const ForLoopRunInfo & run_info,
IMDRangeFunctor< 2 > * functor )
inlinestatic

Executes a 2D loop.

Definition at line 145 of file TaskFactory.h.

◆ executeParallelFor() [4/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 2 > & loop_ranges,
const ParallelLoopOptions & options,
IMDRangeFunctor< 2 > * functor )
inlinestatic

Executes a 2D loop.

Definition at line 137 of file TaskFactory.h.

◆ executeParallelFor() [5/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 3 > & loop_ranges,
const ForLoopRunInfo & run_info,
IMDRangeFunctor< 3 > * functor )
inlinestatic

Executes a 3D loop.

Definition at line 161 of file TaskFactory.h.

◆ executeParallelFor() [6/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 3 > & loop_ranges,
const ParallelLoopOptions & options,
IMDRangeFunctor< 3 > * functor )
inlinestatic

Executes a 3D loop.

Definition at line 153 of file TaskFactory.h.

◆ executeParallelFor() [7/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 4 > & loop_ranges,
const ForLoopRunInfo & run_info,
IMDRangeFunctor< 4 > * functor )
inlinestatic

Executes a 4D loop.

Definition at line 177 of file TaskFactory.h.

◆ executeParallelFor() [8/12]

void Arcane::TaskFactory::executeParallelFor ( const ComplexForLoopRanges< 4 > & loop_ranges,
const ParallelLoopOptions & options,
IMDRangeFunctor< 4 > * functor )
inlinestatic

Executes a 4D loop.

Definition at line 169 of file TaskFactory.h.

◆ executeParallelFor() [9/12]

void Arcane::TaskFactory::executeParallelFor ( const ParallelFor1DLoopInfo & loop_info)
inlinestatic

Executes the loop loop_info in parallel.

Definition at line 115 of file TaskFactory.h.

◆ executeParallelFor() [10/12]

◆ executeParallelFor() [11/12]

void Arcane::TaskFactory::executeParallelFor ( Integer begin,
Integer size,
Integer block_size,
IRangeFunctor * f )
inlinestatic

Executes the functor f in parallel.

Definition at line 103 of file TaskFactory.h.

◆ executeParallelFor() [12/12]

void Arcane::TaskFactory::executeParallelFor ( Integer begin,
Integer size,
IRangeFunctor * f )
inlinestatic

Executes the functor f in parallel.

Definition at line 109 of file TaskFactory.h.

◆ isActive()

bool Arcane::TaskFactory::isActive ( )
inlinestatic

Indicates whether tasks are active. Tasks are active if an implementation is available and if the requested number of threads is strictly greater than 1.

Definition at line 242 of file TaskFactory.h.

Referenced by Arcane::Application::initialize().

Here is the caller graph for this function:

◆ nbAllowedThread()

Int32 Arcane::TaskFactory::nbAllowedThread ( )
inlinestatic

Maximum number of threads used to manage tasks.

Definition at line 185 of file TaskFactory.h.

References Arcane::ConcurrencyBase::maxAllowedThread().

Referenced by Arcane::Application::initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printInfos()

void Arcane::TaskFactory::printInfos ( std::ostream & o)
inlinestatic

Prints information about the implementation.

The information is for example the version number or the name of the implementation.

Definition at line 253 of file TaskFactory.h.

Referenced by Arcane::Application::initialize().

Here is the caller graph for this function:

◆ setDefaultParallelLoopOptions()

void Arcane::TaskFactory::setDefaultParallelLoopOptions ( const ParallelLoopOptions & v)
inlinestatic

Sets the default parallel loop execution options.

Definition at line 224 of file TaskFactory.h.

References Arcane::ConcurrencyBase::setDefaultParallelLoopOptions().

Referenced by Arcane::ArcaneLauncher::init(), and Arcane::TBBTaskImplementation::initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVerboseLevel()

void Arcane::TaskFactory::setVerboseLevel ( Integer v)
inlinestatic

Sets the verbosity level (0 for no output, which is the default).

Definition at line 290 of file TaskFactory.h.

References setVerboseLevel().

Referenced by setVerboseLevel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ terminate()

void Arcane::TaskFactory::terminate ( )
static

Indicates that threads will no longer be used. This method must not be called when tasks are active.

Definition at line 265 of file ConcurrencyUtils.cc.

Referenced by Arcane::Application::~Application().

Here is the caller graph for this function:

◆ verboseLevel()

Integer Arcane::TaskFactory::verboseLevel ( )
inlinestatic

Verbosity level.

Definition at line 293 of file TaskFactory.h.

Referenced by Arcane::TBBTaskImplementation::_executeMDParallelFor().

Here is the caller graph for this function:

Member Data Documentation

◆ m_impl

ITaskImplementation * Arcane::TaskFactory::m_impl = &NullTaskImplementation::singleton
staticprivate

Definition at line 304 of file TaskFactory.h.

◆ m_verbose_level

Int32 Arcane::TaskFactory::m_verbose_level = 0
staticprivate

Definition at line 305 of file TaskFactory.h.

◆ TaskFactoryInternal

friend Arcane::TaskFactory::TaskFactoryInternal
private

Definition at line 36 of file TaskFactory.h.


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