From 2cbab90cc98c73126b62927d85f5284ac0af1429 Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 21:25:54 +0100 Subject: [PATCH 1/7] =?UTF-8?q?[arccore,collections]=20Ajoute=20=C3=A9num?= =?UTF-8?q?=C3=A9ration=20'eHostDeviceMemoryLocation'=20pour=20indiquer=20?= =?UTF-8?q?l'emplacement=20physique=20d'une=20zone=20m=C3=A9moire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arccore/collections/CMakeLists.txt | 1 + .../arccore/collections/CollectionsGlobal.cc | 60 +++++++++++++++++++ .../arccore/collections/CollectionsGlobal.h | 27 +++++++++ 3 files changed, 88 insertions(+) create mode 100644 arccore/src/collections/arccore/collections/CollectionsGlobal.cc diff --git a/arccore/src/collections/arccore/collections/CMakeLists.txt b/arccore/src/collections/arccore/collections/CMakeLists.txt index 76fb89fa5e..7710265bff 100644 --- a/arccore/src/collections/arccore/collections/CMakeLists.txt +++ b/arccore/src/collections/arccore/collections/CMakeLists.txt @@ -6,6 +6,7 @@ set(SOURCES ArrayTraits.h ArrayDebugInfo.h CollectionsGlobal.h + CollectionsGlobal.cc IMemoryAllocator.h MemoryAllocationArgs.h MemoryAllocationOptions.h diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.cc b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc new file mode 100644 index 0000000000..5d40c1d135 --- /dev/null +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc @@ -0,0 +1,60 @@ +// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- +//----------------------------------------------------------------------------- +// 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 +//----------------------------------------------------------------------------- +/*---------------------------------------------------------------------------*/ +/* CollectionsGlobal.cc (C) 2000-2024 */ +/* */ +/* Définitions globales de la composante 'Collections' de 'Arccore'. */ +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +#include "arccore/collections/CollectionsGlobal.h" + +#include + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +namespace Arccore +{ + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +namespace +{ + const char* _toName(eHostDeviceMemoryLocation v) + { + switch (v) { + case eHostDeviceMemoryLocation::Unknown: + return "Unknown"; + case eHostDeviceMemoryLocation::Device: + return "Device"; + case eHostDeviceMemoryLocation::Host: + return "Host"; + case eHostDeviceMemoryLocation::ManagedMemoryDevice: + return "ManagedMemoryDevice"; + case eHostDeviceMemoryLocation::ManagedMemoryHost: + return "ManagedMemoryHost"; + } + return "Invalid"; + } +} // namespace + +extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& +operator<<(std::ostream& o, eHostDeviceMemoryLocation v) +{ + o << _toName(v); + return o; +} + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +} // End namespace Arccore + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.h b/arccore/src/collections/arccore/collections/CollectionsGlobal.h index 2bb5e8bba1..e60bdbb58f 100644 --- a/arccore/src/collections/arccore/collections/CollectionsGlobal.h +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.h @@ -16,6 +16,8 @@ #include "arccore/base/ArccoreGlobal.h" +#include + /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -85,6 +87,31 @@ enum class eMemoryLocationHint : int8_t HostAndDeviceMostlyRead = 3 }; +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ +/*! + * \brief Localisation physique d'une adresse mémoire. + * + * Pour les valeurs ManagedMemoryDevice et ManagedMemoryHost il s'agit d'une + * indication car il n'y a pas de moyen simple de savoir où se trouve + * réellement la mémoire. + */ +enum class eHostDeviceMemoryLocation : int8_t +{ + //! Localisation inconnue + Unknown = 0, + //! La mémoire est sur accélérateur + Device = 1, + //! La mémoire est sur l'hôte. + Host = 2, + //! La mémoire est de la mémoire managée sur accélérateur + ManagedMemoryDevice = 3, + //! La mémoire est de la mémoire managée sur l'hôte. + ManagedMemoryHost = 4, +}; +extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& +operator<<(std::ostream& o, eHostDeviceMemoryLocation r); + /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /*! From 2e94b2ecc8af10b1c1bc8e531f728bb1755184da Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 21:32:14 +0100 Subject: [PATCH 2/7] =?UTF-8?q?[arccore,collections]=20D=C3=A9place=20'eMe?= =?UTF-8?q?moryRessource'=20depuis=20'Arcane'.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arccore/collections/CollectionsGlobal.cc | 25 ++++++++++++++++ .../arccore/collections/CollectionsGlobal.h | 29 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.cc b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc index 5d40c1d135..315489c380 100644 --- a/arccore/src/collections/arccore/collections/CollectionsGlobal.cc +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc @@ -42,6 +42,24 @@ namespace } return "Invalid"; } + + const char* _toName(eMemoryRessource r) + { + switch (r) { + case eMemoryRessource::Unknown: + return "Unknown"; + case eMemoryRessource::Host: + return "Host"; + case eMemoryRessource::HostPinned: + return "HostPinned"; + case eMemoryRessource::Device: + return "Device"; + case eMemoryRessource::UnifiedMemory: + return "UnifiedMemory"; + } + return "Invalid"; + } + } // namespace extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& @@ -51,6 +69,13 @@ operator<<(std::ostream& o, eHostDeviceMemoryLocation v) return o; } +extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& +operator<<(std::ostream& o, eMemoryRessource v) +{ + o << _toName(v); + return o; +} + /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.h b/arccore/src/collections/arccore/collections/CollectionsGlobal.h index e60bdbb58f..3668987bf6 100644 --- a/arccore/src/collections/arccore/collections/CollectionsGlobal.h +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.h @@ -112,6 +112,35 @@ enum class eHostDeviceMemoryLocation : int8_t extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& operator<<(std::ostream& o, eHostDeviceMemoryLocation r); +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +/*! + * \brief Liste des ressources mémoire disponibles. + */ +enum class eMemoryRessource +{ + //! Valeur inconnue ou non initialisée + Unknown = 0, + //! Alloue sur l'hôte. + Host, + //! Alloue sur l'hôte. + HostPinned, + //! Alloue sur le device + Device, + //! Alloue en utilisant la mémoire unifiée. + UnifiedMemory +}; + +//! Nombre de valeurs valides pour eMemoryRessource +static constexpr int ARCCORE_NB_MEMORY_RESSOURCE = 5; + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& +operator<<(std::ostream& o, eMemoryRessource r); + /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /*! From 70dcbeaacf381567d710ebd28c0d9ee53694ffac Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 21:40:24 +0100 Subject: [PATCH 3/7] =?UTF-8?q?[arccore,collections]=20Conserve=20dans=20'?= =?UTF-8?q?MemoryAllocationOptions'=20la=20position=20physique=20de=20la?= =?UTF-8?q?=20m=C3=A9moire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arccore/collections/MemoryAllocationArgs.h | 4 ++++ .../arccore/collections/MemoryAllocationOptions.cc | 1 + .../arccore/collections/MemoryAllocationOptions.h | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/arccore/src/collections/arccore/collections/MemoryAllocationArgs.h b/arccore/src/collections/arccore/collections/MemoryAllocationArgs.h index 04063c7555..13a79fec40 100644 --- a/arccore/src/collections/arccore/collections/MemoryAllocationArgs.h +++ b/arccore/src/collections/arccore/collections/MemoryAllocationArgs.h @@ -34,6 +34,9 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationArgs void setMemoryLocationHint(eMemoryLocationHint mem_advice) { m_memory_location_hint = mem_advice; } eMemoryLocationHint memoryLocationHint() const { return m_memory_location_hint; } + void setHostDeviceMemoryLocation(eHostDeviceMemoryLocation v) { m_host_device_memory_location = v; } + eHostDeviceMemoryLocation hostDeviceMemoryLocation() const { return m_host_device_memory_location; } + Int16 device() const { return m_device; } void setDevice(Int16 device) { m_device = device; } @@ -49,6 +52,7 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationArgs private: eMemoryLocationHint m_memory_location_hint = eMemoryLocationHint::None; + eHostDeviceMemoryLocation m_host_device_memory_location = eHostDeviceMemoryLocation::Unknown; Int16 m_device = (-1); RunQueue* m_run_queue = nullptr; ArrayDebugInfo* m_debug_info = nullptr; diff --git a/arccore/src/collections/arccore/collections/MemoryAllocationOptions.cc b/arccore/src/collections/arccore/collections/MemoryAllocationOptions.cc index 2a235fe386..fe385c207c 100644 --- a/arccore/src/collections/arccore/collections/MemoryAllocationOptions.cc +++ b/arccore/src/collections/arccore/collections/MemoryAllocationOptions.cc @@ -38,6 +38,7 @@ allocationArgs(RunQueue* queue) const { MemoryAllocationArgs x; x.setMemoryLocationHint(m_memory_location_hint); + x.setHostDeviceMemoryLocation(m_host_device_memory_location); x.setDevice(m_device); x.setDebugInfo(m_debug_info); x.setRunQueue(queue); diff --git a/arccore/src/collections/arccore/collections/MemoryAllocationOptions.h b/arccore/src/collections/arccore/collections/MemoryAllocationOptions.h index 6b60c1ef17..7100b74277 100644 --- a/arccore/src/collections/arccore/collections/MemoryAllocationOptions.h +++ b/arccore/src/collections/arccore/collections/MemoryAllocationOptions.h @@ -60,6 +60,7 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions , m_debug_info(rhs.m_debug_info) , m_device(rhs.m_device) , m_memory_location_hint(rhs.m_memory_location_hint) + , m_host_device_memory_location(rhs.m_host_device_memory_location) { if (m_debug_info) _addDebugReference(); @@ -78,6 +79,7 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions _removeDebugReference(); m_allocator = rhs.m_allocator; m_memory_location_hint = rhs.m_memory_location_hint; + m_host_device_memory_location = rhs.m_host_device_memory_location; m_device = rhs.m_device; m_debug_info = rhs.m_debug_info; if (m_debug_info) @@ -93,6 +95,9 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions eMemoryLocationHint memoryLocationHint() const { return m_memory_location_hint; } void setMemoryLocationHint(eMemoryLocationHint mem_advice) { m_memory_location_hint = mem_advice; } + void setHostDeviceMemoryLocation(eHostDeviceMemoryLocation v) { m_host_device_memory_location = v; } + eHostDeviceMemoryLocation hostDeviceMemoryLocation() const { return m_host_device_memory_location; } + Int16 device() const { return m_device; } void setDevice(Int16 device) { m_device = device; } @@ -106,12 +111,15 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions public: + // TODO: A supprimer car ne sert que pour les tests friend bool operator==(const MemoryAllocationOptions& a, const MemoryAllocationOptions& b) { if (a.m_allocator != b.m_allocator) return false; if (a.m_memory_location_hint != b.m_memory_location_hint) return false; + if (a.m_host_device_memory_location != b.m_host_device_memory_location) + return false; if (a.m_device != b.m_device) return false; if (a.m_queue != b.m_queue) @@ -125,6 +133,7 @@ class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions ArrayDebugInfo* m_debug_info = nullptr; Int16 m_device = -1; eMemoryLocationHint m_memory_location_hint = eMemoryLocationHint::None; + eHostDeviceMemoryLocation m_host_device_memory_location = eHostDeviceMemoryLocation::Unknown; RunQueue* m_queue = nullptr; private: From 45dfa4952fa590dcea4ff71a5d03697284f36462 Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 22:02:58 +0100 Subject: [PATCH 4/7] =?UTF-8?q?[arccore,collections]=20Ajoute=20possibilit?= =?UTF-8?q?=C3=A9=20dans=20'AbstractArray'=20de=20sp=C3=A9cifier=20la=20lo?= =?UTF-8?q?calisation=20de=20la=20zone=20m=C3=A9moire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collections/arccore/collections/Array.cc | 9 +++++++++ .../collections/arccore/collections/Array.h | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/arccore/src/collections/arccore/collections/Array.cc b/arccore/src/collections/arccore/collections/Array.cc index 7ac1cfb6cf..8d83f9488a 100644 --- a/arccore/src/collections/arccore/collections/Array.cc +++ b/arccore/src/collections/arccore/collections/Array.cc @@ -107,6 +107,15 @@ _setMemoryLocationHint(eMemoryLocationHint new_hint,void* ptr,Int64 sizeof_true_ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ +void ArrayMetaData:: +_setHostDeviceMemoryLocation(eHostDeviceMemoryLocation location) +{ + allocation_options.setHostDeviceMemoryLocation(location); +} + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + void ArrayMetaData:: _copyFromMemory(MemoryPointer destination, ConstMemoryPointer source, Int64 sizeof_true_type, RunQueue* queue) { diff --git a/arccore/src/collections/arccore/collections/Array.h b/arccore/src/collections/arccore/collections/Array.h index 8c8d1cb172..0ebf2e4634 100644 --- a/arccore/src/collections/arccore/collections/Array.h +++ b/arccore/src/collections/arccore/collections/Array.h @@ -77,6 +77,7 @@ class ARCCORE_COLLECTIONS_EXPORT ArrayMetaData Int32 nb_ref = 0; //! Indique is cette instance a été allouée par l'opérateur new. bool is_allocated_by_new = false; + //! Indique si cette instance n'est pas l'instance nulle (partagée par tous les SharedArray) bool is_not_null = false; protected: @@ -102,6 +103,7 @@ class ARCCORE_COLLECTIONS_EXPORT ArrayMetaData MemoryPointer _reallocate(const AllocatedMemoryInfo& mem_info, Int64 new_capacity, Int64 sizeof_true_type, RunQueue* queue); void _deallocate(const AllocatedMemoryInfo& mem_info, RunQueue* queue) ARCCORE_NOEXCEPT; void _setMemoryLocationHint(eMemoryLocationHint new_hint, void* ptr, Int64 sizeof_true_type); + void _setHostDeviceMemoryLocation(eHostDeviceMemoryLocation location); void _copyFromMemory(MemoryPointer destination, ConstMemoryPointer source, Int64 sizeof_true_type, RunQueue* queue); private: @@ -465,6 +467,23 @@ class AbstractArray m_md->_setMemoryLocationHint(new_hint,m_ptr,sizeof(T)); } + /*! + * \brief Positionne l'emplacement physique de la zone mémoire. + * + * \warning L'appelant doit garantir la cohérence entre l'allocateur + * et la zone mémoire spécifiée. + */ + void _internalSetHostDeviceMemoryLocation(eHostDeviceMemoryLocation location) + { + m_md->_setHostDeviceMemoryLocation(location); + } + + //! Positionne l'emplacement physique de la zone mémoire. + eHostDeviceMemoryLocation hostDeviceMemoryLocation() const + { + return m_md->allocation_options.hostDeviceMemoryLocation(); + } + public: friend bool operator==(const AbstractArray& rhs, const AbstractArray& lhs) From 3f1c95b0e52231b40d4c76c7a01e241dc0b8823e Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 22:05:59 +0100 Subject: [PATCH 5/7] =?UTF-8?q?[arccore,collections]=20Ajoute=20'IMemoryAl?= =?UTF-8?q?locator::memoryRessource()'=20permettant=20de=20sp=C3=A9cifier?= =?UTF-8?q?=20la=20ressource=20m=C3=A9moire=20associ=C3=A9e=20=C3=A0=20un?= =?UTF-8?q?=20allocateur.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arccore/src/collections/arccore/collections/IMemoryAllocator.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arccore/src/collections/arccore/collections/IMemoryAllocator.h b/arccore/src/collections/arccore/collections/IMemoryAllocator.h index e23023d438..770868d6e2 100644 --- a/arccore/src/collections/arccore/collections/IMemoryAllocator.h +++ b/arccore/src/collections/arccore/collections/IMemoryAllocator.h @@ -139,6 +139,9 @@ class ARCCORE_COLLECTIONS_EXPORT IMemoryAllocator */ virtual void copyMemory(MemoryAllocationArgs args, AllocatedMemoryInfo destination, AllocatedMemoryInfo source); + //! Ressource mémoire fournie par l'allocateur + virtual eMemoryRessource memoryRessource() const { return eMemoryRessource::Unknown; } + public: // Méthodes historiques (avant 2023) sans arguments supplémentaires. From 47945fd837a0913a992f42186fdcbef8185469d2 Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 22:17:50 +0100 Subject: [PATCH 6/7] [arccore,collections] Renomme 'eMemoryRessource' en 'eMemoryResource'. --- .../arccore/collections/CollectionsGlobal.cc | 14 +++++++------- .../arccore/collections/CollectionsGlobal.h | 6 +++--- .../arccore/collections/IMemoryAllocator.h | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.cc b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc index 315489c380..10d96e81a0 100644 --- a/arccore/src/collections/arccore/collections/CollectionsGlobal.cc +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.cc @@ -43,18 +43,18 @@ namespace return "Invalid"; } - const char* _toName(eMemoryRessource r) + const char* _toName(eMemoryResource r) { switch (r) { - case eMemoryRessource::Unknown: + case eMemoryResource::Unknown: return "Unknown"; - case eMemoryRessource::Host: + case eMemoryResource::Host: return "Host"; - case eMemoryRessource::HostPinned: + case eMemoryResource::HostPinned: return "HostPinned"; - case eMemoryRessource::Device: + case eMemoryResource::Device: return "Device"; - case eMemoryRessource::UnifiedMemory: + case eMemoryResource::UnifiedMemory: return "UnifiedMemory"; } return "Invalid"; @@ -70,7 +70,7 @@ operator<<(std::ostream& o, eHostDeviceMemoryLocation v) } extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& -operator<<(std::ostream& o, eMemoryRessource v) +operator<<(std::ostream& o, eMemoryResource v) { o << _toName(v); return o; diff --git a/arccore/src/collections/arccore/collections/CollectionsGlobal.h b/arccore/src/collections/arccore/collections/CollectionsGlobal.h index 3668987bf6..a828ca7db4 100644 --- a/arccore/src/collections/arccore/collections/CollectionsGlobal.h +++ b/arccore/src/collections/arccore/collections/CollectionsGlobal.h @@ -118,7 +118,7 @@ operator<<(std::ostream& o, eHostDeviceMemoryLocation r); /*! * \brief Liste des ressources mémoire disponibles. */ -enum class eMemoryRessource +enum class eMemoryResource { //! Valeur inconnue ou non initialisée Unknown = 0, @@ -133,13 +133,13 @@ enum class eMemoryRessource }; //! Nombre de valeurs valides pour eMemoryRessource -static constexpr int ARCCORE_NB_MEMORY_RESSOURCE = 5; +static constexpr int ARCCORE_NB_MEMORY_RESOURCE = 5; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ extern "C++" ARCCORE_COLLECTIONS_EXPORT std::ostream& -operator<<(std::ostream& o, eMemoryRessource r); +operator<<(std::ostream& o, eMemoryResource r); /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/arccore/src/collections/arccore/collections/IMemoryAllocator.h b/arccore/src/collections/arccore/collections/IMemoryAllocator.h index 770868d6e2..4c6e8986a7 100644 --- a/arccore/src/collections/arccore/collections/IMemoryAllocator.h +++ b/arccore/src/collections/arccore/collections/IMemoryAllocator.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-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- /*---------------------------------------------------------------------------*/ -/* IMemoryAllocator.h (C) 2000-2023 */ +/* IMemoryAllocator.h (C) 2000-2024 */ /* */ /* Interface d'un allocateur mémoire. */ /*---------------------------------------------------------------------------*/ @@ -140,7 +140,7 @@ class ARCCORE_COLLECTIONS_EXPORT IMemoryAllocator virtual void copyMemory(MemoryAllocationArgs args, AllocatedMemoryInfo destination, AllocatedMemoryInfo source); //! Ressource mémoire fournie par l'allocateur - virtual eMemoryRessource memoryRessource() const { return eMemoryRessource::Unknown; } + virtual eMemoryResource memoryRessource() const { return eMemoryResource::Unknown; } public: From 960ee6e685762d539904020d0bf8b2f4f78de6c6 Mon Sep 17 00:00:00 2001 From: Gilles Grospellier Date: Thu, 28 Nov 2024 22:18:20 +0100 Subject: [PATCH 7/7] =?UTF-8?q?[arccore,collections]=20Ajoute=20test=20pou?= =?UTF-8?q?r=20les=20derni=C3=A8res=20modifications.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arccore/src/collections/tests/TestArray.cc | 39 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/arccore/src/collections/tests/TestArray.cc b/arccore/src/collections/tests/TestArray.cc index 57e53b92de..abcaee588c 100644 --- a/arccore/src/collections/tests/TestArray.cc +++ b/arccore/src/collections/tests/TestArray.cc @@ -23,21 +23,29 @@ void _testArraySwap(bool use_own_swap) { std::cout << "** TestArraySwap is_own=" << use_own_swap << "\n"; + String c1_name = "TestC1"; UniqueArray c1(7); - IntSubClass* x1 = c1.unguardedBasePointer(); + c1.setDebugName(c1_name); + IntSubClass* x1 = c1.data(); std::cout << "** C1_this = " << &c1 << "\n"; std::cout << "** C1_BASE = " << x1 << "\n"; UniqueArray c2(3); - IntSubClass* x2 = c2.unguardedBasePointer(); + IntSubClass* x2 = c2.data(); std::cout << "** C2_this = " << &c2 << "\n"; std::cout << "** C2_BASE = " << x2 << "\n"; + ASSERT_EQ(c1.debugName(), c1_name); + ASSERT_EQ(c2.debugName(), String{}); + if (use_own_swap) { swap(c1, c2); } else std::swap(c1, c2); + ASSERT_EQ(c2.debugName(), c1_name); + ASSERT_EQ(c1.debugName(), String{}); + IntSubClass* after_x1 = c1.data(); IntSubClass* after_x2 = c2.data(); std::cout << "** C1_BASE_AFTER = " << after_x1 << " size=" << c1.size() << "\n"; @@ -990,6 +998,9 @@ TEST(Array, AllocatorV2) } } +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + TEST(Array, DebugInfo) { using namespace Arccore; @@ -1034,6 +1045,30 @@ TEST(Array, DebugInfo) /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ +TEST(Collections, Memory) +{ + using namespace Arccore; + std::cout << eHostDeviceMemoryLocation::Unknown << " " + << eHostDeviceMemoryLocation::Device << " " + << eHostDeviceMemoryLocation::Host << " " + << eHostDeviceMemoryLocation::ManagedMemoryDevice << " " + << eHostDeviceMemoryLocation::ManagedMemoryHost << "\n"; + + std::cout << eMemoryResource::Unknown << " " + << eMemoryResource::Host << " " + << eMemoryResource::HostPinned << " " + << eMemoryResource::Device << " " + << eMemoryResource::UnifiedMemory << "\n"; + + UniqueArray a1; + ASSERT_EQ(a1.hostDeviceMemoryLocation(), eHostDeviceMemoryLocation::Unknown); + a1._internalSetHostDeviceMemoryLocation(eHostDeviceMemoryLocation::Host); + ASSERT_EQ(a1.hostDeviceMemoryLocation(), eHostDeviceMemoryLocation::Host); +} + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + namespace Arccore { // Instancie explicitement les classes tableaux pour garantir