Arcane  4.1.12.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-2025 */
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/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \internal
30 * \brief Implementation of a task factory.
31 *
32 * \ingroup Concurrency
33 *
34 * This class is internal to Arcane. To manage tasks, you
35 * must use the TaskFactory class.
36 */
37class ARCCORE_CONCURRENCY_EXPORT ITaskImplementation
38{
39 public:
40
41 virtual ~ITaskImplementation() = default;
42
43 public:
44
45 /*!
46 * \internal.
47 * Initializes the implementation with a maximum of \a nb_thread.
48 * If \a nb_thread is 0, the implementation can choose
49 * the number of threads automatically.
50 * This method is internal to Arcane and should only be called
51 * during the execution initialization.
52 */
53 virtual void initialize(Int32 nb_thread) = 0;
54 /*!
55 * \internal.
56 * Terminates the use of the implementation.
57 * This method must be called only at the end of the calculation.
58 */
59 virtual void terminate() = 0;
60 /*!
61 * \brief Creates a root task.
62 * The implementation must copy the value of \a f, which is either
63 * a TaskFunctor or a TaskFunctorWithContext.
64 */
66
67 //! Executes the functor \a f in parallel.
68 virtual void executeParallelFor(Integer begin, Integer size, const ParallelLoopOptions& options, IRangeFunctor* f) = 0;
69
70 //! Executes the functor \a f in parallel.
71 virtual void executeParallelFor(Integer begin, Integer size, Integer block_size, IRangeFunctor* f) = 0;
72
73 //! Executes the functor \a f in parallel.
74 virtual void executeParallelFor(Integer begin, Integer size, IRangeFunctor* f) = 0;
75
76 //! Executes the loop \a loop_info in parallel.
77 virtual void executeParallelFor(const ParallelFor1DLoopInfo& loop_info) = 0;
78
79 //! Executes a 1D loop in parallel
80 virtual void executeParallelFor(const ComplexForLoopRanges<1>& loop_ranges,
81 const ForLoopRunInfo& run_info,
82 IMDRangeFunctor<1>* functor) = 0;
83 //! Executes a 2D loop in parallel
84 virtual void executeParallelFor(const ComplexForLoopRanges<2>& loop_ranges,
85 const ForLoopRunInfo& run_info,
86 IMDRangeFunctor<2>* functor) = 0;
87 //! Executes a 3D loop in parallel
88 virtual void executeParallelFor(const ComplexForLoopRanges<3>& loop_ranges,
89 const ForLoopRunInfo& run_info,
90 IMDRangeFunctor<3>* functor) = 0;
91 //! Executes a 4D loop in parallel
92 virtual void executeParallelFor(const ComplexForLoopRanges<4>& loop_ranges,
93 const ForLoopRunInfo& run_info,
94 IMDRangeFunctor<4>* functor) = 0;
95
96 //! Indicates if the implementation is active.
97 virtual bool isActive() const = 0;
98
99 //! Maximum number of threads used to manage tasks
100 ARCCORE_DEPRECATED_REASON("Y2025: use ConcurrencyBase::maxAllowedThread() instead")
101 Int32 nbAllowedThread() const;
102
103 //! Implementation of TaskFactory::currentTaskThreadIndex()
104 virtual Int32 currentTaskThreadIndex() const = 0;
105
106 //! Implementation of TaskFactory::currentTaskIndex()
107 virtual Int32 currentTaskIndex() const = 0;
108
109 //! Prints information about the runtime used
110 virtual void printInfos(std::ostream& o) const = 0;
111};
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116} // End namespace Arcane
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121#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.