Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MemoryAllocationOptions.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* MemoryAllocationOptions.h (C) 2000-2024 */
9/* */
10/* Options pour configurer les allocations. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COLLECTIONS_MEMORYALLOCATIONOPTIONS_H
13#define ARCCORE_COLLECTIONS_MEMORYALLOCATIONOPTIONS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/collections/CollectionsGlobal.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arccore
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
30class ARCCORE_COLLECTIONS_EXPORT MemoryAllocationOptions
31{
32 friend class ArrayMetaData;
33
34 public:
35
36 MemoryAllocationOptions() = default;
37
38 explicit MemoryAllocationOptions(IMemoryAllocator* allocator)
39 : m_allocator(allocator)
40 {
41 }
42
44 : m_allocator(allocator)
45 , m_memory_location_hint(mem_hint)
46 {
47 }
48
50 : m_allocator(allocator)
51 , m_device(device)
52 , m_memory_location_hint(mem_hint)
53 {
54 }
55
56 public:
57
59 : m_allocator(rhs.m_allocator)
60 , m_debug_info(rhs.m_debug_info)
61 , m_device(rhs.m_device)
62 , m_memory_location_hint(rhs.m_memory_location_hint)
63 , m_host_device_memory_location(rhs.m_host_device_memory_location)
64 {
65 if (m_debug_info)
66 _addDebugReference();
67 }
68
70 {
71 if (m_debug_info)
72 _removeDebugReference();
73 }
75 {
76 if (&rhs == this)
77 return (*this);
78 if (m_debug_info)
79 _removeDebugReference();
80 m_allocator = rhs.m_allocator;
81 m_memory_location_hint = rhs.m_memory_location_hint;
82 m_host_device_memory_location = rhs.m_host_device_memory_location;
83 m_device = rhs.m_device;
84 m_debug_info = rhs.m_debug_info;
85 if (m_debug_info)
86 _addDebugReference();
87 return (*this);
88 }
89
90 public:
91
92 IMemoryAllocator* allocator() const { return m_allocator; }
93 void setAllocator(IMemoryAllocator* v) { m_allocator = v; }
94
95 eMemoryLocationHint memoryLocationHint() const { return m_memory_location_hint; }
96 void setMemoryLocationHint(eMemoryLocationHint mem_advice) { m_memory_location_hint = mem_advice; }
97
98 void setHostDeviceMemoryLocation(eHostDeviceMemoryLocation v) { m_host_device_memory_location = v; }
99 eHostDeviceMemoryLocation hostDeviceMemoryLocation() const { return m_host_device_memory_location; }
100
101 Int16 device() const { return m_device; }
102 void setDevice(Int16 device) { m_device = device; }
103
104 void setArrayName(const String& name);
105 String arrayName() const;
106
107 RunQueue* runQueue() const { return m_queue; }
108
110 MemoryAllocationArgs allocationArgs(RunQueue* queue = nullptr) const;
111
112 public:
113
114 // TODO: A supprimer car ne sert que pour les tests
115 friend bool operator==(const MemoryAllocationOptions& a, const MemoryAllocationOptions& b)
116 {
117 if (a.m_allocator != b.m_allocator)
118 return false;
119 if (a.m_memory_location_hint != b.m_memory_location_hint)
120 return false;
121 if (a.m_host_device_memory_location != b.m_host_device_memory_location)
122 return false;
123 if (a.m_device != b.m_device)
124 return false;
125 if (a.m_queue != b.m_queue)
126 return false;
127 return true;
128 }
129
130 private:
131
132 IMemoryAllocator* m_allocator = nullptr;
133 ArrayDebugInfo* m_debug_info = nullptr;
134 Int16 m_device = -1;
135 eMemoryLocationHint m_memory_location_hint = eMemoryLocationHint::None;
136 eHostDeviceMemoryLocation m_host_device_memory_location = eHostDeviceMemoryLocation::Unknown;
137 RunQueue* m_queue = nullptr;
138
139 private:
140
141 void _addDebugReference();
142 void _removeDebugReference();
143};
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148} // namespace Arccore
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153#endif
File d'exécution pour un accélérateur.
Informations de debug pour les classes tableaux.
Classe contenant des informations pour spécialiser les allocations.
Options pour configurer les allocations.
Chaîne de caractères unicode.
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
eHostDeviceMemoryLocation
Localisation physique d'une adresse mémoire.
eMemoryLocationHint
Indices sur la localisation mémoire attendue.
std::int8_t Int8
Type entier signé sur 8 bits.
std::int16_t Int16
Type entier signé sur 16 bits.