Arcane  v4.1.4.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ArrayMetaData.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ArrayMetaData.h (C) 2000-2026 */
9/* */
10/* Tableau 1D. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ARRAYMETADATA_H
13#define ARCCORE_COMMON_ARRAYMETADATA_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/common/MemoryAllocationOptions.h"
18#include "arccore/common/MemoryAllocationArgs.h"
19#include "arccore/common/IMemoryAllocator.h"
20#include "arccore/common/AllocatedMemoryInfo.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*!
31 * \internal
32 *
33 * \brief Meta-Données des tableaux.
34 *
35 * Cette classe sert pour contenir les meta-données communes à toutes les
36 * implémentations qui dérivent de AbstractArray.
37 *
38 * Seules les classes qui implémentent une sémantique à la UniqueArray
39 * ont le droit d'utiliser un allocateur autre que l'allocateur par défaut.
40 */
41class ARCCORE_COMMON_EXPORT ArrayMetaData
42{
43 // NOTE: Les champs de cette classe sont utilisés pour l'affichage TTF de totalview.
44 // Si on modifie leur ordre il faut mettre à jour la copie de cette classe
45 // dans l'afficheur totalview de Arcane.
46
47 template <typename> friend class AbstractArray;
48 template <typename> friend class Array2;
49 template <typename> friend class Array;
50 template <typename> friend class SharedArray;
51 template <typename> friend class SharedArray2;
52 friend class AbstractArrayBase;
53 static IMemoryAllocator* _defaultAllocator();
54
55 public:
56
57 ArrayMetaData()
58 : allocation_options(_defaultAllocator())
59 {}
60
61 protected:
62
63 //! Nombre d'éléments du tableau (pour les tableaux 1D)
65 //! Taille de la première dimension (pour les tableaux 2D)
67 //! Taille de la deuxième dimension (pour les tableaux 2D)
69 //! Nombre d'éléments alloués
71 //! Allocateur mémoire et options associées
73 //! Nombre de références sur l'instance
75 //! Indique is cette instance a été allouée par l'opérateur new.
76 bool is_allocated_by_new = false;
77 //! Indique si cette instance n'est pas l'instance nulle (partagée par tous les SharedArray)
78 bool is_not_null = false;
79
80 protected:
81
82 IMemoryAllocator* _allocator() const { return allocation_options.m_allocator; }
83
84 public:
85
86 static void throwInvalidMetaDataForSharedArray ARCCORE_NORETURN();
87 static void throwNullExpected ARCCORE_NORETURN();
88 static void throwNotNullExpected ARCCORE_NORETURN();
89 static void throwUnsupportedSpecificAllocator ARCCORE_NORETURN();
90 static void overlapError ARCCORE_NORETURN(const void* begin1, Int64 size1,
91 const void* begin2, Int64 size2);
92
93 protected:
94
95 using MemoryPointer = void*;
96 using ConstMemoryPointer = const void*;
97
98 protected:
99
100 MemoryPointer _allocate(Int64 nb, Int64 sizeof_true_type, RunQueue* queue);
101 MemoryPointer _reallocate(const AllocatedMemoryInfo& mem_info, Int64 new_capacity, Int64 sizeof_true_type, RunQueue* queue);
102 void _deallocate(const AllocatedMemoryInfo& mem_info, RunQueue* queue) noexcept
103 {
104 if (_allocator()) {
105 MemoryAllocationArgs alloc_args = _getAllocationArgs(queue);
106 _allocator()->deallocate(alloc_args, mem_info);
107 }
108 }
109 MemoryPointer _changeAllocator(const MemoryAllocationOptions& new_allocator_opt, const AllocatedMemoryInfo& current_info, Int64 sizeof_true_type, RunQueue* queue);
110 void _setMemoryLocationHint(eMemoryLocationHint new_hint, void* ptr, Int64 sizeof_true_type);
111 void _setHostDeviceMemoryLocation(eHostDeviceMemoryLocation location);
112 void _copyFromMemory(MemoryPointer destination, ConstMemoryPointer source, Int64 sizeof_true_type, RunQueue* queue);
113
114 private:
115
116 void _checkAllocator() const;
117 MemoryAllocationArgs _getAllocationArgs() const { return allocation_options.allocationArgs(); }
118 MemoryAllocationArgs _getAllocationArgs(RunQueue* queue) const
119 {
120 return allocation_options.allocationArgs(queue);
121 }
122};
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
126/*!
127 * \internal
128 *
129 * \brief Ce type n'est plus utilisé.
130 */
132{
133};
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137/*!
138 * \internal
139 *
140 * \brief Cette classe n'est plus utilisée.
141 */
142template <typename T>
144: public ArrayImplBase
145{
146};
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151} // namespace Arcane
152
153/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155
156#endif
Informations sur une zone mémoire allouée.
bool is_not_null
Indique si cette instance n'est pas l'instance nulle (partagée par tous les SharedArray)
Int64 size
Nombre d'éléments du tableau (pour les tableaux 1D)
Int64 capacity
Nombre d'éléments alloués.
MemoryAllocationOptions allocation_options
Allocateur mémoire et options associées.
Int32 nb_ref
Nombre de références sur l'instance.
Int64 dim2_size
Taille de la deuxième dimension (pour les tableaux 2D)
bool is_allocated_by_new
Indique is cette instance a été allouée par l'opérateur new.
Int64 dim1_size
Taille de la première dimension (pour les tableaux 2D)
Interface d'un allocateur pour la mémoire.
Classe contenant des informations pour spécialiser les allocations.
MemoryAllocationArgs allocationArgs(RunQueue *queue=nullptr) const
Arguments pour 'IMemoryAllocator' associés à ces options et à la file queue.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.