14#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
16#include "arcane/utils/CheckedConvert.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/IMemoryRessourceMng.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
43ReduceMemoryImpl(RunCommandImpl* p)
50 _allocateMemoryForReduceData(128);
51 _allocateMemoryForGridDeviceCount();
57void ReduceMemoryImpl::
60 m_command->releaseReduceMemoryImpl(
this);
66void ReduceMemoryImpl::
69 m_grid_memory_info.m_reduce_policy = m_command->runner()->reducePolicy();
75void* ReduceMemoryImpl::
88 m_command->internalStream()->copyMemory(
copy_args.addAsync());
90 return m_device_memory;
96void ReduceMemoryImpl::
97_allocateGridDataMemory()
101 Int32 total_size = CheckedConvert::toInt32(m_data_type_size * m_grid_size);
102 if (
total_size <= m_grid_memory_info.m_grid_memory_values.bytes().size())
107 auto mem_view = makeMutableMemoryView(m_grid_buffer.span());
108 m_grid_memory_info.m_grid_memory_values =
mem_view;
114void ReduceMemoryImpl::
115_allocateMemoryForGridDeviceCount()
119 Int64 size =
sizeof(
unsigned int);
120 const unsigned int zero = 0;
121 m_grid_device_count.resize(1);
122 auto*
ptr = m_grid_device_count.data();
124 m_grid_memory_info.m_grid_device_count =
ptr;
128 m_command->internalStream()->copyMemory(
copy_args);
134void ReduceMemoryImpl::
135copyReduceValueFromDevice()
137 void* destination = m_grid_memory_info.m_host_memory_for_reduced_value;
138 void* source = m_device_memory;
140 m_command->internalStream()->copyMemory(
copy_args);
147internalGetOrCreateReduceMemoryImpl(
RunCommand* command)
149 return command->m_p->getOrCreateReduceMemoryImpl();
Arguments pour la copie mémoire.
Gestion d'une commande sur accélérateur.
Interface de la gestion mémoire pour les réductions.
virtual IMemoryAllocator * getAllocator(eMemoryRessource r)=0
Allocateur mémoire pour la ressource r.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
eMemoryRessource
Liste des ressources mémoire disponibles.
@ HostPinned
Alloue sur l'hôte.
std::int32_t Int32
Type entier signé sur 32 bits.