Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ParallelLoopOptions.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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-2024 */
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/Property.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace
30{
31 const char*
32 _partitionerToString(ParallelLoopOptions::Partitioner p)
33 {
34 switch (p) {
36 return "static";
38 return "deterministic";
40 return "auto";
41 }
42 ARCANE_FATAL("Bad value {0} for partitioner", (int)p);
43 }
44
46 _stringToPartitioner(const String& str)
47 {
48 if (str == "static")
50 if (str == "deterministic")
52 if (str == "auto")
54 ARCANE_FATAL("Bad value '{0}' for partitioner. Valid values are 'auto', 'static' or 'deterministic'", str);
55 }
56} // namespace
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61template <typename V> void ParallelLoopOptionsProperties::
62_applyPropertyVisitor(V& p)
63{
64 auto b = p.builder();
65 p << b.addInt32("ParallelLoopGrainSize")
66 .addDescription("GrainSize of the loop")
67 .addCommandLineArgument("ParallelLoopGrainSize")
68 .addGetter([](auto a) { return a.x.grainSize(); })
69 .addSetter([](auto a) { a.x.setGrainSize(a.v); });
70
71 p << b.addString("ParallelLoopPartitioner")
72 .addDescription("Partitioner for the loop (auto, static or deterministic)")
73 .addCommandLineArgument("ParallelLoopPartitioner")
74 .addGetter([](auto a) { return _partitionerToString(a.x.partitioner()); })
75 .addSetter([](auto a) { a.x.setPartitioner(_stringToPartitioner(a.v)); });
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81ARCANE_REGISTER_PROPERTY_CLASS(ParallelLoopOptionsProperties, ());
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86} // End namespace Arcane
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Partitioner
Type du partitionneur.
@ Auto
Laisse le partitionneur géré le partitionnement et l'ordonnancement (défaut)
@ Static
Utilise un partitionnement statique.
@ Deterministic
Utilise un partitionnement et un ordonnancement statique.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-