Arcane  v4.1.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArrayMetaData.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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-2025 */
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/*---------------------------------------------------------------------------*/
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
76 bool is_allocated_by_new = false;
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 void _setMemoryLocationHint(eMemoryLocationHint new_hint, void* ptr, Int64 sizeof_true_type);
110 void _setHostDeviceMemoryLocation(eHostDeviceMemoryLocation location);
111 void _copyFromMemory(MemoryPointer destination, ConstMemoryPointer source, Int64 sizeof_true_type, RunQueue* queue);
112
113 private:
114
115 void _checkAllocator() const;
116 MemoryAllocationArgs _getAllocationArgs() const { return allocation_options.allocationArgs(); }
117 MemoryAllocationArgs _getAllocationArgs(RunQueue* queue) const
118 {
119 return allocation_options.allocationArgs(queue);
120 }
121};
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
131{
132};
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
141template <typename T>
143: public ArrayImplBase
144{
145};
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150} // namespace Arcane
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155#endif
File d'exécution pour un accélérateur.
Informations sur une zone mémoire allouée.
Ce type n'est plus utilisé.
Cette classe n'est plus utilisé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.