14#include "arcane/utils/MemoryView.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/internal/SpecificMemoryCopyList.h"
61 ARCANE_FATAL(
"No instance of copier is available for RunQueue");
66 Int32 _checkDataTypeSize(
const TraceInfo& trace,
Int32 data_size1,
Int32 data_size2)
68 if (data_size1 != data_size2)
69 throw FatalErrorException(trace, String::format(
"Datatype size are not equal this={0} v={1}", data_size1, data_size2));
88void MutableMemoryView::
89copyHost(ConstMemoryView v)
const
91 auto source = v.bytes();
92 auto destination = bytes();
98 ARCANE_FATAL(
"Destination is too small source_size={0} destination_size={1}",
104 std::memmove(destination.data(), source.data(),
source_size);
110void MutableMemoryView::
116void MutableMemoryView::
117copyFromIndexes(ConstMemoryView v, SmallSpan<const Int32> indexes,
118 RunQueue* queue)
const
121 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
123 Int64 nb_index = indexes.size();
127 auto source = v.bytes();
128 auto destination = bytes();
130 _getDefaultCopyList(queue)->copyFrom(one_data_size, { indexes, source, destination, queue });
136void MutableMemoryView::
137fillIndexes(ConstMemoryView v, SmallSpan<const Int32> indexes,
138 RunQueue* queue)
const
140 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
142 Int64 nb_index = indexes.size();
146 auto source = v.bytes();
147 auto destination = bytes();
149 _getDefaultCopyList(queue)->fill(one_data_size, { indexes, source, destination, queue });
155void MutableMemoryView::
156fill(ConstMemoryView v, RunQueue* queue)
const
158 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
160 auto source = v.bytes();
161 auto destination = bytes();
163 _getDefaultCopyList(queue)->fill(one_data_size, { {}, source, destination, queue });
169void ConstMemoryView::
170copyToIndexesHost(MutableMemoryView v, Span<const Int32> indexes)
const
172 copyToIndexes(v, indexes.smallView(),
nullptr);
175void ConstMemoryView::
176copyToIndexes(MutableMemoryView v, SmallSpan<const Int32> indexes,
177 RunQueue* queue)
const
179 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
181 Int64 nb_index = indexes.size();
185 auto source = bytes();
186 auto destination = v.bytes();
188 _getDefaultCopyList(queue)->copyTo(one_data_size, { indexes, source, destination, queue });
195makeMutableMemoryView(
void* ptr,
Int32 datatype_size,
Int64 nb_element)
197 Span<std::byte> bytes(
reinterpret_cast<std::byte*
>(ptr), datatype_size * nb_element);
198 return { bytes, datatype_size, nb_element };
205makeConstMemoryView(
const void* ptr,
Int32 datatype_size,
Int64 nb_element)
207 Span<const std::byte> bytes(
reinterpret_cast<const std::byte*
>(ptr), datatype_size * nb_element);
208 return { bytes, datatype_size, nb_element };
217void MutableMultiMemoryView::
218copyFromIndexes(ConstMemoryView v, SmallSpan<const Int32> indexes,
221 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
223 Int64 nb_index = indexes.size();
227 _getDefaultCopyList(queue)->copyFrom(one_data_size, { indexes, m_views, v.bytes(), queue });
233void MutableMultiMemoryView::
234fillIndexes(ConstMemoryView v, SmallSpan<const Int32> indexes, RunQueue* queue)
236 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
238 Int64 nb_index = indexes.size();
242 _getDefaultCopyList(queue)->fill(one_data_size, { indexes, m_views, v.bytes(), queue });
248void MutableMultiMemoryView::
249fill(ConstMemoryView v, RunQueue* queue)
251 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
253 _getDefaultCopyList(queue)->fill(one_data_size, { {}, m_views, v.bytes(), queue });
259void ConstMultiMemoryView::
260copyToIndexes(MutableMemoryView v, SmallSpan<const Int32> indexes,
263 Int32 one_data_size = _checkDataTypeSize(A_FUNCINFO, m_datatype_size, v.datatypeSize());
265 Int64 nb_index = indexes.size();
269 _getDefaultCopyList(queue)->copyTo(one_data_size, { indexes, m_views, v.bytes(), queue });
275extern "C++" ARCANE_UTILS_EXPORT
void
276arcanePrintSpecificMemoryStats()
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
File d'exécution pour un accélérateur.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Interface d'une liste d'instances de ISpecificMemoryCopy spécialisées.
static void setDefaultCopyListIfNotSet(ISpecificMemoryCopyList *ptr)
Positionne l'instance par défaut pour les copies.
Interface d'un copieur mémoire spécialisé pour une taille de donnée.
Liste d'instances de ISpecificMemoryCopy spécialisées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
bool arcaneIsCheck()
Vrai si on est en mode vérification.
std::int64_t Int64
Type entier signé sur 64 bits.