14#include "arcane/utils/internal/MemoryRessourceMng.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/MemoryView.h"
20#include "arcane/utils/MemoryAllocator.h"
45 return "UnifiedMemory";
62extern "C++" ARCANE_UTILS_EXPORT std::ostream&
79 [[maybe_unused]]
const RunQueue* queue)
override
84 if (!_isHost(from_mem))
85 ARCANE_FATAL(
"Source buffer is not accessible from host and no copier provided (location={0})",
89 ARCANE_FATAL(
"Destination buffer is not accessible from host and no copier provided (location={0})",
102, m_copier(m_default_memory_copier.get())
114int MemoryRessourceMng::
118 if (x <= 0 || x >= NB_MEMORY_RESSOURCE)
119 ARCANE_FATAL(
"Invalid value '{0}'. Valid range is '1' to '{1}'", x, NB_MEMORY_RESSOURCE - 1);
126IMemoryAllocator* MemoryRessourceMng::
129 int x = _checkValidRessource(r);
130 IMemoryAllocator* a = m_allocators[x];
134 if (!a && !m_is_accelerator) {
142 if (!a && throw_if_not_found)
143 ARCANE_FATAL(
"Allocator for ressource '{0}' is not available", r);
151IMemoryAllocator* MemoryRessourceMng::
154 return getAllocator(r,
true);
160void MemoryRessourceMng::
163 int x = _checkValidRessource(r);
164 m_allocators[x] = allocator;
170void MemoryRessourceMng::
174 Int64 from_size = from.bytes().size();
175 Int64 to_size = to.bytes().size();
176 if (from_size > to_size)
177 ARCANE_FATAL(
"Destination copy is too small (to_size={0} from_size={1})", to_size, from_size);
179 m_copier->copy(from, from_mem, to, to_mem, queue);
185void MemoryRessourceMng::
186genericCopy(ConstMemoryView from, MutableMemoryView to)
190 mrm->_internal()->copy(from, mem_type, to, mem_type,
nullptr);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
File d'exécution pour un accélérateur.
static AlignedMemoryAllocator * Simd()
Allocateur garantissant l'alignement pour utiliser la vectorisation sur la plateforme cible.
Interface d'un allocateur pour la mémoire.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
eMemoryRessource
Liste des ressources mémoire disponibles.
@ HostPinned
Alloue sur l'hôte.
@ Unknown
Valeur inconnue ou non initialisée.
@ UnifiedMemory
Alloue en utilisant la mémoire unifiée.
@ Device
Alloue sur le device.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.