14#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
16#include "arcane/utils/CheckedConvert.h"
17#include "arcane/utils/PlatformUtils.h"
20#include "arcane/accelerator/core/Runner.h"
21#include "arcane/accelerator/core/Memory.h"
22#include "arcane/accelerator/core/internal/IRunQueueStream.h"
23#include "arcane/accelerator/core/internal/RunCommandImpl.h"
24#include "arcane/accelerator/core/internal/RunnerImpl.h"
29namespace Arcane::Accelerator::impl
50 _allocateMemoryForReduceData(128);
51 _allocateMemoryForGridDeviceCount();
52 m_grid_memory_info.m_warp_size = p->runner()->deviceInfo().warpSize();
58void ReduceMemoryImpl::
61 m_command->releaseReduceMemoryImpl(
this);
67void* ReduceMemoryImpl::
70 auto identity_span = identity_view.
bytes();
71 Int32 data_type_size =
static_cast<Int32>(identity_span.size());
73 if (data_type_size >
m_size)
74 _allocateMemoryForReduceData(data_type_size);
80 m_command->internalStream()->copyMemory(copy_args.addAsync());
88void ReduceMemoryImpl::
89_allocateGridDataMemory()
94 if (total_size <= m_grid_memory_info.m_grid_memory_values.bytes().size())
97 m_grid_buffer.resize(total_size);
100 m_grid_memory_info.m_grid_memory_values = mem_view;
106void ReduceMemoryImpl::
107_allocateMemoryForGridDeviceCount()
111 Int64 size =
sizeof(
unsigned int);
112 const unsigned int zero = 0;
113 m_grid_device_count.resize(1);
114 auto* ptr = m_grid_device_count.data();
116 m_grid_memory_info.m_grid_device_count = ptr;
120 m_command->internalStream()->copyMemory(copy_args);
126void ReduceMemoryImpl::
127copyReduceValueFromDevice()
129 void* destination = m_grid_memory_info.m_host_memory_for_reduced_value;
132 m_command->internalStream()->copyMemory(copy_args);
139internalGetOrCreateReduceMemoryImpl(
RunCommand* command)
141 return command->m_p->getOrCreateReduceMemoryImpl();
Fonctions de gestion mémoire et des allocateurs.
Arguments pour la copie mémoire.
Gestion d'une commande sur accélérateur.
Interface de la gestion mémoire pour les réductions.
std::byte * m_device_memory
Pointeur vers la mémoire unifiée contenant la donnée réduite.
Int64 m_data_type_size
Taille de la donnée actuelle.
UniqueArray< std::byte > m_identity_buffer
Buffer pour conserver la valeur de l'identité
Int64 m_size
Taille allouée pour m_device_memory.
Implémentation d'une commande pour accélérateur.
Vue constante sur une zone mémoire contigue contenant des éléments de taille fixe.
constexpr SpanType bytes() const
Vue sous forme d'octets.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
IMemoryAllocator * getAllocator(eMemoryResource mem_resource)
Allocateur par défaut pour la ressource mem_resource.
MutableMemoryView makeMutableMemoryView(void *ptr, Int32 datatype_size, Int64 nb_element)
Créé une vue mémoire modifiable.
std::int64_t Int64
Type entier signé sur 64 bits.
Arcane::eMemoryResource eMemoryRessource
Typedef pour la version Arcane historique (avec 2's')
@ HostPinned
Alloue sur l'hôte.
std::int32_t Int32
Type entier signé sur 32 bits.