Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
SequentialSection.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/* SequentialSection.cc (C) 2000-2015 */
9/* */
10/* Section du code à exécuter séquentiellement. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/ParallelFatalErrorException.h"
18
19#include "arcane/IParallelMng.h"
20#include "arcane/ISubDomain.h"
21#include "arcane/SequentialSection.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26ARCANE_BEGIN_NAMESPACE
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31SequentialSection::
32SequentialSection(IParallelMng* pm)
33: m_parallel_mng(pm)
34, m_has_error(false)
35{
36 _init();
37}
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42SequentialSection::
43SequentialSection(ISubDomain* sd)
44: m_parallel_mng(sd->parallelMng())
45, m_has_error(false)
46{
47 _init();
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
53SequentialSection::
54~SequentialSection() ARCANE_NOEXCEPT_FALSE
55{
56 Integer sid = m_parallel_mng->commRank();
57 if (sid==0){
58 Integer error_value = m_has_error ? 1 : 0;
59 //cerr << "** ERROR SEND " << error_value << "!\n";
60 ArrayView<Integer> iv(1,&error_value);
61 m_parallel_mng->broadcast(iv,0);
62 if (m_has_error)
63 _sendError();
64 }
65 else{
66 return;
67 }
68}
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73void SequentialSection::
74_init()
75{
76 Integer sid = m_parallel_mng->commRank();
77 if (sid==0){
78 return;
79 }
80 else{
81 Integer error_value = 0;
82 ArrayView<Integer> iv(1,&error_value);
83 m_parallel_mng->broadcast(iv,0);
84 //cerr << "** ERROR RECV " << sid << ' ' << error_value << "!\n";
85 if (error_value!=0)
86 _sendError();
87 }
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93void SequentialSection::
94_sendError()
95{
96 Integer sid = m_parallel_mng->commRank();
97 ITraceMng* trace = m_parallel_mng->traceMng();
98 if (trace)
99 trace->logdate() << "Subdomain " << sid << "Fatal in sequantial section";
100 m_parallel_mng->barrier();
101 throw ParallelFatalErrorException("sequential section");
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107void SequentialSection::
108setError(bool is_error)
109{
110 m_has_error = is_error;
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116ARCANE_END_NAMESPACE
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
Int32 Integer
Type représentant un entier.