Skip to content

Commit

Permalink
Merge pull request #1872 from arcaneframework/dev/gg-remove-deprecate…
Browse files Browse the repository at this point in the history
…d-usage-of-iserializer-methods

Remove usage of deprecated methods of 'ISerializer'
  • Loading branch information
grospelliergilles authored Dec 25, 2024
2 parents 3efaa54 + 6f9e843 commit fc129a4
Show file tree
Hide file tree
Showing 29 changed files with 204 additions and 207 deletions.
30 changes: 15 additions & 15 deletions arcane/src/arcane/core/Properties.cc
Original file line number Diff line number Diff line change
@@ -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-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* Properties.cc (C) 2000-2020 */
/* Properties.cc (C) 2000-2024 */
/* */
/* Liste de propriétés. */
/*---------------------------------------------------------------------------*/
Expand All @@ -20,11 +20,11 @@
#include "arcane/utils/ArgumentException.h"
#include "arcane/utils/FatalErrorException.h"

#include "arcane/datatype/SmallVariant.h"
#include "arcane/datatype/DataTypeTraits.h"
#include "arcane/core/datatype/SmallVariant.h"
#include "arcane/core/datatype/DataTypeTraits.h"

#include "arcane/IPropertyMng.h"
#include "arcane/ISerializer.h"
#include "arcane/core/IPropertyMng.h"
#include "arcane/core/ISerializer.h"

#include <map>

Expand Down Expand Up @@ -210,7 +210,7 @@ void _directPutScalar(ISerializer* s,const bool& value)
template<typename DataType>
void _directReserveScalar(ISerializer* s,const DataType&)
{
s->reserve(DataTypeTraitsT<DataType>::type(),1);
s->reserve(DataTypeTraitsT<DataType>::basicDataType(),1);
}

void _directReserveScalar(ISerializer* s,const String& value)
Expand All @@ -221,21 +221,21 @@ void _directReserveScalar(ISerializer* s,const String& value)
template<typename DataType>
void _directReserve(ISerializer* s,Span<const DataType> values)
{
s->reserve(DT_Int64,1);
s->reserveSpan(DataTypeTraitsT<DataType>::type(),values.size());
s->reserveInt64(1);
s->reserveSpan(DataTypeTraitsT<DataType>::basicDataType(),values.size());
}


void _directReserve(ISerializer* s,Span<const bool> values)
{
Int64 n = values.size();
s->reserve(DT_Int64,1);
s->reserveSpan(DT_Byte,n);
s->reserveInt64(1);
s->reserveSpan(eBasicDataType::Byte,n);
}

void _directReserve(ISerializer* s,Span<const String> values)
{
s->reserve(DT_Int64,1);
s->reserveInt64(1);
Int64 n = values.size();
for( Integer i=0; i<n; ++i )
s->reserve(values[i]);
Expand Down Expand Up @@ -621,15 +621,15 @@ serialize(ISerializer* serializer)
void PropertiesImpl::
serializeReserve(ISerializer* serializer)
{
serializer->reserve(DT_Int32,1); // SERIALIZE_VERSION
serializer->reserve(DT_Int64,1); // Nombre d'éléments dans la map
serializer->reserveInt32(1); // SERIALIZE_VERSION
serializer->reserveInt64(1); // Nombre d'éléments dans la map

MapType::iterator v = m_property_map.begin();
MapType::iterator vend = m_property_map.end();
for( ; v!=vend; ++v ){
PropertyVariant* p = v->second;
PropertyVariant::eType et = p->type();
serializer->reserve(DT_Int32,1);
serializer->reserveInt32(1);
serializer->reserve(v->first);
IPropertyType* pt = m_types[et];
pt->serializeReserve(serializer,p);
Expand Down
24 changes: 12 additions & 12 deletions arcane/src/arcane/core/SerializedData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,24 @@ _serialize(ISerializer* sbuf) const

switch (mode) {
case ISerializer::ModeReserve:
sbuf->reserve(DT_Int64, 1); // Valeur magique pour vérification
sbuf->reserve(DT_Int32, 1); // Numéro de version
sbuf->reserveInt64(1); // Valeur magique pour vérification
sbuf->reserveInt32(1); // Numéro de version
sbuf->reserveInteger(1); // Pour le m_base_data_type
sbuf->reserve(DT_Int64, 1); // Pour le m_memory_size
sbuf->reserveInt64(1); // Pour le m_memory_size
sbuf->reserveInteger(1); // Pour le m_nb_dimension
sbuf->reserve(DT_Int64, 1); // Pour le m_nb_element
sbuf->reserve(DT_Int64, 1); // Pour le m_nb_base_element
sbuf->reserveInt64(1); // Pour le m_nb_element
sbuf->reserveInt64(1); // Pour le m_nb_base_element
sbuf->reserveInteger(1); // Pour le m_is_multi_size
sbuf->reserve(DT_Int64, 1); // Pour le m_element_size
sbuf->reserveInt64(1); // Pour le m_element_size

sbuf->reserve(DT_Int64, 1); // Pour le m_extents.size()
sbuf->reserveSpan(DT_Int64, m_extents.size()); // Pour les dimensions
sbuf->reserveInt64(1); // Pour le m_extents.size()
sbuf->reserveSpan(eBasicDataType::Int64, m_extents.size()); // Pour les dimensions

sbuf->reserve(DT_Int32, 1); // Pour le nombre de valeur de 'm_shape'
sbuf->reserveSpan(DT_Int32, m_shape.nbDimension()); // Pour les données de 'm_shape'
sbuf->reserveInt32(1); // Pour le nombre de valeur de 'm_shape'
sbuf->reserveSpan(eBasicDataType::Int32, m_shape.nbDimension()); // Pour les données de 'm_shape'

sbuf->reserve(DT_Int64, 1); // Pour le m_const_buffer.size()
sbuf->reserveSpan(DT_Byte, m_const_buffer.size()); // Pour les données
sbuf->reserveInt64(1); // Pour le m_const_buffer.size()
sbuf->reserveSpan(eBasicDataType::Byte, m_const_buffer.size()); // Pour les données
break;
case ISerializer::ModePut:
sbuf->putInt64(SERIALIZE_MAGIC_NUMBER); // Valeur magique pour vérification
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/core/Variable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class VariablePrivate
{
switch(sbuf->mode()){
case ISerializer::ModeReserve:
sbuf->reserveSpan(DT_Byte,HASHID_SIZE);
sbuf->reserveSpan(eBasicDataType::Byte,HASHID_SIZE);
break;
case ISerializer::ModePut:
sbuf->putSpan(Span<const Byte>(m_hash_id,HASHID_SIZE));
Expand Down
3 changes: 3 additions & 0 deletions arcane/src/arcane/core/datatype/DataTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class DataTypeTraitsT<bool>
*/
static constexpr eDataType type() { return DT_Byte; }

//! Type de donnée de base.
static constexpr eBasicDataType basicDataType() { return eBasicDataType::Byte; }

//! Type du proxy associé
typedef BuiltInProxy<bool> ProxyType;

Expand Down
28 changes: 14 additions & 14 deletions arcane/src/arcane/core/parallel/VariableParallelOperationBase.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* VariableParallelOperationBase.cc (C) 2000-2023 */
/* VariableParallelOperationBase.cc (C) 2000-2024 */
/* */
/* Classe de base des opérations parallèles sur des variables. */
/*---------------------------------------------------------------------------*/
Expand All @@ -16,16 +16,16 @@
#include "arcane/utils/FatalErrorException.h"
#include "arcane/utils/ScopedPtr.h"

#include "arcane/IParallelMng.h"
#include "arcane/ISerializer.h"
#include "arcane/ISerializeMessage.h"
#include "arcane/IParallelExchanger.h"
#include "arcane/ISubDomain.h"
#include "arcane/IVariable.h"
#include "arcane/IItemFamily.h"
#include "arcane/ItemInternal.h"
#include "arcane/ItemGroup.h"
#include "arcane/ParallelMngUtils.h"
#include "arcane/core/IParallelMng.h"
#include "arcane/core/ISerializer.h"
#include "arcane/core/ISerializeMessage.h"
#include "arcane/core/IParallelExchanger.h"
#include "arcane/core/ISubDomain.h"
#include "arcane/core/IVariable.h"
#include "arcane/core/IItemFamily.h"
#include "arcane/core/ItemInternal.h"
#include "arcane/core/ItemGroup.h"
#include "arcane/core/ParallelMngUtils.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -138,10 +138,10 @@ applyOperation(IDataOperation* operation)
sbuf->setMode(ISerializer::ModeReserve);

// Réserve pour le magic number
sbuf->reserve(DT_Int64,1);
sbuf->reserveInt64(1);

// Réserve pour la liste uniqueId() des entités transférées
sbuf->reserve(DT_Int64,1);
sbuf->reserveInt64(1);
sbuf->reserveSpan(dest_items_unique_id);

// Réserve pour chaque variable
Expand Down
8 changes: 4 additions & 4 deletions arcane/src/arcane/impl/Array2Data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
{
Integer nb_count = DataTypeTraitsT<DataType>::nbBasicType();
typedef typename DataTypeTraitsT<DataType>::BasicType BasicType;
eDataType data_type = DataTypeTraitsT<BasicType>::type();
eBasicDataType data_type = DataTypeTraitsT<BasicType>::basicDataType();

ISerializer::eMode mode = sbuf->mode();
if (mode==ISerializer::ModeReserve){
Expand All @@ -428,7 +428,7 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
// - le nombre d'éléments de la deuxième dimension
// - le nombre d'éléments de ids.
// - le nombre magique pour verification
sbuf->reserveSpan(DT_Int64,4);
sbuf->reserveSpan(eBasicDataType::Int64,4);
// Réserve la mémoire pour les valeurs
Int64 total_nb_element = m_value.totalNbElement();
sbuf->reserveSpan(data_type,total_nb_element*nb_count);
Expand Down Expand Up @@ -495,7 +495,7 @@ serialize(ISerializer* sbuf,Int32ConstArrayView ids,IDataOperation* operation)
{
Integer nb_count = DataTypeTraitsT<DataType>::nbBasicType();
typedef typename DataTypeTraitsT<DataType>::BasicType BasicType;
eDataType data_type = DataTypeTraitsT<BasicType>::type();
eBasicDataType data_type = DataTypeTraitsT<BasicType>::basicDataType();

ISerializer::eMode mode = sbuf->mode();
if (mode==ISerializer::ModeReserve){
Expand All @@ -504,7 +504,7 @@ serialize(ISerializer* sbuf,Int32ConstArrayView ids,IDataOperation* operation)
// - le nombre d'éléments de la deuxième dimension
// - le nombre d'éléments de ids.
// - le nombre magique pour verification
sbuf->reserveSpan(DT_Int64,4);
sbuf->reserveSpan(eBasicDataType::Int64,4);
// Réserve la mémoire pour les valeurs
Int64 total_nb_value = ((Int64)ids.size()) * ((Int64)m_value.dim2Size());
sbuf->reserveSpan(data_type,total_nb_value*nb_count);
Expand Down
24 changes: 10 additions & 14 deletions arcane/src/arcane/impl/ArrayData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
{
Integer nb_count = DataTypeTraitsT<DataType>::nbBasicType();
typedef typename DataTypeTraitsT<DataType>::BasicType BasicType;
eDataType data_type = DataTypeTraitsT<BasicType>::type();
eBasicDataType data_type = DataTypeTraitsT<BasicType>::basicDataType();
bool is_debug = arcaneIsDebug();

switch(sbuf->mode()){
Expand All @@ -391,9 +391,8 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
Int64 nb_value = m_value.largeSize();
Int64 total_size = nb_value*nb_count;
m_trace->debug(Trace::High) << " ArrayDataT::serialize (full) reserve datatype="
<< dataTypeName(data_type)
<< " ids=" << nb_value << " totalsize=" << total_size;
sbuf->reserve(DT_Int64,2); // 1 pour magic number et 1 pour la taille
<< data_type << " ids=" << nb_value << " totalsize=" << total_size;
sbuf->reserveInt64(2); // 1 pour magic number et 1 pour la taille
sbuf->reserveSpan(data_type,total_size);
}
break;
Expand All @@ -402,8 +401,7 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
Int64 nb_value = m_value.largeSize();
Int64 total_size = nb_value*nb_count;
m_trace->debug(Trace::High) << " ArrayDataT::serialize (full) put datatype="
<< dataTypeName(data_type)
<< " ids=" << nb_value << " totalsize=" << total_size;
<< data_type << " ids=" << nb_value << " totalsize=" << total_size;
if (is_debug)
for( Int64 i=0; i<nb_value; ++i )
m_trace->debug(Trace::Highest) << "Put i=" << i << " value =" << m_value[i];
Expand All @@ -426,7 +424,7 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
Int64 total_size = nb_value * nb_count;

m_trace->debug(Trace::High) << " ArrayDataT::serialize (full) get mode=" << sbuf->readMode()
<< " datatype=" << dataTypeName(data_type)
<< " datatype=" << data_type
<< " ids=" << nb_value << " totalsize=" << total_size;
switch(sbuf->readMode()){
case ISerializer::ReadReplace:
Expand Down Expand Up @@ -488,7 +486,7 @@ _serialize(ISerializer* sbuf,Span<const Int32> ids,IDataOperation* operation)
{
Integer nb_count = DataTypeTraitsT<DataType>::nbBasicType();
typedef typename DataTypeTraitsT<DataType>::BasicType BasicType;
eDataType data_type = DataTypeTraitsT<BasicType>::type();
eBasicDataType data_type = DataTypeTraitsT<BasicType>::basicDataType();
bool is_debug = arcaneIsDebug();

Int64 nb_value = ids.size();
Expand All @@ -498,17 +496,15 @@ _serialize(ISerializer* sbuf,Span<const Int32> ids,IDataOperation* operation)
case ISerializer::ModeReserve:
{
m_trace->debug(Trace::High) << " ArrayDataT::serialize (partial) reserve datatype="
<< dataTypeName(data_type)
<< " ids=" << nb_value << " totalsize=" << total_size;
sbuf->reserve(DT_Int64,2);
<< data_type << " ids=" << nb_value << " totalsize=" << total_size;
sbuf->reserveInt64(2);
sbuf->reserveSpan(data_type,total_size);
}
break;
case ISerializer::ModePut:
{
m_trace->debug(Trace::High) << " ArrayDataT::serialize (partial) put datatype="
<< dataTypeName(data_type)
<< " ids=" << nb_value << " totalsize=" << total_size;
<< data_type << " ids=" << nb_value << " totalsize=" << total_size;
if (is_debug){
// Vérifie les valeurs
for( Integer i=0, max_value=m_value.size(); i<nb_value; ++i )
Expand Down Expand Up @@ -536,7 +532,7 @@ _serialize(ISerializer* sbuf,Span<const Int32> ids,IDataOperation* operation)
case ISerializer::ModeGet:
{
m_trace->debug(Trace::High) << " ArrayDataT::serialize (partial) get mode=" << sbuf->readMode()
<< " datatype=" << dataTypeName(data_type)
<< " datatype=" << data_type
<< " ids=" << nb_value << " totalsize=" << total_size;
if (is_debug){
// Vérifie les valeurs
Expand Down
24 changes: 12 additions & 12 deletions arcane/src/arcane/impl/GetVariablesValuesParallelOperation.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* GetVariablesValuesParallelOperation.cc (C) 2000-2023 */
/* GetVariablesValuesParallelOperation.cc (C) 2000-2024 */
/* */
/* Opérations pour accéder aux valeurs de variables d'un autre sous-domaine. */
/*---------------------------------------------------------------------------*/
Expand All @@ -14,12 +14,12 @@
#include "arcane/utils/Array.h"
#include "arcane/utils/ITraceMng.h"

#include "arcane/Timer.h"
#include "arcane/VariableTypes.h"
#include "arcane/IParallelMng.h"
#include "arcane/ISerializer.h"
#include "arcane/SerializeMessage.h"
#include "arcane/IItemFamily.h"
#include "arcane/core/Timer.h"
#include "arcane/core/VariableTypes.h"
#include "arcane/core/IParallelMng.h"
#include "arcane/core/ISerializer.h"
#include "arcane/core/SerializeMessage.h"
#include "arcane/core/IItemFamily.h"

#include "arcane/impl/GetVariablesValuesParallelOperation.h"

Expand Down Expand Up @@ -151,8 +151,8 @@ getVariableValues(VariableItemReal& variable,
ARCANE_FATAL("Can not find rank '{0}'",rank_recv);
Span<const Int64> z_unique_ids = xiter->second.m_unique_ids;
Int64 nb = z_unique_ids.size();
s->reserve(DT_Int64,1); // Pour la taille
s->reserveSpan(DT_Int64,nb); // Pour le tableau
s->reserveInt64(1); // Pour la taille
s->reserveSpan(eBasicDataType::Int64,nb); // Pour le tableau
s->allocateBuffer();
s->setMode(ISerializer::ModePut);
s->putInt64(nb);
Expand Down Expand Up @@ -196,8 +196,8 @@ getVariableValues(VariableItemReal& variable,
new_sm = new SerializeMessage(my_rank,sm->destination().value(),ISerializeMessage::MT_Send);
ISerializer* s2 = new_sm->serializer();
s2->setMode(ISerializer::ModeReserve);
s2->reserve(DT_Int64,1);
s2->reserveSpan(DT_Real,nb);
s2->reserveInt64(1);
s2->reserveSpan(eBasicDataType::Real,nb);
s2->allocateBuffer();
s2->setMode(ISerializer::ModePut);
s2->putInt64(nb);
Expand Down
10 changes: 5 additions & 5 deletions arcane/src/arcane/impl/NumArrayData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ serialize(ISerializer* sbuf,IDataOperation* operation)
// Réserve la mémoire pour
// - le nombre magique pour verification
// - le nombre d'éléments de ids.
sbuf->reserveSpan(DT_Int64,2);
sbuf->reserveSpan(eBasicDataType::Int64,2);
// Réserve la mémoire pour le nombre d'éléments de chaque dimension (soit RankValue)
sbuf->reserveSpan(DT_Int32,RankValue);
sbuf->reserveSpan(eBasicDataType::Int32,RankValue);
// Réserve la mémoire pour les valeurs
sbuf->reserveSpan(m_value.to1DSpan());
}
Expand Down Expand Up @@ -499,16 +499,16 @@ serialize(ISerializer* sbuf,Int32ConstArrayView ids,IDataOperation* operation)

[[maybe_unused]] Integer nb_count = 1;
typedef typename DataTypeTraitsT<DataType>::BasicType BasicType;
eDataType data_type = DataTypeTraitsT<BasicType>::type();
eBasicDataType data_type = DataTypeTraitsT<BasicType>::basicDataType();
ISerializer::eMode mode = sbuf->mode();
if (mode==ISerializer::ModeReserve){
// Réserve la mémoire pour
// - le nombre magique pour verification
// - le nombre d'éléments de ids.
// -
sbuf->reserveSpan(DT_Int64,3);
sbuf->reserveSpan(eBasicDataType::Int64,3);
// Réserve la mémoire pour le nombre d'éléments de chaque dimension (soit RankValue)
sbuf->reserveSpan(DT_Int32,RankValue);
sbuf->reserveSpan(eBasicDataType::Int32,RankValue);
// Réserve la mémoire pour les valeurs
auto sub_extent = m_value.extents().removeFirstExtent();
sbuf->reserveSpan(data_type,sub_extent.totalNbElement() * ids.size());
Expand Down
Loading

0 comments on commit fc129a4

Please sign in to comment.