Arcane  v3.14.10.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-2022 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-2022 */
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
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace
29{
30 const char*
31 _partitionerToString(ParallelLoopOptions::Partitioner p)
32 {
33 switch (p) {
35 return "static";
37 return "deterministic";
39 return "auto";
40 }
41 ARCANE_FATAL("Bad value {0} for partitioner", (int)p);
42 }
43
45 _stringToPartitioner(const String& str)
46 {
47 if (str == "static")
49 if (str == "deterministic")
51 if (str == "auto")
53 ARCANE_FATAL("Bad value '{0}' for partitioner. Valid values are 'auto', 'static' or 'deterministic'", str);
54 }
55} // namespace
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60template <typename V> void ParallelLoopOptions::
61_applyPropertyVisitor(V& p)
62{
63 auto b = p.builder();
64 p << b.addInt32("ParallelLoopGrainSize")
65 .addDescription("GrainSize of the loop")
66 .addCommandLineArgument("ParallelLoopGrainSize")
67 .addGetter([](auto a) { return a.x.grainSize(); })
68 .addSetter([](auto a) { a.x.setGrainSize(a.v); });
69
70 p << b.addString("ParallelLoopPartitioner")
71 .addDescription("Partitioner for the loop (auto, static or deterministic)")
72 .addCommandLineArgument("ParallelLoopPartitioner")
73 .addGetter([](auto a) { return _partitionerToString(a.x.partitioner()); })
74 .addSetter([](auto a) { a.x.setPartitioner(_stringToPartitioner(a.v)); });
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80ARCANE_REGISTER_PROPERTY_CLASS(ParallelLoopOptions, ());
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85} // End namespace Arcane
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
#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 -*-