From 2b31b6192518863ae15787b6b8b742d1eeab391c Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Wed, 6 Nov 2024 22:47:13 +0100 Subject: [PATCH] [arcane,materials] Simplifie 'ItemMaterialVariableBase::_initializeNewItems()' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En profite pour corriger des avertissements signalés par 'clang-tidy'. --- .../materials/ItemMaterialVariableBaseT.H | 19 +-- .../arcane/materials/MeshMaterialVariable.h | 142 +++++++++--------- 2 files changed, 83 insertions(+), 78 deletions(-) diff --git a/arcane/src/arcane/materials/ItemMaterialVariableBaseT.H b/arcane/src/arcane/materials/ItemMaterialVariableBaseT.H index fc14715de..d32b02a2f 100644 --- a/arcane/src/arcane/materials/ItemMaterialVariableBaseT.H +++ b/arcane/src/arcane/materials/ItemMaterialVariableBaseT.H @@ -393,8 +393,8 @@ _resizeForIndexer(ResizeVariableIndexerArgs& args) this->_setView(index + 1); } if (args.isUseOneCommand()) { - auto dest = asWritableBytes(m_device_views).smallView(); - auto source = asBytes(m_host_views).smallView(); + auto dest = asWritableBytes(m_device_views.view()); + auto source = asBytes(m_host_views.view()); args.addOneCopyData(source,dest,1); } else @@ -467,7 +467,7 @@ _initializeNewItems(const ComponentItemListBuilder& list_builder, RunQueue& queu { MeshMaterialVariableIndexer* indexer = list_builder.indexer(); Integer var_index = indexer->index(); - PrivatePartType* partial_var = m_vars[var_index+1]; + PrivatePartType* partial_var = m_vars[var_index + 1]; if (!_isValidAndUsedAndGlobalUsed(partial_var)) return; @@ -485,31 +485,32 @@ _initializeNewItems(const ComponentItemListBuilder& list_builder, RunQueue& queu auto command = makeCommand(queue); SmallSpan views = m_device_views.smallSpan(); + ContainerSpanType partial_view = m_host_views[var_index + 1]; + ContainerSpanType pure_view = m_host_views[0]; + ARCANE_CHECK_ACCESSIBLE_POINTER(queue, views.data()); ARCANE_CHECK_ACCESSIBLE_POINTER(queue, partial_matvar.data()); - if (init_with_zero){ + if (init_with_zero) { command << RUNCOMMAND_LOOP1(iter, nb_partial) { auto [i] = iter(); MatVarIndex mvi = partial_matvar[i]; - Traits::setValue(views[mvi.arrayIndex()][mvi.valueIndex()],zero); + Traits::setValue(partial_view[mvi.valueIndex()], zero); }; } - else{ + else { SmallSpan partial_local_ids = list_builder.partialLocalIds(); ARCANE_CHECK_ACCESSIBLE_POINTER(queue, partial_local_ids.data()); command << RUNCOMMAND_LOOP1(iter, nb_partial) { auto [i] = iter(); - const auto& v = views[0][partial_local_ids[i]]; MatVarIndex mvi = partial_matvar[i]; - Traits::setValue(views[mvi.arrayIndex()][mvi.valueIndex()],v); + Traits::setValue(partial_view[mvi.valueIndex()], pure_view[partial_local_ids[i]]); }; } } - /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/materials/MeshMaterialVariable.h b/arcane/src/arcane/materials/MeshMaterialVariable.h index be4a9c0a8..3323fba40 100644 --- a/arcane/src/arcane/materials/MeshMaterialVariable.h +++ b/arcane/src/arcane/materials/MeshMaterialVariable.h @@ -178,18 +178,19 @@ class MaterialVariableScalarTraits { public: - typedef DataType ValueType; - - typedef DataType SubViewType; - typedef DataType SubConstViewType; - typedef DataType SubInputViewType; - typedef ArrayView ContainerViewType; - typedef ConstArrayView ContainerConstViewType; - typedef VariableArrayT PrivatePartType; - typedef IArrayDataT ValueDataType; - typedef Array ContainerType; - typedef UniqueArray UniqueContainerType; - typedef VariableRefArrayT VariableRefType; + using ValueType = DataType; + + using SubViewType = DataType; + using SubConstViewType = DataType; + using SubInputViewType = DataType; + using ContainerSpanType = SmallSpan; + using ContainerViewType = ArrayView; + using ContainerConstViewType = ConstArrayView; + using PrivatePartType = VariableArrayT; + using ValueDataType = IArrayDataT; + using ContainerType = Array; + using UniqueContainerType = UniqueArray; + using VariableRefType = VariableRefArrayT; public: @@ -211,8 +212,8 @@ class MaterialVariableScalarTraits static Integer dimension() { return 0; } static SmallSpan toBytes(ArrayView view) { - SmallSpan s(view); - return asWritableBytes(s).smallView(); + //SmallSpan s(view); + return asWritableBytes(view); } }; @@ -225,18 +226,19 @@ class MaterialVariableArrayTraits { public: - typedef DataType ValueType; + using ValueType = DataType; - typedef ArrayView SubViewType; - typedef ConstArrayView SubConstViewType; - typedef SmallSpan SubInputViewType; - typedef Array2View ContainerViewType; - typedef ConstArray2View ContainerConstViewType; - typedef Array2VariableT PrivatePartType; - typedef IArray2DataT ValueDataType; - typedef Array2 ContainerType; - typedef UniqueArray2 UniqueContainerType; - typedef VariableRefArray2T VariableRefType; + using SubViewType = ArrayView; + using SubConstViewType = ConstArrayView; + using SubInputViewType = SmallSpan; + using ContainerViewType = Array2View; + using ContainerSpanType = SmallSpan2; + using ContainerConstViewType = ConstArray2View; + using PrivatePartType = Array2VariableT; + using ValueDataType = IArray2DataT; + using ContainerType = Array2; + using UniqueContainerType = UniqueArray2; + using VariableRefType = VariableRefArray2T; public: @@ -263,7 +265,7 @@ class MaterialVariableArrayTraits static SmallSpan toBytes(Array2View view) { SmallSpan s(view.data(), view.totalNbElement()); - return asWritableBytes(s).smallView(); + return asWritableBytes(s); } static Integer dimension() { return 0; } @@ -282,21 +284,22 @@ class ItemMaterialVariableBase { public: - typedef Traits TraitsType; - typedef typename Traits::ValueType ValueType; - typedef typename Traits::ValueType DataType; - typedef ItemMaterialVariableBase ThatClass; - - typedef typename Traits::SubViewType SubViewType; - typedef typename Traits::SubConstViewType SubConstViewType; - typedef typename Traits::SubInputViewType SubInputViewType; - typedef typename Traits::ContainerViewType ContainerViewType; - typedef typename Traits::ContainerConstViewType ContainerConstViewType; - typedef typename Traits::PrivatePartType PrivatePartType; - typedef typename Traits::ValueDataType ValueDataType; - typedef typename Traits::ContainerType ContainerType; - typedef typename Traits::UniqueContainerType UniqueContainerType; - typedef typename Traits::VariableRefType VariableRefType; + using TraitsType = Traits; + using ValueType = typename Traits::ValueType; + using DataType = typename Traits::ValueType; + using ThatClass = ItemMaterialVariableBase; + + using SubViewType = typename Traits::SubViewType; + using SubConstViewType = typename Traits::SubConstViewType; + using SubInputViewType = typename Traits::SubInputViewType; + using ContainerSpanType = typename Traits::ContainerSpanType; + using ContainerViewType = typename Traits::ContainerViewType; + using ContainerConstViewType = typename Traits::ContainerConstViewType; + using PrivatePartType = typename Traits::PrivatePartType; + using ValueDataType = typename Traits::ValueDataType; + using ContainerType = typename Traits::ContainerType; + using UniqueContainerType = typename Traits::UniqueContainerType; + using VariableRefType = typename Traits::VariableRefType; public: @@ -304,7 +307,7 @@ class ItemMaterialVariableBase ItemMaterialVariableBase(const MaterialVariableBuildInfo& v, PrivatePartType* global_var, VariableRef* global_var_ref,MatVarSpace mvs); - ARCANE_MATERIALS_EXPORT ~ItemMaterialVariableBase(); + ARCANE_MATERIALS_EXPORT ~ItemMaterialVariableBase() override; public: @@ -374,6 +377,12 @@ class ItemMaterialVariableBase protected: + /*! + * \brief Positionne les vues à partir du conteneur + * + * La vue accélérateur n'est pas mise à jour ici mais lors de l'appel + * à _copyHostViewsToViews(). + */ void _setView(Int32 index) { ContainerViewType view; @@ -416,16 +425,16 @@ class ItemMaterialVariableScalar : public ItemMaterialVariableBase> { public: - - typedef ItemMaterialVariableBase> BaseClass; - typedef MaterialVariableScalarTraits Traits; - typedef ItemMaterialVariableScalar ThatClass; - typedef typename Traits::ContainerViewType ContainerViewType; - typedef typename Traits::PrivatePartType PrivatePartType; - typedef typename Traits::ValueDataType ValueDataType; - typedef typename Traits::ContainerType ContainerType; - typedef typename Traits::VariableRefType VariableRefType; + using BaseClass = ItemMaterialVariableBase>; + using Traits = MaterialVariableScalarTraits; + using ThatClass = ItemMaterialVariableScalar; + + using ContainerViewType = typename Traits::ContainerViewType; + using PrivatePartType = typename Traits::PrivatePartType; + using ValueDataType = typename Traits::ValueDataType; + using ContainerType = typename Traits::ContainerType; + using VariableRefType = typename Traits::VariableRefType; protected: @@ -495,8 +504,6 @@ class ItemMaterialVariableScalar void _synchronizeV1(); void _synchronizeV2(); - void _synchronizeV3(); - void _synchronizeV4(); void _synchronizeV5(); Int64 _synchronize2(); @@ -568,8 +575,8 @@ class MeshMaterialVariableScalar IMeshMaterialVariable* toMeshMaterialVariable() final { return this; } private: - - VariableRefType* m_true_global_variable_ref; + + VariableRefType* m_true_global_variable_ref = nullptr; }; /*---------------------------------------------------------------------------*/ @@ -585,16 +592,16 @@ class ItemMaterialVariableArray { public: - typedef ItemMaterialVariableBase> BaseClass; - typedef MaterialVariableArrayTraits Traits; + using BaseClass = ItemMaterialVariableBase>; + using Traits = MaterialVariableArrayTraits; - typedef ItemMaterialVariableArray ThatClass; + using ThatClass = ItemMaterialVariableArray; - typedef typename Traits::ContainerViewType ContainerViewType; - typedef typename Traits::PrivatePartType PrivatePartType; - typedef typename Traits::ValueDataType ValueDataType; - typedef typename Traits::ContainerType ContainerType; - typedef typename Traits::VariableRefType VariableRefType; + using ContainerViewType = typename Traits::ContainerViewType; + using PrivatePartType = typename Traits::PrivatePartType; + using ValueDataType = typename Traits::ValueDataType; + using ContainerType = typename Traits::ContainerType; + using VariableRefType = typename Traits::VariableRefType; protected: @@ -602,7 +609,6 @@ class ItemMaterialVariableArray ItemMaterialVariableArray(const MaterialVariableBuildInfo& v, PrivatePartType* global_var, VariableRef* global_var_ref,MatVarSpace mvs); - ARCANE_MATERIALS_EXPORT ~ItemMaterialVariableArray() {} public: @@ -679,10 +685,10 @@ class MeshMaterialVariableArray using ThatInterface = IArrayMeshMaterialVariable; using BuilderType = typename ThatInterface::BuilderType; using StaticImpl = MeshMaterialVariableCommonStaticImpl; - typedef ItemType ItemTypeTemplate; + using ItemTypeTemplate = ItemType; using BaseClass = ItemMaterialVariableArray; - typedef MeshVariableArrayRefT VariableRefType; + using VariableRefType = MeshVariableArrayRefT; using PrivatePartType = typename BaseClass::PrivatePartType; friend StaticImpl; @@ -693,8 +699,6 @@ class MeshMaterialVariableArray MeshMaterialVariableArray(const MaterialVariableBuildInfo& v, PrivatePartType* global_var, VariableRefType* global_var_ref,MatVarSpace mvs); - ARCANE_MATERIALS_EXPORT - ~MeshMaterialVariableArray(){} public: @@ -706,7 +710,7 @@ class MeshMaterialVariableArray private: - VariableRefType* m_true_global_variable_ref; + VariableRefType* m_true_global_variable_ref = nullptr; };