14#include "arccore/common/accelerator/internal/ReduceMemoryImpl.h"
16#include "arccore/base/CheckedConvert.h"
17#include "arccore/base/PlatformUtils.h"
20#include "arccore/common/accelerator/Runner.h"
21#include "arccore/common/accelerator/Memory.h"
22#include "arccore/common/accelerator/internal/IRunQueueStream.h"
23#include "arccore/common/accelerator/internal/RunCommandImpl.h"
24#include "arccore/common/accelerator/internal/RunnerImpl.h"
29namespace Arcane::Accelerator::Impl
49 _allocateMemoryForReduceData(128);
50 _allocateMemoryForGridDeviceCount();
51 m_grid_memory_info.m_warp_size = p->runner()->deviceInfo().warpSize();
57void ReduceMemoryImpl::
60 m_command->releaseReduceMemoryImpl(
this);
66void ReduceMemoryImpl::
67allocateReduceDataMemory(
Int32 data_type_size)
70 if (data_type_size >
m_size)
71 _allocateMemoryForReduceData(data_type_size);
77void ReduceMemoryImpl::
78_allocateMemoryForReduceData(
Int32 new_size)
80 m_host_memory_bytes.resize(new_size);
81 m_grid_memory_info.m_host_memory_for_reduced_value = m_host_memory_bytes.data();
89void ReduceMemoryImpl::
90_allocateGridDataMemory()
94 Int32 total_size = CheckedConvert::toInt32(m_data_type_size * m_grid_size);
95 if (total_size <= m_grid_memory_info.m_grid_memory_values.bytes().size())
98 m_grid_buffer.resize(total_size);
101 m_grid_memory_info.m_grid_memory_values = mem_view;
107void ReduceMemoryImpl::
108_allocateMemoryForGridDeviceCount()
112 Int64 size =
sizeof(
unsigned int);
113 const unsigned int zero = 0;
114 m_grid_device_count.resize(1);
115 auto* ptr = m_grid_device_count.data();
117 m_grid_memory_info.m_grid_device_count = ptr;
121 m_command->internalStream()->copyMemory(copy_args);
127extern "C++" IReduceMemoryImpl*
128internalGetOrCreateReduceMemoryImpl(RunCommand* command)
130 return command->m_p->getOrCreateReduceMemoryImpl();
Fonctions utilitaires de gestion mémoire.
Int64 m_size
Taille allouée pour m_device_memory.
Int64 m_data_type_size
Taille de la donnée actuelle.
Implémentation d'une commande pour accélérateur.
Arguments pour la copie mémoire.
ARCCORE_COMMON_EXPORT IMemoryAllocator * getAllocator(eMemoryResource mem_resource)
Allocateur par défaut pour la ressource mem_resource.
std::int64_t Int64
Type entier signé sur 64 bits.
MutableMemoryView makeMutableMemoryView(void *ptr, Int32 datatype_size, Int64 nb_element)
Créé une vue mémoire modifiable.
eMemoryResource
Liste des ressources mémoire disponibles.
@ HostPinned
Alloue sur l'hôte.
std::int32_t Int32
Type entier signé sur 32 bits.