Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ConcurrencyUtils.h
Go to the documentation of this file.
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/* ConcurrencyUtils.h (C) 2000-2025 */
9/* */
10/* Classes managing concurrency (tasks, parallel loops, ...) */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_CONCURRENCYUTILS_H
13#define ARCANE_UTILS_CONCURRENCYUTILS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include "arccore/concurrency/ParallelFor.h"
20#include "arccore/concurrency/TaskFactory.h"
21#include "arccore/concurrency/ITaskImplementation.h"
22#include "arccore/concurrency/Task.h"
23#include "arccore/base/ForLoopRunInfo.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34/*!
35 * \brief Applies the lambda function \a lambda_function
36 * concurrently over the iteration range given by \a loop_ranges.
37 */
38template <int RankValue, typename LambdaType, typename... ReducerArgs> inline void
40 const ForLoopRunInfo& run_info,
41 const LambdaType& lambda_function,
42 const ReducerArgs&... reducer_args)
43{
44 arccoreParallelFor(loop_ranges, run_info, lambda_function, reducer_args...);
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50/*!
51 * \brief Applies the lambda function \a lambda_function
52 * concurrently over the iteration range given by \a loop_ranges.
53 */
54template <int RankValue, typename LambdaType, typename... ReducerArgs> inline void
56 const ParallelLoopOptions& options,
57 const LambdaType& lambda_function,
58 const ReducerArgs&... reducer_args)
59{
60 arccoreParallelFor(loop_ranges, ForLoopRunInfo(options), lambda_function, reducer_args...);
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66/*!
67 * \brief Applies the lambda function \a lambda_function
68 * concurrently over the iteration range given by \a loop_ranges.
69 */
70template <int RankValue, typename LambdaType, typename... ReducerArgs> inline void
72 const ForLoopRunInfo& run_info,
73 const LambdaType& lambda_function,
74 const ReducerArgs&... reducer_args)
75{
76 arccoreParallelFor(loop_ranges, run_info, lambda_function, reducer_args...);
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82/*!
83 * \brief Applies the lambda function \a lambda_function
84 * concurrently over the iteration range given by \a loop_ranges.
85 */
86template <int RankValue, typename LambdaType, typename... ReducerArgs> inline void
88 const ParallelLoopOptions& options,
89 const LambdaType& lambda_function,
90 const ReducerArgs&... reducer_args)
91{
92 arccoreParallelFor(loop_ranges, options, lambda_function, reducer_args...);
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98/*!
99 * \brief Applies the lambda function \a lambda_function
100 * concurrently over the iteration range given by \a loop_ranges.
101 */
102template <int RankValue, typename LambdaType> inline void
104 const LambdaType& lambda_function)
105{
106 arccoreParallelFor(loop_ranges, lambda_function);
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112/*!
113 * \brief Applies the lambda function \a lambda_function
114 * concurrently over the iteration range given by \a loop_ranges.
115 */
116template <int RankValue, typename LambdaType> inline void
118 const LambdaType& lambda_function)
119{
120 arccoreParallelFor(loop_ranges, lambda_function);
121}
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126} // End namespace Arcane
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
131#endif
Declarations of types used in Arcane.
Loop execution information.
Execution options for a parallel loop in multi-threading.
void arcaneParallelFor(Integer i0, Integer size, InstanceType *itype, void(InstanceType::*lambda_function)(Integer i0, Integer size))
Applies the lambda function lambda_function concurrently over the iteration range [i0,...
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
void arccoreParallelFor(const ComplexForLoopRanges< RankValue > &loop_ranges, const ForLoopRunInfo &run_info, const LambdaType &lambda_function, const ReducerArgs &... reducer_args)
Applies the lambda function lambda_function concurrently over the iteration interval given by loop_ra...
Definition ParallelFor.h:87