From deda603012415eec35ffe705990b161126e534bb Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Wed, 19 Feb 2025 21:17:13 +0100 Subject: [PATCH 1/2] [arcane,impl] Nettoyage de 'GetVariablevaluesParallelOperation'. --- .../GetVariablesValuesParallelOperation.cc | 262 ++++++++---------- .../GetVariablesValuesParallelOperation.h | 29 +- 2 files changed, 131 insertions(+), 160 deletions(-) diff --git a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc index 3fa4be5f4d..6dca0d4f63 100644 --- a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc +++ b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc @@ -11,7 +11,6 @@ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -#include "arcane/utils/Array.h" #include "arcane/utils/ITraceMng.h" #include "arcane/core/Timer.h" @@ -43,14 +42,6 @@ GetVariablesValuesParallelOperation(IParallelMng* pm) /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -GetVariablesValuesParallelOperation:: -~GetVariablesValuesParallelOperation() -{ -} - -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ - IParallelMng* GetVariablesValuesParallelOperation:: parallelMng() { @@ -62,97 +53,86 @@ parallelMng() void GetVariablesValuesParallelOperation:: getVariableValues(VariableItemReal& variable, - Int64ConstArrayView unique_ids, - Int32ConstArrayView sub_domain_ids, - RealArrayView values) + ConstArrayView unique_ids, + ConstArrayView sub_domain_ids, + ArrayView values) { IParallelMng* pm = m_parallel_mng; - Timer::Phase tphase(pm->timeStats(),TP_Communication); + Timer::Phase tphase(pm->timeStats(), TP_Communication); - if (!pm->isParallel()){ - _getVariableValuesSequential(variable,unique_ids,values); + if (!pm->isParallel()) { + _getVariableValuesSequential(variable, unique_ids, values); return; } - String func_id("MpiParallelMng::getVariableValues()"); - ItemGroup group = variable.itemGroup(); - ITraceMng* trace = pm->traceMng(); IItemFamily* item_family = variable.variable()->itemFamily(); if (group.null()) - trace->fatal() << "MpiParallelDispatchT::getVariableValues() " - << "the variable '" << variable.name() << "' is not defined " - << "on a group."; - Integer nb_item = unique_ids.size(); - if (nb_item!=values.size()) - trace->fatal() << "MpiParallelDispatchT::getVariableValues() " - << "the arrays 'unique_ids' and 'values' don't have the same " - << "number of elements (respectively " - << nb_item << " and " << values.size() << ")."; - if (nb_item!=sub_domain_ids.size()) - trace->fatal() << "MpiParallelDispatchT::getVariableValues() " - << "the arrays 'unique_ids' and 'sub_domains_ids' don't have the same " - << "number of elements (respectively " - << nb_item << " et " << sub_domain_ids.size() << ")."; - - typedef std::map SubDomainUniqueIdMap; + ARCANE_FATAL("The variable '{0}' is not defined on a group.", variable.name()); + + Int32 nb_item = unique_ids.size(); + if (nb_item != values.size()) + ARCANE_FATAL("The arrays 'unique_ids' and 'values' don't have the same " + "number of elements (respectively {0} and {1}).", + nb_item, values.size()); + + if (nb_item != sub_domain_ids.size()) + ARCANE_FATAL("The arrays 'unique_ids' and 'sub_domains_ids' don't have the same " + "number of elements (respectively {0} and {1}).", + nb_item, sub_domain_ids.size()); + + using SubDomainUniqueIdMap = std::map; SubDomainUniqueIdMap sub_domain_list; - - for( Integer i=0; icommRank(); - for( SubDomainUniqueIdMap::const_iterator b=sub_domain_list.begin(); - b!=sub_domain_list.end(); ++b ){ - Int32 sd = b->first; - Integer n = b->second.m_unique_ids.size(); + UniqueArray sub_domain_nb_to_send; + Int32 my_rank = pm->commRank(); + for (auto& [sd, helper] : sub_domain_list) { + Integer n = helper.m_unique_ids.size(); sub_domain_nb_to_send.add(my_rank); sub_domain_nb_to_send.add(sd); sub_domain_nb_to_send.add(n); } - + UniqueArray total_sub_domain_nb_to_send; - pm->allGatherVariable(sub_domain_nb_to_send,total_sub_domain_nb_to_send); + pm->allGatherVariable(sub_domain_nb_to_send, total_sub_domain_nb_to_send); UniqueArray messages; - for( Integer i=0, is=total_sub_domain_nb_to_send.size(); iinfo() << " SEND=" << rank_send //<< " RECV= " << rank_recv //<< " N= " << nb_exchange; - if (rank_send==rank_recv) + if (rank_send == rank_recv) continue; - SerializeMessage* sm = 0; - if (rank_recv==my_rank){ + SerializeMessage* sm = nullptr; + if (rank_recv == my_rank) { //trace->info() << " ADD RECV MESSAGE recv=" << rank_recv << " send=" << rank_send; - sm = new SerializeMessage(rank_recv,rank_send,ISerializeMessage::MT_Recv); + sm = new SerializeMessage(rank_recv, rank_send, ISerializeMessage::MT_Recv); } - else if (rank_send==my_rank){ + else if (rank_send == my_rank) { //trace->info() << " ADD SEND MESSAGE recv=" << rank_recv << " send=" << rank_send; - sm = new SerializeMessage(rank_send,rank_recv,ISerializeMessage::MT_Send); + sm = new SerializeMessage(rank_send, rank_recv, ISerializeMessage::MT_Send); ISerializer* s = sm->serializer(); s->setMode(ISerializer::ModeReserve); auto xiter = sub_domain_list.find(rank_recv); - if (xiter==sub_domain_list.end()) - ARCANE_FATAL("Can not find rank '{0}'",rank_recv); + if (xiter == sub_domain_list.end()) + ARCANE_FATAL("Can not find rank '{0}'", rank_recv); Span z_unique_ids = xiter->second.m_unique_ids; Int64 nb = z_unique_ids.size(); s->reserveInt64(1); // Pour la taille - s->reserveSpan(eBasicDataType::Int64,nb); // Pour le tableau + s->reserveSpan(eBasicDataType::Int64, nb); // Pour le tableau s->allocateBuffer(); s->setMode(ISerializer::ModePut); s->putInt64(nb); @@ -164,21 +144,20 @@ getVariableValues(VariableItemReal& variable, pm->processMessages(messages); - Int64UniqueArray tmp_unique_ids; - Int32UniqueArray tmp_local_ids; - RealUniqueArray tmp_values; + UniqueArray tmp_unique_ids; + UniqueArray tmp_local_ids; + UniqueArray tmp_values; UniqueArray values_messages; ItemInfoListView items_internal(item_family); - for( Integer i=0, is=messages.size(); iisSend()){ + for (ISerializeMessage* sm : messages) { + ISerializeMessage* new_sm = nullptr; + if (sm->isSend()) { // Pour recevoir les valeurs //trace->info() << " ADD RECV2 MESSAGE recv=" << my_rank << " send=" << sm->destSubDomain(); - new_sm = new SerializeMessage(my_rank,sm->destination().value(),ISerializeMessage::MT_Recv); + new_sm = new SerializeMessage(my_rank, sm->destination().value(), ISerializeMessage::MT_Recv); } - else{ + else { ISerializer* s = sm->serializer(); s->setMode(ISerializer::ModeGet); Int64 nb = s->getInt64(); @@ -186,18 +165,18 @@ getVariableValues(VariableItemReal& variable, tmp_local_ids.resize(nb); tmp_values.resize(nb); s->getSpan(tmp_unique_ids); - item_family->itemsUniqueIdToLocalId(tmp_local_ids,tmp_unique_ids); - for( Integer z=0; zitemsUniqueIdToLocalId(tmp_local_ids, tmp_unique_ids); + for (Integer z = 0; z < nb; ++z) { Item item = items_internal[tmp_local_ids[z]]; tmp_values[z] = variable[item]; } //trace->info() << " ADD SEND2 MESSAGE recv=" << my_rank << " send=" << sm->destSubDomain(); - new_sm = new SerializeMessage(my_rank,sm->destination().value(),ISerializeMessage::MT_Send); + new_sm = new SerializeMessage(my_rank, sm->destination().value(), ISerializeMessage::MT_Send); ISerializer* s2 = new_sm->serializer(); s2->setMode(ISerializer::ModeReserve); s2->reserveInt64(1); - s2->reserveSpan(eBasicDataType::Real,nb); + s2->reserveSpan(eBasicDataType::Real, nb); s2->allocateBuffer(); s2->setMode(ISerializer::ModePut); s2->putInt64(nb); @@ -211,12 +190,10 @@ getVariableValues(VariableItemReal& variable, pm->processMessages(values_messages); - for( Integer i=0, is=values_messages.size(); iisSend()){ + for (ISerializeMessage* sm : values_messages) { + if (sm->isSend()) { } - else{ + else { ISerializer* s = sm->serializer(); s->setMode(ISerializer::ModeGet); Int64 nb = s->getInt64(); @@ -225,7 +202,7 @@ getVariableValues(VariableItemReal& variable, s->getSpan(tmp_values); //trace->info() << " GET VALUES from=" << sm->destSubDomain() << " n=" << nb; Span indexes = sub_domain_list[sender].m_indexes; - for( Int64 z=0; z indexes(h.m_indexes.constSpan()); Int64 nb = h.m_unique_ids.largeSize(); tmp_local_ids.resize(nb); - item_family->itemsUniqueIdToLocalId(tmp_local_ids,h.m_unique_ids); - for( Int64 z=0; zitemsUniqueIdToLocalId(tmp_local_ids, h.m_unique_ids); + for (Int64 z = 0; z < nb; ++z) { Item item = items_internal[tmp_local_ids[z]]; values[indexes[z]] = variable[item]; } @@ -271,60 +248,57 @@ getVariableValues(VariableItemReal& variable, /*---------------------------------------------------------------------------*/ void GetVariablesValuesParallelOperation:: -getVariableValues(VariableItemReal& variable, - Int64ConstArrayView unique_ids, +getVariableValues(VariableItemReal& variable, Int64ConstArrayView unique_ids, RealArrayView values) { IParallelMng* pm = m_parallel_mng; - Timer::Phase tphase(pm->timeStats(),TP_Communication); + Timer::Phase tphase(pm->timeStats(), TP_Communication); - if (!pm->isParallel()){ - _getVariableValuesSequential(variable,unique_ids,values); + if (!pm->isParallel()) { + _getVariableValuesSequential(variable, unique_ids, values); return; } ItemGroup group = variable.itemGroup(); ITraceMng* trace = pm->traceMng(); if (group.null()) - trace->fatal() << "MpiParallelDispatchT::getVariableValues() " - << "the variable '" << variable.name() << "' is not defined " - << "on a group."; - Integer size = unique_ids.size(); - if (size!=values.size()) - trace->fatal() << "MpiParallelDispatchT::getVariableValues() " - << "the arrays 'unique_ids' and 'values' don't have the same " - << "number of elements (respectivemely " - << size << " and " << values.size() << ")."; - - Integer nb_proc = pm->commSize(); + ARCANE_FATAL("The variable '{0}' is not defined on a group.", variable.name()); + + Int32 size = unique_ids.size(); + if (size != values.size()) + ARCANE_FATAL("The arrays 'unique_ids' and 'values' don't have the same " + "number of elements (respectively {0} and {1}).", + size, values.size()); + + Int32 nb_proc = pm->commSize(); Integer nb_phase = 0; - while(nb_proc!=0 && nb_phase<32){ + while (nb_proc != 0 && nb_phase < 32) { nb_proc /= 2; ++nb_phase; } - if (nb_phase<3) + if (nb_phase < 3) nb_phase = 1; trace->info() << " NB PHASE=" << nb_phase; nb_phase = 1; - if (nb_phase==1){ - _getVariableValues(variable,unique_ids,values); + if (nb_phase == 1) { + _getVariableValues(variable, unique_ids, values); } - else{ + else { Integer nb_done = 0; - for( Integer i=0; idebug() << "GetVariableValue: first=" << first << " last=" << last << " n=" << n << " size=" << size; - RealArrayView local_values(n,values.data()+first); - Int64ConstArrayView local_unique_ids(n,unique_ids.data()+first); - _getVariableValues(variable,local_unique_ids,local_values); + RealArrayView local_values(n, values.data() + first); + Int64ConstArrayView local_unique_ids(n, unique_ids.data() + first); + _getVariableValues(variable, local_unique_ids, local_values); } - if (nb_done!=size){ + if (nb_done != size) { trace->fatal() << "MpiParallelMng::getVariableValue() Internal error in size: " << " size=" << size << " done=" << nb_done; } @@ -337,15 +311,15 @@ getVariableValues(VariableItemReal& variable, void GetVariablesValuesParallelOperation:: _deleteMessages(Array& messages) { - for( Integer i=0, is=messages.size(); i void GetVariablesValuesParallelOperation:: +template void GetVariablesValuesParallelOperation:: _getVariableValues(ItemVariableScalarRefT& variable, Int64ConstArrayView unique_ids, ArrayView values) @@ -355,11 +329,11 @@ _getVariableValues(ItemVariableScalarRefT& variable, ITraceMng* msg = pm->traceMng(); IItemFamily* item_family = group.itemFamily(); - // Pour eviter un bug MPI sur certaines machines, - // si la liste est vide, creer une liste temporaire + // Pour éviter un bug MPI sur certaines machines, + // si la liste est vide, on créé une liste temporaire UniqueArray dummy_unique_ids; UniqueArray dummy_values; - if (unique_ids.empty()){ + if (unique_ids.empty()) { dummy_unique_ids.resize(1); dummy_values.resize(1); dummy_unique_ids[0] = NULL_ITEM_ID; @@ -368,79 +342,74 @@ _getVariableValues(ItemVariableScalarRefT& variable, } // Principe de fonctionnement. - // Chaque sous-domaine recupère la totalité des unique_ids dont on veut + // Chaque sous-domaine récupère la totalité des unique_ids dont on veut // les valeurs (allGatherVariable). - // On alloue ensuite un tableau dimensionné à ce nombre de unique_id qui + // On alloue ensuite un tableau dimensionné à ce nombre de uniqueId() qui // contiendra les valeurs des entités (tableau all_value). - // Chaque sous-domaine remplit ce tableau comme suit: - // - si l'entité lui appartient, remplit avec la valeur de la variable - // - sinon, remplit avec la valeur minimale possible suivant \a Type. + // Chaque sous-domaine remplit ce tableau comme suit : + // * si l'entité lui appartient, remplit avec la valeur de la variable + // * sinon, remplit avec la valeur minimale possible suivant \a Type. // Le processeur 0 effectue ensuite une réduction Max de ce tableau, // qui contiendra alors la bonne valeur pour chacun de ses éléments. - // Il ne reste plus alors qu'a faire un 'scatter' symétrique du + // Il ne reste plus alors qu'à faire un 'scatter' symétrique du // premier 'gather'. Int64UniqueArray all_unique_ids; - pm->allGatherVariable(unique_ids,all_unique_ids); + pm->allGatherVariable(unique_ids, all_unique_ids); Integer all_size = all_unique_ids.size(); Int32UniqueArray all_local_ids(all_size); - item_family->itemsUniqueIdToLocalId(all_local_ids,all_unique_ids,false); + item_family->itemsUniqueIdToLocalId(all_local_ids, all_unique_ids, false); ConstArrayView variable_a(variable.asArray()); UniqueArray all_values(all_size); msg->debug() << "MpiParallelMng::_getVariableValues(): size=" << all_size - << " values_size=" << sizeof(Type)*all_size; + << " values_size=" << sizeof(Type) * all_size; // Remplit le tableau des valeurs avec la valeur maximale possible // pour le type. Il suffit ensuite de faire un ReduceMin Type max_value = std::numeric_limits::max(); ItemInfoListView internal_items(item_family); - for( Integer i=0; i* mpd = dynamic_cast*>(m_double); - pm->reduce(Parallel::ReduceMin,all_values); + pm->reduce(Parallel::ReduceMin, all_values); // Scinde le tableau sur les autres processeurs - pm->scatterVariable(all_values,values,0); + pm->scatterVariable(all_values, values, 0); } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -template void GetVariablesValuesParallelOperation:: +template void GetVariablesValuesParallelOperation:: _getVariableValuesSequential(ItemVariableScalarRefT& variable, Int64ConstArrayView unique_ids, ArrayView values) { - ITraceMng* trace = m_parallel_mng->traceMng(); ItemGroup group = variable.itemGroup(); if (group.null()) - trace->fatal() << "SequentialParallelDispatchT::getVariableValues() " - << "the variable '" << variable.name() << "' is not defined " - << "on a group."; - //eItemKind ik = group.itemKind(); + ARCANE_FATAL("The variable '{0}' is not defined on a group.", variable.name()); + IItemFamily* family = group.itemFamily(); - Integer size = unique_ids.size(); - if (size!=values.size()) - trace->fatal() << "SequentialParallelDispatchT::getVariableValues() " - << "the arrays 'unique_ids' and 'values' don't have the same " - << "number of elements (respectively " - << size << " and " << values.size() << ")."; + Int32 size = unique_ids.size(); + if (size != values.size()) + ARCANE_FATAL("The arrays 'unique_ids' and 'values' don't have the same " + "number of elements (respectively {0} and {1}).", + size, values.size()); //TODO: faire par morceaux. - Int32UniqueArray local_ids(size); - family->itemsUniqueIdToLocalId(local_ids,unique_ids); + UniqueArray local_ids(size); + family->itemsUniqueIdToLocalId(local_ids, unique_ids); ConstArrayView variable_a(variable.asArray()); - for( Integer i=0; i& variable, /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ - diff --git a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h index 2e0eeea7a7..5507cb85b9 100644 --- a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h +++ b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h @@ -1,11 +1,11 @@ // -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- //----------------------------------------------------------------------------- -// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) +// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- /*---------------------------------------------------------------------------*/ -/* GetVariablesValuesParallelOperation.h (C) 2000-2021 */ +/* GetVariablesValuesParallelOperation.h (C) 2000-2025 */ /* */ /* Opérations pour accéder aux valeurs de variables d'un autre sous-domaine. */ /*---------------------------------------------------------------------------*/ @@ -14,7 +14,7 @@ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -#include "arcane/IGetVariablesValuesParallelOperation.h" +#include "arcane/core/IGetVariablesValuesParallelOperation.h" #include "arcane/utils/Array.h" @@ -33,30 +33,33 @@ class ARCANE_IMPL_EXPORT GetVariablesValuesParallelOperation : public IGetVariablesValuesParallelOperation { private: + class Helper { public: SharedArray m_unique_ids; SharedArray m_indexes; }; + public: - GetVariablesValuesParallelOperation(IParallelMng* pm); - virtual ~GetVariablesValuesParallelOperation(); + + explicit GetVariablesValuesParallelOperation(IParallelMng* pm); public: - virtual IParallelMng* parallelMng(); + IParallelMng* parallelMng() override; public: - virtual void getVariableValues(VariableItemReal& variable, - Int64ConstArrayView unique_ids, - RealArrayView values); + void getVariableValues(VariableItemReal& variable, + Int64ConstArrayView unique_ids, + RealArrayView values) override; + + void getVariableValues(VariableItemReal& variable, + Int64ConstArrayView unique_ids, + Int32ConstArrayView sub_domain_ids, + RealArrayView values) override; - virtual void getVariableValues(VariableItemReal& variable, - Int64ConstArrayView unique_ids, - Int32ConstArrayView sub_domain_ids, - RealArrayView values); private: IParallelMng* m_parallel_mng; From 4ae0e093cf699e2712386ff14b61395c23cbc36e Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Wed, 19 Feb 2025 21:17:44 +0100 Subject: [PATCH 2/2] [arcane,impl] Supprime utilisation de 'SerializeMessage' dans 'GetVariablesValuesParallelOperation'. --- .../GetVariablesValuesParallelOperation.cc | 50 ++++++++----------- .../GetVariablesValuesParallelOperation.h | 4 +- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc index 6dca0d4f63..3aead5d662 100644 --- a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc +++ b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc @@ -18,10 +18,12 @@ #include "arcane/core/IParallelMng.h" #include "arcane/core/ISerializer.h" #include "arcane/core/IItemFamily.h" -#include "arcane/core/internal/SerializeMessage.h" +#include "arcane/core/ISerializeMessage.h" #include "arcane/impl/GetVariablesValuesParallelOperation.h" +#include "arccore/message_passing/ISerializeMessageList.h" + #include /*---------------------------------------------------------------------------*/ @@ -29,6 +31,7 @@ namespace Arcane { +using namespace MessagePassing; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -106,7 +109,8 @@ getVariableValues(VariableItemReal& variable, UniqueArray total_sub_domain_nb_to_send; pm->allGatherVariable(sub_domain_nb_to_send, total_sub_domain_nb_to_send); - UniqueArray messages; + UniqueArray> messages; + Ref message_list(pm->createSerializeMessageListRef()); for (Integer i = 0, is = total_sub_domain_nb_to_send.size(); i < is; i += 3) { Int32 rank_send = total_sub_domain_nb_to_send[i]; Int32 rank_recv = total_sub_domain_nb_to_send[i + 1]; @@ -116,14 +120,14 @@ getVariableValues(VariableItemReal& variable, //<< " N= " << nb_exchange; if (rank_send == rank_recv) continue; - SerializeMessage* sm = nullptr; + Ref sm; if (rank_recv == my_rank) { //trace->info() << " ADD RECV MESSAGE recv=" << rank_recv << " send=" << rank_send; - sm = new SerializeMessage(rank_recv, rank_send, ISerializeMessage::MT_Recv); + sm = message_list->createAndAddMessage(MessageRank(rank_send), ePointToPointMessageType::MsgReceive); } else if (rank_send == my_rank) { //trace->info() << " ADD SEND MESSAGE recv=" << rank_recv << " send=" << rank_send; - sm = new SerializeMessage(rank_send, rank_recv, ISerializeMessage::MT_Send); + sm = message_list->createAndAddMessage(MessageRank(rank_recv), ePointToPointMessageType::MsgSend); ISerializer* s = sm->serializer(); s->setMode(ISerializer::ModeReserve); auto xiter = sub_domain_list.find(rank_recv); @@ -138,24 +142,24 @@ getVariableValues(VariableItemReal& variable, s->putInt64(nb); s->putSpan(z_unique_ids); } - if (sm) + if (sm.get()) messages.add(sm); } - pm->processMessages(messages); + message_list->waitMessages(eWaitType::WaitAll); UniqueArray tmp_unique_ids; UniqueArray tmp_local_ids; UniqueArray tmp_values; - UniqueArray values_messages; + UniqueArray> values_messages; ItemInfoListView items_internal(item_family); - for (ISerializeMessage* sm : messages) { - ISerializeMessage* new_sm = nullptr; + for (Ref sm : messages) { + Ref new_sm; if (sm->isSend()) { // Pour recevoir les valeurs //trace->info() << " ADD RECV2 MESSAGE recv=" << my_rank << " send=" << sm->destSubDomain(); - new_sm = new SerializeMessage(my_rank, sm->destination().value(), ISerializeMessage::MT_Recv); + new_sm = message_list->createAndAddMessage(MessageRank(sm->destination().value()), ePointToPointMessageType::MsgReceive); } else { ISerializer* s = sm->serializer(); @@ -172,7 +176,7 @@ getVariableValues(VariableItemReal& variable, } //trace->info() << " ADD SEND2 MESSAGE recv=" << my_rank << " send=" << sm->destSubDomain(); - new_sm = new SerializeMessage(my_rank, sm->destination().value(), ISerializeMessage::MT_Send); + new_sm = message_list->createAndAddMessage(MessageRank(sm->destination().value()), ePointToPointMessageType::MsgSend); ISerializer* s2 = new_sm->serializer(); s2->setMode(ISerializer::ModeReserve); s2->reserveInt64(1); @@ -186,11 +190,11 @@ getVariableValues(VariableItemReal& variable, } // Supprime les messages qui ne sont plus utilisés - _deleteMessages(messages); + messages.clear(); - pm->processMessages(values_messages); + message_list->waitMessages(eWaitType::WaitAll); - for (ISerializeMessage* sm : values_messages) { + for (Ref sm : values_messages) { if (sm->isSend()) { } else { @@ -222,7 +226,8 @@ getVariableValues(VariableItemReal& variable, } // Supprime les messages qui ne sont plus utilisés - _deleteMessages(values_messages); + values_messages.clear(); + //_deleteMessages(values_messages); #if 0 { @@ -308,17 +313,6 @@ getVariableValues(VariableItemReal& variable, Int64ConstArrayView unique_ids, /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -void GetVariablesValuesParallelOperation:: -_deleteMessages(Array& messages) -{ - for (ISerializeMessage* sm : messages) - delete sm; - messages.clear(); -} - -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ - template void GetVariablesValuesParallelOperation:: _getVariableValues(ItemVariableScalarRefT& variable, Int64ConstArrayView unique_ids, @@ -330,7 +324,7 @@ _getVariableValues(ItemVariableScalarRefT& variable, IItemFamily* item_family = group.itemFamily(); // Pour éviter un bug MPI sur certaines machines, - // si la liste est vide, on créé une liste temporaire + // si la liste est vide, on crée une liste temporaire UniqueArray dummy_unique_ids; UniqueArray dummy_values; if (unique_ids.empty()) { diff --git a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h index 5507cb85b9..752c949a88 100644 --- a/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h +++ b/arcane/src/arcane/impl/GetVariablesValuesParallelOperation.h @@ -62,12 +62,10 @@ class ARCANE_IMPL_EXPORT GetVariablesValuesParallelOperation private: - IParallelMng* m_parallel_mng; + IParallelMng* m_parallel_mng = nullptr; private: - void _deleteMessages(Array& messages); - template void _getVariableValues(ItemVariableScalarRefT& variable, Int64ConstArrayView unique_ids,