14#include "arcane/accelerator/core/internal/RunQueueImpl.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/MemoryUtils.h"
19#include "arcane/accelerator/core/internal/IRunnerRuntime.h"
20#include "arcane/accelerator/core/internal/IRunQueueStream.h"
21#include "arcane/accelerator/core/internal/RunCommandImpl.h"
22#include "arcane/accelerator/core/internal/RunnerImpl.h"
23#include "arcane/accelerator/core/internal/IRunQueueEventImpl.h"
24#include "arcane/accelerator/core/Runner.h"
25#include "arcane/accelerator/core/RunQueueBuildInfo.h"
26#include "arcane/accelerator/core/DeviceId.h"
27#include "arcane/accelerator/core/RunQueueEvent.h"
32namespace Arcane::Accelerator::impl
39RunQueueImpl(RunnerImpl* runner_impl, Int32
id,
const RunQueueBuildInfo& bi)
40: m_runner_impl(runner_impl)
41, m_execution_policy(runner_impl->executionPolicy())
42, m_runtime(runner_impl->runtime())
43, m_queue_stream(m_runtime->createStream(bi))
54 while (!m_run_command_pool.empty()) {
55 RunCommand::_internalDestroyImpl(m_run_command_pool.top());
56 m_run_command_pool.pop();
58 delete m_queue_stream;
75 if (!m_active_run_command_list.empty()) {
76 if (!_internalStream()->_barrierNoException()) {
77 _internalFreeRunningCommands();
80 std::cerr <<
"WARNING: Error in internal accelerator barrier\n";
83 m_runner_impl->_internalPutRunQueueImplInPool(
this);
93_setDefaultMemoryRessource()
95 m_memory_ressource = eMemoryRessource::Host;
97 m_memory_ressource = eMemoryRessource::UnifiedMemory;
103MemoryAllocationOptions RunQueueImpl::
104allocationOptions()
const
106 MemoryAllocationOptions opt = MemoryUtils::getAllocationOptions(m_memory_ressource);
107 Int16 device_id =
static_cast<Int16
>(m_runner_impl->deviceId().asInt32());
108 opt.setDevice(device_id);
116isAutoPrefetchCommand()
const
118 return m_runner_impl->isAutoPrefetchCommand();
125copyMemory(
const MemoryCopyArgs& args)
const
127 _internalStream()->copyMemory(args);
134prefetchMemory(
const MemoryPrefetchArgs& args)
const
136 _internalStream()->prefetchMemory(args);
143recordEvent(RunQueueEvent& event)
145 auto* p =
event._internalEventImpl();
146 return p->recordQueue(_internalStream());
153waitEvent(RunQueueEvent& event)
155 auto* p =
event._internalEventImpl();
156 return p->waitForEvent(_internalStream());
162RunQueueImpl* RunQueueImpl::
165 return _reset(r->_internalCreateOrGetRunQueueImpl());
171RunQueueImpl* RunQueueImpl::
172create(RunnerImpl* r,
const RunQueueBuildInfo& bi)
174 return _reset(r->_internalCreateOrGetRunQueueImpl(bi));
180RunCommandImpl* RunQueueImpl::
181_internalCreateOrGetRunCommandImpl()
183 auto& pool = m_run_command_pool;
184 RunCommandImpl* p =
nullptr;
192 p = RunCommand::_internalCreateImpl(
this);
194 m_active_run_command_list.add(p);
207_internalFreeRunningCommands()
209 for (RunCommandImpl* p : m_active_run_command_list) {
210 p->notifyEndExecuteKernel();
211 m_run_command_pool.push(p);
213 m_active_run_command_list.clear();
224 _internalStream()->barrier();
225 _internalFreeRunningCommands();
237RunQueueImpl* RunQueueImpl::
238_reset(RunQueueImpl* p)
240 p->m_is_async =
false;
241 p->_setDefaultMemoryRessource();
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.