12#ifndef ARCCORE_CONCURRENCY_TASKFACTORY_H
13#define ARCCORE_CONCURRENCY_TASKFACTORY_H
17#include "arccore/base/ConcurrencyBase.h"
18#include "arccore/concurrency/Task.h"
19#include "arccore/concurrency/ITaskImplementation.h"
34class ARCCORE_CONCURRENCY_EXPORT TaskFactory
36 friend TaskFactoryInternal;
40 TaskFactory() =
delete;
49 template <
typename InstanceType>
static ITask*
53 return m_impl->createRootTask(&functor);
61 template <
typename InstanceType>
static ITask*
62 createTask(InstanceType* instance,
void (InstanceType::*function)())
65 return m_impl->createRootTask(&functor);
74 template <
typename InstanceType>
static ITask*
79 return parent_task->_createChildTask(&functor);
88 template <
typename InstanceType>
static ITask*
93 return parent_task->_createChildTask(&functor);
99 m_impl->executeParallelFor(begin, size, options, f);
105 m_impl->executeParallelFor(begin, size, block_size, f);
111 m_impl->executeParallelFor(begin, size, f);
117 m_impl->executeParallelFor(loop_info);
125 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
133 m_impl->executeParallelFor(loop_ranges, run_info, functor);
141 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
149 m_impl->executeParallelFor(loop_ranges, run_info, functor);
157 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
165 m_impl->executeParallelFor(loop_ranges, run_info, functor);
173 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
181 m_impl->executeParallelFor(loop_ranges, run_info, functor);
197 return m_impl->currentTaskThreadIndex();
215 return m_impl->currentTaskIndex();
244 return m_impl->isActive();
255 return m_impl->printInfos(o);
266 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. Do not use it")
277 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. Do not use it")
285 static
void terminate();
298 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. "
299 "Use TaskFactoryInternal::setImplementation() instead")
305 static
Int32 m_verbose_level;
#define ARCCORE_CHECK_POINTER(ptr)
Macro that returns the pointer ptr if it is not null or throws an exception if it is null.
static void setDefaultParallelLoopOptions(const ParallelLoopOptions &v)
Sets the default execution values for a parallel loop.
static Int32 maxAllowedThread()
Maximum number of allowed threads for multi-threading.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Default execution values for a parallel loop.
Loop execution information.
Interface of a functor on a multi-dimensional iteration interval of dimension RankValue.
Interface of an observable.
Interface of a functor on an iteration interval.
Interface for a concurrent task.
Characteristics of a multi-thread 1D loop.
Execution options for a parallel loop in multi-threading.
Execution context of a task.
static Int32 currentTaskIndex()
Index (between 0 and nbAllowedThread()-1) of the current task.
static void executeParallelFor(const ParallelFor1DLoopInfo &loop_info)
Executes the loop loop_info in parallel.
static void setVerboseLevel(Integer v)
Sets the verbosity level (0 for no output, which is the default).
static Int32 nbAllowedThread()
Maximum number of threads used to manage tasks.
static void executeParallelFor(Integer begin, Integer size, IRangeFunctor *f)
Executes the functor f in parallel.
static ITask * createTask(InstanceType *instance, void(InstanceType::*function)())
Creates a task. During execution, the task will call the method function via the instance instance.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Default parallel loop execution options.
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 ForLoopRunInfo &run_info, IMDRangeFunctor< 2 > *functor)
Executes a 2D loop.
static Integer verboseLevel()
Verbosity level.
static void executeParallelFor(const ComplexForLoopRanges< 4 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 4 > *functor)
Executes a 4D loop.
static void executeParallelFor(const ComplexForLoopRanges< 2 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 2 > *functor)
Executes a 2D loop.
static void setDefaultParallelLoopOptions(const ParallelLoopOptions &v)
Sets the default parallel loop execution options.
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(const ComplexForLoopRanges< 3 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 3 > *functor)
Executes a 3D loop.
static ITask * createChildTask(ITask *parent_task, InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
Creates a child task.
static Int32 currentTaskThreadIndex()
Index (between 0 and nbAllowedThread()-1) of the thread executing the current task.
static ITask * createChildTask(ITask *parent_task, InstanceType *instance, void(InstanceType::*function)())
Creates a child task.
static bool isActive()
Indicates whether tasks are active. Tasks are active if an implementation is available and if the req...
static ITask * createTask(InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
Creates a task. During execution, the task will call the method function via the instance instance.
static void executeParallelFor(const ComplexForLoopRanges< 4 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 4 > *functor)
Executes a 4D loop.
static void printInfos(std::ostream &o)
Prints information about the implementation.
static void executeParallelFor(const ComplexForLoopRanges< 3 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 3 > *functor)
Executes a 3D loop.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.