14#include "arcane/accelerator/core/internal/RunCommandImpl.h"
15#include "arcane/accelerator/core/internal/AcceleratorCoreGlobalInternal.h"
17#include "arcane/utils/ForLoopTraceInfo.h"
19#include "arcane/utils/PlatformUtils.h"
21#include "arcane/accelerator/core/Runner.h"
22#include "arcane/accelerator/core/internal/IRunQueueEventImpl.h"
23#include "arcane/accelerator/core/internal/IRunQueueStream.h"
24#include "arcane/accelerator/core/internal/IRunnerRuntime.h"
25#include "arcane/accelerator/core/internal/RunQueueImpl.h"
26#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
27#include "arcane/accelerator/core/internal/RunnerImpl.h"
32namespace Arcane::Accelerator::impl
42RunCommandImpl(RunQueueImpl* queue)
66 while (!m_reduce_memory_pool.empty()) {
67 delete m_reduce_memory_pool.top();
68 m_reduce_memory_pool.pop();
75IRunQueueEventImpl* RunCommandImpl::
78 if (m_use_sequential_timer_event)
79 return getSequentialRunQueueRuntime()->createEventImplWithTimer();
80 return runner()->_createEventWithTimer();
97 if (m_use_accelerator && !ProfilingRegistry::hasProfiling())
98 m_use_sequential_timer_event =
true;
100 m_start_event = _createEvent();
101 m_stop_event = _createEvent();
107RunCommandImpl* RunCommandImpl::
108create(RunQueueImpl* r)
110 return r->_internalCreateOrGetRunCommandImpl();
119notifyBeginLaunchKernel()
121 IRunQueueStream* stream = internalStream();
122 stream->notifyBeginLaunchKernel(*
this);
124 m_start_event->recordQueue(stream);
125 m_has_been_launched =
true;
126 if (ProfilingRegistry::hasProfiling()) {
127 m_begin_time = platform::getRealTimeNS();
128 m_loop_one_exec_stat_ptr = &m_loop_one_exec_stat;
129 m_loop_one_exec_stat.setBeginTime(m_begin_time);
141notifyEndLaunchKernel()
143 IRunQueueStream* stream = internalStream();
145 m_stop_event->recordQueue(stream);
146 stream->notifyEndLaunchKernel(*
this);
159notifyLaunchKernelSyclEvent(
void* sycl_event_ptr)
161 IRunQueueStream* stream = internalStream();
162 stream->_setSyclLastCommandEvent(sycl_event_ptr);
166 m_start_event->recordQueue(stream);
179notifyEndExecuteKernel()
182 if (!m_has_been_launched)
185 Int64 diff_time_ns = m_stop_event->elapsedTime(m_start_event);
187 runner()->addTime((
double)diff_time_ns / 1.0e9);
189 ForLoopOneExecStat* exec_info = m_loop_one_exec_stat_ptr;
191 exec_info->setEndTime(m_begin_time + diff_time_ns);
193 ForLoopTraceInfo flti(traceInfo(), kernelName());
194 ProfilingRegistry::_threadLocalForLoopInstance()->merge(*exec_info, flti);
206 m_kernel_name = String();
207 m_trace_info = TraceInfo();
208 m_nb_thread_per_block = 0;
209 m_parallel_loop_options = TaskFactory::defaultParallelLoopOptions();
211 m_loop_one_exec_stat.reset();
212 m_loop_one_exec_stat_ptr =
nullptr;
213 m_has_been_launched =
false;
219IReduceMemoryImpl* RunCommandImpl::
220getOrCreateReduceMemoryImpl()
222 ReduceMemoryImpl* p = _getOrCreateReduceMemoryImpl();
224 m_active_reduce_memory_list.insert(p);
233releaseReduceMemoryImpl(ReduceMemoryImpl* p)
235 auto x = m_active_reduce_memory_list.find(p);
236 if (x == m_active_reduce_memory_list.end())
238 m_active_reduce_memory_list.erase(x);
239 m_reduce_memory_pool.push(p);
245IRunQueueStream* RunCommandImpl::
246internalStream()
const
248 return m_queue->_internalStream();
254RunnerImpl* RunCommandImpl::
257 return m_queue->runner();
263ReduceMemoryImpl* RunCommandImpl::
264_getOrCreateReduceMemoryImpl()
268 if (!m_use_accelerator)
271 auto& pool = m_reduce_memory_pool;
274 ReduceMemoryImpl* p = pool.top();
278 return new ReduceMemoryImpl(
this);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classes, Types et macros pour gérer la concurrence.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.