Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableSynchronizer.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* VariableSynchronizer.h (C) 2000-2024 */
9/* */
10/* Variable synchronization service. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_IMPL_INTERNAL_VARIABLESYNCHRONIZER_H
14#define ARCANE_IMPL_INTERNAL_VARIABLESYNCHRONIZER_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/utils/TraceAccessor.h"
19#include "arcane/utils/NotSupportedException.h"
20#include "arcane/utils/ITraceMng.h"
21#include "arcane/utils/Event.h"
22
24#include "arcane/core/ItemGroup.h"
25#include "arcane/core/IVariableSynchronizer.h"
26#include "arcane/core/IParallelMng.h"
27#include "arcane/core/DataTypeDispatchingDataVisitor.h"
28
29#include "arcane/accelerator/core/Runner.h"
30
31#include "arcane/impl/internal/IDataSynchronizeDispatcher.h"
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane
37{
38class Timer;
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
53class ARCANE_IMPL_EXPORT VariableSynchronizer
54: public TraceAccessor
56{
57 friend class VariableSynchronizerComputeList;
58 class SyncMessage;
59
60 public:
61
62 VariableSynchronizer(IParallelMng* pm, const ItemGroup& group,
63 Ref<IDataSynchronizeImplementationFactory> implementation_factory);
64 ~VariableSynchronizer() override;
65
66 public:
67
69 {
70 return m_parallel_mng;
71 }
72
73 const ItemGroup& itemGroup() override { return m_item_group; }
74
75 void compute() override;
76
77 void changeLocalIds(Int32ConstArrayView old_to_new_ids) override;
78
79 void synchronize(IVariable* var) override;
80
81 void synchronize(IVariable* var, Int32ConstArrayView local_ids) override;
82
83 void synchronize(VariableCollection vars) override;
84
85 void synchronize(VariableCollection vars, Int32ConstArrayView local_ids) override;
86
87 Int32ConstArrayView communicatingRanks() override;
88
89 Int32ConstArrayView sharedItems(Int32 index) override;
90
91 Int32ConstArrayView ghostItems(Int32 index) override;
92
93 void synchronizeData(IData* data) override;
94
96 {
97 return m_on_synchronized;
98 }
99
100 public:
101
102 IVariableSynchronizerMng* synchronizeMng() const { return m_variable_synchronizer_mng; }
103
104 private:
105
106 IParallelMng* m_parallel_mng = nullptr;
107 ItemGroup m_item_group;
108 Ref<DataSynchronizeInfo> m_sync_info;
109 Timer* m_sync_timer = nullptr;
110 bool m_is_verbose = false;
111 bool m_allow_multi_sync = true;
112 bool m_trace_sync = false;
113 EventObservable<const VariableSynchronizerEventArgs&> m_on_synchronized;
114 Ref<IDataSynchronizeImplementationFactory> m_implementation_factory;
115 IVariableSynchronizerMng* m_variable_synchronizer_mng = nullptr;
116 SyncMessage* m_default_message = nullptr;
117 Runner m_runner;
118 // For synchronizations on a subset of entities
119 Ref<DataSynchronizeInfo> m_partial_sync_info;
120 Ref<SyncMessage> m_partial_message;
121 UniqueArray<Int32> m_partial_local_ids;
122 bool m_is_check_coherence = false;
123
124 private:
125
126 void _synchronize(IVariable* var, SyncMessage* message);
127 void _synchronizeMulti(const VariableCollection& vars, SyncMessage* message);
128 bool _canSynchronizeMulti(const VariableCollection& vars);
129 DataSynchronizeResult _synchronize(INumericDataInternal* data, bool is_compare_sync);
130 SyncMessage* _buildMessage();
131 SyncMessage* _buildMessage(Ref<DataSynchronizeInfo>& sync_info);
132 void _rebuildMessage(Int32ConstArrayView local_ids);
133 void _sendBeginEvent(VariableSynchronizerEventArgs& args);
134 void _sendEndEvent(VariableSynchronizerEventArgs& args);
135 void _sendEvent(VariableSynchronizerEventArgs& args);
136 void _checkCreateTimer();
137 void _doSynchronize(SyncMessage* message);
138 void _setCurrentDevice();
139};
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144} // End namespace Arcane
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
148
149#endif
File containing declarations concerning the message passing model.
File containing event management mechanisms.
Information about the result of a synchronization.
Interface of a data item.
Definition IData.h:34
Interface for an 'IData' of a numeric type.
Interface of the parallelism manager for a subdomain.
Interface of the variable synchronization manager.
Interface of a variable synchronization service.
Interface of a variable.
Definition IVariable.h:40
Mesh entity group.
Definition ItemGroup.h:51
Reference to an instance.
Management of a timer.
Definition Timer.h:63
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
IParallelMng * parallelMng() override
Associated parallel manager.
EventObservable< const VariableSynchronizerEventArgs & > & onSynchronized() override
Event sent at the beginning and end of synchronization.
const ItemGroup & itemGroup() override
Entity group used for synchronization.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int32_t Int32
Signed integer type of 32 bits.