12#ifndef ARCANE_CORE_CONCURRENCY_H
13#define ARCANE_CORE_CONCURRENCY_H
19#include "arcane/core/Item.h"
20#include "arcane/core/ItemFunctor.h"
21#include "arcane/core/ItemGroup.h"
23#include "arcane/core/materials/MatItem.h"
33adaptGrainSize(
const ForLoopRunInfo& run_info)
35 const std::optional<ParallelLoopOptions>& options = run_info.options();
36 Int32 grain_size = AbstractItemRangeFunctor::DEFAULT_GRAIN_SIZE;
37 if (options.has_value())
38 if (options.value().hasGrainSize())
39 grain_size = options.value().grainSize();
56template <
typename InstanceType,
typename ItemType>
inline void
60 Int32 grain_size = impl::adaptGrainSize(run_info);
66 adapted_run_info.addOptions(loop_opt);
80template <
typename LambdaType>
inline void
82 const LambdaType& lambda_function)
84 Int32 grain_size = impl::adaptGrainSize(run_info);
90 adapted_run_info.addOptions(loop_opt);
105template <
typename InstanceType,
typename ItemType>
inline void
118template <
typename InstanceType,
typename ItemType>
inline void
130template <
typename InstanceType,
typename ItemType>
inline void
142template <
typename InstanceType,
typename ItemType>
inline void
154template <
typename LambdaType>
inline void
156 const LambdaType& lambda_function)
166template <
typename LambdaType>
inline void
168 const LambdaType& lambda_function)
178template <
typename LambdaType>
inline void
189template <
typename LambdaType>
inline void
202template <
typename InstanceType>
inline void
216template <
typename LambdaType>
inline void
218 const LambdaType& lambda_function)
230template <
typename LambdaType>
inline void
232 const LambdaType& lambda_function)
241template <
typename LambdaType>
inline void
257template <
typename LambdaType,
typename... Views>
inline void
261 typename std::tuple_element_t<0, std::tuple<Views...>>
::size_type sizes[] = { views.size()... };
262 if (!std::all_of(std::begin(sizes), std::end(sizes), [&sizes](
auto cur) {
return cur == sizes[0]; }))
286 template <
typename InstanceType,
typename ItemType>
287 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
301 template <
typename InstanceType,
typename ItemType>
302 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
306 Foreach(items._paddedView(), options, instance, function);
312 template <
typename InstanceType,
typename ItemType>
313 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
323 template <
typename InstanceType,
typename ItemType>
324 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
327 Foreach(items._paddedView(), instance, function);
333 template <
typename LambdaType>
334 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
347 template <
typename LambdaType>
348 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
357 template <
typename LambdaType>
358 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
368 template <
typename LambdaType>
369 [[deprecated(
"Year2021: Use Arcane::arcaneParallelForeach() instead")]]
inline void
378 template <
typename InstanceType> ARCANE_DEPRECATED_122
inline void
389 template <
typename InstanceType>
390 [[deprecated(
"Year2021: Use Arcane::arcaneParallelFor() instead")]]
inline void
401 template <
typename LambdaType> ARCANE_DEPRECATED_122
inline void
411 template <
typename InstanceType>
412 [[deprecated(
"Year2021: Use Arcane::arcaneParallelFor() instead")]]
inline void
423 template <
typename LambdaType>
424 [[deprecated(
"Year2021: Use Arcane::arcaneParallelFor() instead")]]
inline void
434 template <
typename LambdaType>
435 [[deprecated(
"Year2021: Use Arcane::arcaneParallelFor() instead")]]
inline void
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Classes, Types, and macros for managing concurrency.
Int32 nbBlock() const
Number of blocks.
Int32 blockGrainSize() const
Desired size of an iteration interval.
Loop execution information.
ItemVectorView _paddedView() const
View of the group entities with padding for vectorization.
Functor for iterating over a list of entities.
View on a typed array of entities.
View on a vector of entities.
Functor on an iteration interval instantiated via a lambda function.
Functor over an iteration interval instantiated via a lambda function.
Functor over an iteration interval instantiated via a lambda function.
Characteristics of a multi-thread 1D loop.
Execution options for a parallel loop in multi-threading.
Integer grainSize() const
Size of an iteration interval.
void setGrainSize(Integer v)
Sets the size (approximate) of an iteration interval.
Functor over an iteration interval.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Default parallel loop execution options.
static void executeParallelFor(Integer begin, Integer size, const ParallelLoopOptions &options, IRangeFunctor *f)
Executes the functor f in parallel.
void arcaneParallelForeach(const ItemVectorView &items_view, const ForLoopRunInfo &run_info, InstanceType *instance, void(InstanceType::*function)(ItemVectorViewT< ItemType > items))
Applies the method function of the instance instance concurrently on the view items_view with the opt...
void arcaneParallelForVa(const ForLoopRunInfo &run_info, const LambdaType &lambda_function, Views... views)
Applies the lambda function lambda_function instance concurrently on the container views views with t...
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,...
Concurrency implementation.
void Foreach(const ItemVectorView &items_view, const ParallelLoopOptions &options, InstanceType *instance, void(InstanceType::*function)(ItemVectorViewT< ItemType > items))
ARCANE_DEPRECATED_122 void For(Integer i0, Integer size, Integer grain_size, InstanceType *itype, void(InstanceType::*lambda_function)(Integer i0, Integer size))
-- 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.