14#include "arcane/parallel/VariableParallelOperationBase.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/ScopedPtr.h"
19#include "arcane/core/IParallelMng.h"
20#include "arcane/core/ISerializer.h"
21#include "arcane/core/ISerializeMessage.h"
22#include "arcane/core/IParallelExchanger.h"
23#include "arcane/core/ISubDomain.h"
24#include "arcane/core/IVariable.h"
25#include "arcane/core/IItemFamily.h"
26#include "arcane/core/ItemInternal.h"
27#include "arcane/core/ItemGroup.h"
28#include "arcane/core/ParallelMngUtils.h"
38 const Int64 SERIALIZE_MAGIC_NUMBER = 0x4cf92789;
44VariableParallelOperationBase::
48, m_item_family(nullptr)
55void VariableParallelOperationBase::
60 m_item_family = family;
75void VariableParallelOperationBase::
81 ARCANE_FATAL(
"variable->itemFamily() and itemFamily() differ");
82 m_variables.add(variable);
88void VariableParallelOperationBase::
91 if (m_variables.empty())
95 const bool is_debug_print =
true;
97 const bool is_debug_print =
false;
110 for (
Integer i = 0; i < nb_rank; ++i)
112 exchanger->addSender(i);
114 bool no_exchange = exchanger->initializeCommunicationsMessages();
120 for (
Integer i = 0, is = exchanger->nbSender(); i < is; ++i) {
126 debug() <<
"Number of items to serialize: " << nb_item <<
" subdomain=" << dest_sub_domain;
130 for (
Integer z = 0; z < nb_item; ++z) {
131 Item item = item_list[dest_items_internal[z]];
132 dest_items_local_id[z] = item.
localId();
133 dest_items_unique_id[z] = item.
uniqueId().asInt64();
138 sbuf->
setMode(ISerializer::ModeReserve);
148 for (VariableList::Enumerator i_var(m_variables); ++i_var;) {
151 var->
serialize(sbuf, dest_items_local_id);
160 sbuf->
putInt64(SERIALIZE_MAGIC_NUMBER);
164 sbuf->
putSpan(dest_items_unique_id);
165 for (VariableList::Enumerator i_var(m_variables); ++i_var;) {
168 var->
serialize(sbuf, dest_items_local_id);
172 exchanger->processExchange();
175 debug() <<
"VariableParallelOperationBase::readVariables()";
181 for (
Integer i = 0, n = exchanger->nbReceiver(); i < n; ++i) {
189 if (magic_number != SERIALIZE_MAGIC_NUMBER)
190 ARCANE_FATAL(
"Bad magic number actual={0} expected={1}. This is probably due to incoherent messaging",
191 magic_number, SERIALIZE_MAGIC_NUMBER);
195 items_unique_id.
resize(nb_item);
196 sbuf->
getSpan(items_unique_id);
197 items_local_id.
resize(nb_item);
200 if (is_debug_print) {
201 for (
Integer iz = 0; iz < nb_item; ++iz)
205 itemFamily()->itemsUniqueIdToLocalId(items_local_id, items_unique_id);
207 for (VariableList::Enumerator ivar(m_variables); ++ivar;) {
209 var->
serialize(sbuf, items_local_id, operation);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
void resize(Int64 s)
Changes the number of elements in the array to s.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of an operation on a data.
Interface of an entity family.
Interface of the parallelism manager for a subdomain.
virtual Int32 commSize() const =0
Number of instances in the communicator.
void reserveInt64(Int64 n)
Reserve for n Int64.
@ ModePut
The serializer expects reserve().
virtual Int64 getInt64()=0
Retrieve a size.
virtual void allocateBuffer()=0
Allocates the serializer memory.
virtual void putSpan(Span< const Real > values)
Add the array values.
virtual void getSpan(Span< Real > values)
Retrieve the array values.
virtual void reserveSpan(eBasicDataType dt, Int64 n)=0
Reserves memory for n values of dt.
virtual void setMode(eMode new_mode)=0
Sets the current mode.
virtual void putInt64(Int64 value)=0
Add the integer value.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
virtual void serialize(ISerializer *sbuffer, IDataOperation *operation=0)=0
virtual String name() const =0
Variable name.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
View of a list to obtain information about entities.
Base class for a mesh element.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Interface for a serialization message between IMessagePassingMng.
virtual MessageRank destination() const =0
Destination rank (if isSend() is true) or sender.
virtual ISerializer * serializer()=0
Serializer.
Int32 value() const
Rank value.
IItemFamily * itemFamily() override
Entity family on which the operation is performed.
UniqueArray< SharedArray< ItemLocalId > > m_items_to_send
List of entities to send to each processor.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
1D data vector with value semantics (STL style).
Ref< IParallelExchanger > createExchangerRef(IParallelMng *pm)
Returns an interface to transfer messages between ranks.
Concurrency implementation.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.