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"
33class ARCCORE_CONCURRENCY_EXPORT TaskFactory
35 friend TaskFactoryInternal;
39 TaskFactory() =
delete;
48 template <
typename InstanceType>
static ITask*
52 return m_impl->createRootTask(&functor);
60 template <
typename InstanceType>
static ITask*
61 createTask(InstanceType* instance,
void (InstanceType::*function)())
64 return m_impl->createRootTask(&functor);
73 template <
typename InstanceType>
static ITask*
76 ARCCORE_CHECK_POINTER(parent_task);
78 return parent_task->_createChildTask(&functor);
87 template <
typename InstanceType>
static ITask*
90 ARCCORE_CHECK_POINTER(parent_task);
92 return parent_task->_createChildTask(&functor);
98 m_impl->executeParallelFor(begin, size, options, f);
104 m_impl->executeParallelFor(begin, size, block_size, f);
110 m_impl->executeParallelFor(begin, size, f);
116 m_impl->executeParallelFor(loop_info);
124 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
132 m_impl->executeParallelFor(loop_ranges, run_info, functor);
140 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
148 m_impl->executeParallelFor(loop_ranges, run_info, functor);
156 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
164 m_impl->executeParallelFor(loop_ranges, run_info, functor);
172 m_impl->executeParallelFor(loop_ranges,
ForLoopRunInfo(options), functor);
180 m_impl->executeParallelFor(loop_ranges, run_info, functor);
195 return m_impl->currentTaskThreadIndex();
213 return m_impl->currentTaskIndex();
242 return m_impl->isActive();
253 return m_impl->printInfos(o);
264 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. Do not use it")
275 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. Do not use it")
283 static
void terminate();
296 ARCCORE_DEPRECATED_REASON(
"Y2024: This method is internal to Arcane. "
297 "Use TaskFactoryInternal::setImplementation() instead")
303 static
Int32 m_verbose_level;
Interval d'itération complexe.
static void setDefaultParallelLoopOptions(const ParallelLoopOptions &v)
Positionne les valeurs par défaut d'exécution d'une boucle parallèle.
static Int32 maxAllowedThread()
Nombre maximum de threads autorisés pour le multi-threading.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Valeurs par défaut d'exécution d'une boucle parallèle.
Informations d'exécution d'une boucle.
Interface d'un fonctor sur un interval d'itération multi-dimensionnel de dimension RankValue.
Interface d'un observable.
Interface d'un fonctor sur un interval d'itération.
Implémentation d'une fabrique de tâches.
Interface d'une tâche concourante.
Caractéristiques d'un boucle 1D multi-thread.
Options d'exécution d'une boucle parallèle en multi-thread.
Contexte d'éxecution d'une tâche.
static Int32 currentTaskIndex()
Indice (entre 0 et nbAllowedThread()-1) de la tâche actuelle.
static void executeParallelFor(const ParallelFor1DLoopInfo &loop_info)
Exécute la boucle loop_info en concurrence.
static void setVerboseLevel(Integer v)
Positionne le niveau de verbosité (0 pour pas d'affichage qui est le défaut)
static Int32 nbAllowedThread()
Nombre de threads utilisés au maximum pour gérer les tâches.
static void executeParallelFor(Integer begin, Integer size, IRangeFunctor *f)
Exécute le fonctor f en concurrence.
static ITask * createTask(InstanceType *instance, void(InstanceType::*function)())
Créé une tâche. Lors de l'exécution, la tâche appellera la méthode function via l'instance instance.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Valeurs par défaut d'exécution d'une boucle parallèle.
static void executeParallelFor(const ComplexForLoopRanges< 1 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 1 > *functor)
Exécute une boucle simple.
static void executeParallelFor(const ComplexForLoopRanges< 1 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 1 > *functor)
Exécute une boucle simple.
static void executeParallelFor(const ComplexForLoopRanges< 2 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 2 > *functor)
Exécute une boucle 2D.
static Integer verboseLevel()
Niveau de verbosité
static void executeParallelFor(const ComplexForLoopRanges< 4 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 4 > *functor)
Exécute une boucle 4D.
static void executeParallelFor(const ComplexForLoopRanges< 2 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 2 > *functor)
Exécute une boucle 2D.
static void setDefaultParallelLoopOptions(const ParallelLoopOptions &v)
Positionne les valeurs par défaut d'exécution d'une boucle parallèle.
static void executeParallelFor(Integer begin, Integer size, const ParallelLoopOptions &options, IRangeFunctor *f)
Exécute le fonctor f en concurrence.
static void executeParallelFor(Integer begin, Integer size, Integer block_size, IRangeFunctor *f)
Exécute le fonctor f en concurrence.
static void executeParallelFor(const ComplexForLoopRanges< 3 > &loop_ranges, const ParallelLoopOptions &options, IMDRangeFunctor< 3 > *functor)
Exécute une boucle 3D.
static ITask * createChildTask(ITask *parent_task, InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
Créé une tâche fille.
static Int32 currentTaskThreadIndex()
Indice (entre 0 et nbAllowedThread()-1) du thread exécutant la tâche actuelle.
static ITask * createChildTask(ITask *parent_task, InstanceType *instance, void(InstanceType::*function)())
Créé une tâche fille.
static bool isActive()
Indique si les tâches sont actives. Les tâches sont actives si une implémentation est disponible et s...
static ITask * createTask(InstanceType *instance, void(InstanceType::*function)(const TaskContext &tc))
Créé une tâche. Lors de l'exécution, la tâche appellera la méthode function via l'instance instance.
static void executeParallelFor(const ComplexForLoopRanges< 4 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 4 > *functor)
Exécute une boucle 4D.
static void printInfos(std::ostream &o)
Affiche les informations sur l'implémentation.
static void executeParallelFor(const ComplexForLoopRanges< 3 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 3 > *functor)
Exécute une boucle 3D.
Fonctor pour une tâche prenant un TaskContext en argument.
Fonctor sans argument pour une tâche.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
std::int32_t Int32
Type entier signé sur 32 bits.