Arcane  v4.1.2.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ParallelLoopOptions.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ParallelLoopOptions.cc (C) 2000-2025 */
9/* */
10/* Options de configuration pour les boucles parallèles en multi-thread. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ParallelLoopOptions.h"
15
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
18
19#include "arccore/common/internal/Property.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace
31{
32 const char*
33 _partitionerToString(ParallelLoopOptions::Partitioner p)
34 {
35 switch (p) {
37 return "static";
39 return "deterministic";
41 return "auto";
42 }
43 ARCANE_FATAL("Bad value {0} for partitioner", (int)p);
44 }
45
47 _stringToPartitioner(const String& str)
48 {
49 if (str == "static")
51 if (str == "deterministic")
53 if (str == "auto")
55 ARCANE_FATAL("Bad value '{0}' for partitioner. Valid values are 'auto', 'static' or 'deterministic'", str);
56 }
57} // namespace
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62template <typename V> void ParallelLoopOptionsProperties::
63_applyPropertyVisitor(V& p)
64{
65 auto b = p.builder();
66 p << b.addInt32("ParallelLoopGrainSize")
67 .addDescription("GrainSize of the loop")
68 .addCommandLineArgument("ParallelLoopGrainSize")
69 .addGetter([](auto a) { return a.x.grainSize(); })
70 .addSetter([](auto a) { a.x.setGrainSize(a.v); });
71
72 p << b.addString("ParallelLoopPartitioner")
73 .addDescription("Partitioner for the loop (auto, static or deterministic)")
74 .addCommandLineArgument("ParallelLoopPartitioner")
75 .addGetter([](auto a) { return _partitionerToString(a.x.partitioner()); })
76 .addSetter([](auto a) { a.x.setPartitioner(_stringToPartitioner(a.v)); });
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82ARCANE_REGISTER_PROPERTY_CLASS(ParallelLoopOptionsProperties, ());
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87} // End namespace Arcane
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
@ Auto
Laisse le partitionneur géré le partitionnement et l'ordonnancement (défaut)
@ Deterministic
Utilise un partitionnement et un ordonnancement statique.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-