14#include "arccore/common/accelerator/internal/RunCommandImpl.h"
15#include "arccore/common/accelerator/internal/AcceleratorCoreGlobalInternal.h"
17#include "arccore/base/FatalErrorException.h"
18#include "arccore/base/ForLoopTraceInfo.h"
19#include "arccore/base/PlatformUtils.h"
20#include "arccore/base/Convert.h"
21#include "arccore/base/ConcurrencyBase.h"
23#include "arccore/common/accelerator/Runner.h"
24#include "arccore/common/accelerator/internal/IRunQueueEventImpl.h"
25#include "arccore/common/accelerator/internal/IRunQueueStream.h"
26#include "arccore/common/accelerator/internal/IRunnerRuntime.h"
27#include "arccore/common/accelerator/internal/RunQueueImpl.h"
28#include "arccore/common/accelerator/internal/ReduceMemoryImpl.h"
29#include "arccore/common/accelerator/internal/RunnerImpl.h"
34namespace Arcane::Accelerator::Impl
43, m_execution_policy(queue->runner()->executionPolicy())
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();
103 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_ACCELERATOR_ALLOW_REUSE_COMMAND",
true))
104 m_is_allow_reuse_command = (v.value() != 0);
106 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_ACCELERATOR_NB_GRID_STRIDE",
true)) {
110 m_default_nb_stride = n;
118RunCommandImpl* RunCommandImpl::
119create(RunQueueImpl* r)
121 RunCommandImpl* c = r->_internalCreateOrGetRunCommandImpl();
132notifyBeginLaunchKernel()
136 ARCCORE_FATAL(
"Command has already been launched. You can not re-use the same command.\n"
137 " You can temporarily allow it if you set environment variable\n"
138 " ARCANE_ACCELERATOR_ALLOW_REUSE_COMMAND to 1\n");
147 m_loop_one_exec_stat_ptr = &m_loop_one_exec_stat;
160notifyEndLaunchKernel()
167 m_queue->_addRunningCommand(
this);
180notifyLaunchKernelSyclEvent(
void* sycl_event_ptr)
200notifyEndExecuteKernel()
206 Int64 diff_time_ns = 0;
209 runner()->addTime((
double)diff_time_ns / 1.0e9);
229 m_nb_thread_per_block = 0;
233 m_loop_one_exec_stat.reset();
234 m_loop_one_exec_stat_ptr =
nullptr;
235 m_has_been_launched =
false;
236 m_has_living_run_command =
false;
237 m_may_be_put_in_pool =
false;
238 m_shared_memory_size = 0;
239 m_nb_stride = m_default_nb_stride;
245IReduceMemoryImpl* RunCommandImpl::
246getOrCreateReduceMemoryImpl()
248 ReduceMemoryImpl* p = _getOrCreateReduceMemoryImpl();
250 m_active_reduce_memory_list.insert(p);
259releaseReduceMemoryImpl(ReduceMemoryImpl* p)
261 auto x = m_active_reduce_memory_list.find(p);
262 if (x == m_active_reduce_memory_list.end())
264 m_active_reduce_memory_list.erase(x);
265 m_reduce_memory_pool.push(p);
271IRunQueueStream* RunCommandImpl::
272internalStream()
const
274 return m_queue->_internalStream();
280RunnerImpl* RunCommandImpl::
283 return m_queue->runner();
289ReduceMemoryImpl* RunCommandImpl::
290_getOrCreateReduceMemoryImpl()
294 if (!m_use_accelerator)
297 auto& pool = m_reduce_memory_pool;
300 ReduceMemoryImpl* p = pool.top();
304 return new ReduceMemoryImpl(
this);
313_notifyDestroyRunCommand()
318 m_queue->_putInCommandPool(
this);
#define ARCCORE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'un flux d'exécution pour une RunQueue.
virtual void notifyEndLaunchKernel(RunCommandImpl &command)=0
Notification de fin de lancement de la commande.
virtual void _setSyclLastCommandEvent(void *sycl_event_ptr)
Pour SYCL, positionne l'évènement associé à la dernière commande exécutée.
virtual void notifyBeginLaunchKernel(RunCommandImpl &command)=0
Notification avant le lancement de la commande.
bool m_use_profiling
Indique si on souhaite le profiling.
bool m_may_be_put_in_pool
Indique si on peut remettre la commande dans le pool associé à la RunQueue.
bool m_is_allow_reuse_command
Indique si on autorise à utiliser plusieurs fois la même commande.
bool m_has_been_launched
Indique si la commande a été lancée.
IRunQueueEventImpl * m_start_event
Évènements pour le début et la fin de l'exécution.
Int64 m_begin_time
Temps au lancement de la commande.
IRunQueueEventImpl * m_stop_event
Évènements pour la fin de l'exécution.
File d'exécution pour accélérateur.
static const ParallelLoopOptions & defaultParallelLoopOptions()
Valeurs par défaut d'exécution d'une boucle parallèle.
Classe pour gérer le profiling d'une seule exécution d'une boucle.
void setEndTime(Int64 v)
Positionne le temps de fin de la boucle en nanoseconde.
Informations de trace pour une boucle 'for'.
static Impl::ForLoopStatInfoList * _threadLocalForLoopInstance()
static bool hasProfiling()
Indique si le profilage est actif.
Chaîne de caractères unicode.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.
std::int64_t Int64
Type entier signé sur 64 bits.