Arcane  v3.14.10.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 {
64 if (m_debug_info)
65 _addDebugReference();
66 }
67
69 {
70 if (m_debug_info)
71 _removeDebugReference();
72 }
74 {
75 if (&rhs == this)
76 return (*this);
77 if (m_debug_info)
78 _removeDebugReference();
79 m_allocator = rhs.m_allocator;
80 m_memory_location_hint = rhs.m_memory_location_hint;
81 m_device = rhs.m_device;
82 m_debug_info = rhs.m_debug_info;
83 if (m_debug_info)
84 _addDebugReference();
85 return (*this);
86 }
87
88 public:
89
90 IMemoryAllocator* allocator() const { return m_allocator; }
91 void setAllocator(IMemoryAllocator* v) { m_allocator = v; }
92
93 eMemoryLocationHint memoryLocationHint() const { return m_memory_location_hint; }
94 void setMemoryLocationHint(eMemoryLocationHint mem_advice) { m_memory_location_hint = mem_advice; }
95
96 Int16 device() const { return m_device; }
97 void setDevice(Int16 device) { m_device = device; }
98
99 void setArrayName(const String& name);
100 String arrayName() const;
101
102 RunQueue* runQueue() const { return m_queue; }
103
105 MemoryAllocationArgs allocationArgs(RunQueue* queue = nullptr) const;
106
107 public:
108
109 friend bool operator==(const MemoryAllocationOptions& a, const MemoryAllocationOptions& b)
110 {
111 if (a.m_allocator != b.m_allocator)
112 return false;
113 if (a.m_memory_location_hint != b.m_memory_location_hint)
114 return false;
115 if (a.m_device != b.m_device)
116 return false;
117 if (a.m_queue != b.m_queue)
118 return false;
119 return true;
120 }
121
122 private:
123
124 IMemoryAllocator* m_allocator = nullptr;
125 ArrayDebugInfo* m_debug_info = nullptr;
126 Int16 m_device = -1;
127 eMemoryLocationHint m_memory_location_hint = eMemoryLocationHint::None;
128 RunQueue* m_queue = nullptr;
129
130 private:
131
132 void _addDebugReference();
133 void _removeDebugReference();
134};
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139} // namespace Arccore
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144#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
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.