14#include "arcane/accelerator/core/RunCommandLaunchInfo.h"
16#include "arcane/utils/CheckedConvert.h"
18#include "arcane/accelerator/core/RunCommand.h"
19#include "arcane/accelerator/core/internal/RunQueueImpl.h"
20#include "arcane/accelerator/core/NativeStream.h"
21#include "arcane/accelerator/core/internal/IRunnerRuntime.h"
26namespace Arcane::Accelerator::impl
33RunCommandLaunchInfo(RunCommand& command,
Int64 total_loop_size)
35, m_total_loop_size(total_loop_size)
37 m_queue_impl = m_command._internalQueueImpl();
38 m_exec_policy = m_queue_impl->executionPolicy();
42 m_kernel_launch_args = _computeKernelLaunchArgs();
43 m_command._allocateReduceMemory(m_kernel_launch_args.nbBlockPerGrid());
51~RunCommandLaunchInfo()
61void RunCommandLaunchInfo::
66 m_has_exec_begun =
true;
67 m_command._internalNotifyBeginLaunchKernel();
80void RunCommandLaunchInfo::
83 if (!m_has_exec_begun)
84 ARCANE_FATAL(
"beginExecute() has to be called before endExecute()");
91void RunCommandLaunchInfo::
94 if (m_is_notify_end_kernel_done)
96 m_is_notify_end_kernel_done =
true;
97 m_command._internalNotifyEndLaunchKernel();
107NativeStream RunCommandLaunchInfo::
108_internalNativeStream()
110 return m_command._internalNativeStream();
119_computeKernelLaunchArgs()
const
121 int threads_per_block = m_command.nbThreadPerBlock();
122 if (threads_per_block<=0)
123 threads_per_block = 256;
124 Int64 big_b = (m_total_loop_size + threads_per_block - 1) / threads_per_block;
126 return { blocks_per_grid, threads_per_block };
133computeParallelLoopOptions()
const
136 const bool use_dynamic_compute =
true;
140 if (use_dynamic_compute && opt.
grainSize() == 0) {
146 Int32 grain_size =
static_cast<Int32>((double)m_total_loop_size / (nb_thread * 2.0));
159void RunCommandLaunchInfo::
164 m_loop_run_info.setExecStat(m_command._internalCommandExecStat());
179_threadBlockInfo(
const void* func,
Int32 shared_memory_size)
const
181 return m_queue_impl->_internalRuntime()->computeKernalLaunchArgs(m_kernel_launch_args, func,
totalLoopSize(), shared_memory_size);
187void RunCommandLaunchInfo::
188_addSyclEvent(
void* sycl_event_ptr)
190 m_command._internalNotifyBeginLaunchKernelSyclEvent(sycl_event_ptr);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Arguments pour lancer un kernel.
Int64 totalLoopSize() const
Taille totale de la boucle.
ParallelLoopOptions computeParallelLoopOptions() const
Calcule et retourne les informations pour les boucles multi-thread.
void _computeLoopRunInfo()
Calcule la valeur de m_loop_run_info.
File d'exécution pour accélérateur.
void _internalBarrier()
Bloque jusqu'à ce que toutes les commandes soient terminées.
Informations d'exécution d'une boucle.
Informations de trace pour une boucle 'for'.
Options d'exécution d'une boucle parallèle en multi-thread.
Integer grainSize() const
Taille d'un intervalle d'itération.
Int32 maxThread() const
Nombre maximal de threads autorisés.
void setGrainSize(Integer v)
Positionne la taille (approximative) d'un intervalle d'itération.
static Int32 nbAllowedThread()
Nombre de threads utilisés au maximum pour gérer les tâches.
@ Thread
Politique d'exécution multi-thread.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.