Arcane  4.2.1.0
User documentation
Loading...
Searching...
No Matches
ITaskImplementation.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ITaskImplementation.h (C) 2000-2026 */
9/* */
10/* Task management interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_BASE_ITASKIMPLEMENTATION_H
13#define ARCCORE_BASE_ITASKIMPLEMENTATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/concurrency/ConcurrencyGlobal.h"
18
19#include <iosfwd>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \internal
32 * \brief Implementation of a task factory.
33 *
34 * \ingroup Concurrency
35 *
36 * This class is internal to Arcane. To manage tasks, you
37 * must use the TaskFactory class.
38 */
39class ARCCORE_CONCURRENCY_EXPORT ITaskImplementation
40{
41 public:
42
43 virtual ~ITaskImplementation() = default;
44
45 public:
46
47 /*!
48 * \internal.
49 * Initializes the implementation with a maximum of \a nb_thread.
50 * If \a nb_thread is 0, the implementation can choose
51 * the number of threads automatically.
52 * This method is internal to Arcane and should only be called
53 * during the execution initialization.
54 */
55 virtual void initialize(Int32 nb_thread) = 0;
56 /*!
57 * \internal.
58 * Terminates the use of the implementation.
59 * This method must be called only at the end of the calculation.
60 */
61 virtual void terminate() = 0;
62 /*!
63 * \brief Creates a root task.
64 * The implementation must copy the value of \a f, which is either
65 * a TaskFunctor or a TaskFunctorWithContext.
66 */
68
69 //! Executes the functor \a f in parallel.
70 virtual void executeParallelFor(Integer begin, Integer size, const ParallelLoopOptions& options, IRangeFunctor* f) = 0;
71
72 //! Executes the functor \a f in parallel.
73 virtual void executeParallelFor(Integer begin, Integer size, Integer block_size, IRangeFunctor* f) = 0;
74
75 //! Executes the functor \a f in parallel.
76 virtual void executeParallelFor(Integer begin, Integer size, IRangeFunctor* f) = 0;
77
78 //! Executes the loop \a loop_info in parallel.
79 virtual void executeParallelFor(const ParallelFor1DLoopInfo& loop_info) = 0;
80
81 //! Executes a 1D loop in parallel
82 virtual void executeParallelFor(const ComplexForLoopRanges<1>& loop_ranges,
83 const ForLoopRunInfo& run_info,
84 IMDRangeFunctor<1>* functor) = 0;
85 //! Executes a 2D loop in parallel
86 virtual void executeParallelFor(const ComplexForLoopRanges<2>& loop_ranges,
87 const ForLoopRunInfo& run_info,
88 IMDRangeFunctor<2>* functor) = 0;
89 //! Executes a 3D loop in parallel
90 virtual void executeParallelFor(const ComplexForLoopRanges<3>& loop_ranges,
91 const ForLoopRunInfo& run_info,
92 IMDRangeFunctor<3>* functor) = 0;
93 //! Executes a 4D loop in parallel
94 virtual void executeParallelFor(const ComplexForLoopRanges<4>& loop_ranges,
95 const ForLoopRunInfo& run_info,
96 IMDRangeFunctor<4>* functor) = 0;
97
98 //! Indicates if the implementation is active.
99 virtual bool isActive() const = 0;
100
101 //! Maximum number of threads used to manage tasks
102 ARCCORE_DEPRECATED_REASON("Y2025: use ConcurrencyBase::maxAllowedThread() instead")
103 Int32 nbAllowedThread() const;
104
105 //! Implementation of TaskFactory::currentTaskThreadIndex()
106 virtual Int32 currentTaskThreadIndex() const = 0;
107
108 //! Implementation of TaskFactory::currentTaskIndex()
109 virtual Int32 currentTaskIndex() const = 0;
110
111 //! Prints information about the runtime used
112 virtual void printInfos(std::ostream& o) const = 0;
113};
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118} // End namespace Arcane
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123#endif
Loop execution information.
Interface of a functor on a multi-dimensional iteration interval of dimension RankValue.
Interface of a functor on an iteration interval.
virtual void executeParallelFor(Integer begin, Integer size, const ParallelLoopOptions &options, IRangeFunctor *f)=0
Executes the functor f in parallel.
virtual void executeParallelFor(Integer begin, Integer size, IRangeFunctor *f)=0
Executes the functor f in parallel.
virtual void executeParallelFor(const ParallelFor1DLoopInfo &loop_info)=0
Executes the loop loop_info in parallel.
Int32 nbAllowedThread() const
Maximum number of threads used to manage tasks.
virtual void executeParallelFor(const ComplexForLoopRanges< 2 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 2 > *functor)=0
Executes a 2D loop in parallel.
virtual void executeParallelFor(Integer begin, Integer size, Integer block_size, IRangeFunctor *f)=0
Executes the functor f in parallel.
virtual void executeParallelFor(const ComplexForLoopRanges< 3 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 3 > *functor)=0
Executes a 3D loop in parallel.
virtual ITask * createRootTask(ITaskFunctor *f)=0
Creates a root task. The implementation must copy the value of f, which is either a TaskFunctor or a ...
virtual Int32 currentTaskIndex() const =0
Implementation of TaskFactory::currentTaskIndex().
virtual bool isActive() const =0
Indicates if the implementation is active.
virtual void executeParallelFor(const ComplexForLoopRanges< 4 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 4 > *functor)=0
Executes a 4D loop in parallel.
virtual void executeParallelFor(const ComplexForLoopRanges< 1 > &loop_ranges, const ForLoopRunInfo &run_info, IMDRangeFunctor< 1 > *functor)=0
Executes a 1D loop in parallel.
virtual void printInfos(std::ostream &o) const =0
Prints information about the runtime used.
virtual Int32 currentTaskThreadIndex() const =0
Implementation of TaskFactory::currentTaskThreadIndex().
Interface for a concurrent task.
Definition Task.h:194
Characteristics of a multi-thread 1D loop.
Definition ParallelFor.h:35
Execution options for a parallel loop in multi-threading.
-- 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.