14#include "arcane/accelerator/core/internal/RunCommandImpl.h"
15#include "arcane/accelerator/core/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 "arcane/accelerator/core/Runner.h"
24#include "arcane/accelerator/core/internal/IRunQueueEventImpl.h"
25#include "arcane/accelerator/core/internal/IRunQueueStream.h"
26#include "arcane/accelerator/core/internal/IRunnerRuntime.h"
27#include "arcane/accelerator/core/internal/RunQueueImpl.h"
28#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
29#include "arcane/accelerator/core/internal/RunnerImpl.h"
34namespace Arcane::Accelerator::impl
65 while (!m_reduce_memory_pool.empty()) {
66 delete m_reduce_memory_pool.top();
67 m_reduce_memory_pool.pop();
74IRunQueueEventImpl* RunCommandImpl::
77 if (m_use_sequential_timer_event)
78 return getSequentialRunQueueRuntime()->createEventImplWithTimer();
79 return runner()->_createEventWithTimer();
96 if (m_use_accelerator && !ProfilingRegistry::hasProfiling())
97 m_use_sequential_timer_event =
true;
99 m_start_event = _createEvent();
100 m_stop_event = _createEvent();
102 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_ACCELERATOR_ALLOW_REUSE_COMMAND",
true))
103 m_is_allow_reuse_command = (v.value() != 0);
109RunCommandImpl* RunCommandImpl::
110create(RunQueueImpl* r)
112 RunCommandImpl* c = r->_internalCreateOrGetRunCommandImpl();
123notifyBeginLaunchKernel()
127 ARCANE_FATAL(
"Command has already been launched. You can not re-use the same command.\n"
128 " You can temporarily allow it if you set environment variable\n"
129 " ARCANE_ACCELERATOR_ALLOW_REUSE_COMMAND to 1\n");
138 m_loop_one_exec_stat_ptr = &m_loop_one_exec_stat;
151notifyEndLaunchKernel()
158 m_queue->_addRunningCommand(
this);
171notifyLaunchKernelSyclEvent(
void* sycl_event_ptr)
191notifyEndExecuteKernel()
197 Int64 diff_time_ns = 0;
200 runner()->addTime((
double)diff_time_ns / 1.0e9);
220 m_nb_thread_per_block = 0;
224 m_loop_one_exec_stat.reset();
225 m_loop_one_exec_stat_ptr =
nullptr;
226 m_has_been_launched =
false;
227 m_has_living_run_command =
false;
228 m_may_be_put_in_pool =
false;
234IReduceMemoryImpl* RunCommandImpl::
235getOrCreateReduceMemoryImpl()
237 ReduceMemoryImpl* p = _getOrCreateReduceMemoryImpl();
239 m_active_reduce_memory_list.insert(p);
248releaseReduceMemoryImpl(ReduceMemoryImpl* p)
250 auto x = m_active_reduce_memory_list.find(p);
251 if (x == m_active_reduce_memory_list.end())
253 m_active_reduce_memory_list.erase(x);
254 m_reduce_memory_pool.push(p);
260IRunQueueStream* RunCommandImpl::
261internalStream()
const
263 return m_queue->_internalStream();
269RunnerImpl* RunCommandImpl::
272 return m_queue->runner();
278ReduceMemoryImpl* RunCommandImpl::
279_getOrCreateReduceMemoryImpl()
283 if (!m_use_accelerator)
286 auto& pool = m_reduce_memory_pool;
289 ReduceMemoryImpl* p = pool.top();
293 return new ReduceMemoryImpl(
this);
302_notifyDestroyRunCommand()
307 m_queue->_putInCommandPool(
this);
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'un flux d'exécution pour une RunQueue.
virtual void notifyBeginLaunchKernel(impl::RunCommandImpl &command)=0
Notification avant le 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 notifyEndLaunchKernel(impl::RunCommandImpl &command)=0
Notification de fin de lancement de la commande.
IRunQueueEventImpl * m_stop_event
Évènements pour la fin de l'exécution.
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.
bool m_is_allow_reuse_command
Indique si on autorise à utiliser plusieurs fois la même commande.
Int64 m_begin_time
Temps au lancement de la commande.
bool m_may_be_put_in_pool
Indique si on peut remettre la commande dans le pool associé à la RunQueue.
bool m_use_profiling
Indique si on souhaite le profiling.
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.
std::int64_t Int64
Type entier signé sur 64 bits.