14#include "arccore/common/accelerator/RunCommandLaunchInfo.h"
16#include "KernelLaunchArgs.h"
17#include "arccore/base/FatalErrorException.h"
18#include "arccore/base/CheckedConvert.h"
19#include "arccore/base/ConcurrencyBase.h"
21#include "arccore/common/accelerator/RunCommand.h"
22#include "arccore/common/accelerator/NativeStream.h"
23#include "arccore/common/accelerator/internal/RunQueueImpl.h"
24#include "arccore/common/accelerator/internal/IRunnerRuntime.h"
29namespace Arcane::Accelerator::Impl
36RunCommandLaunchInfo(RunCommand& command,
Int64 total_loop_size)
38, m_total_loop_size(total_loop_size)
40 m_queue_impl = m_command._internalQueueImpl();
41 m_exec_policy = m_queue_impl->executionPolicy();
45 _computeInitialKernelLaunchArgs();
46 m_command._allocateReduceMemory(m_kernel_launch_args.nbBlockPerGrid());
54~RunCommandLaunchInfo()
64void RunCommandLaunchInfo::
68 ARCCORE_FATAL(
"beginExecute() has already been called");
69 m_has_exec_begun =
true;
70 m_command._internalNotifyBeginLaunchKernel();
72 _computeLoopRunInfo();
83void RunCommandLaunchInfo::
86 if (!m_has_exec_begun)
87 ARCCORE_FATAL(
"beginExecute() has to be called before endExecute()");
94void RunCommandLaunchInfo::
97 if (m_is_notify_end_kernel_done)
99 m_is_notify_end_kernel_done =
true;
100 m_command._internalNotifyEndLaunchKernel();
102 impl::RunQueueImpl* q = m_queue_impl;
104 q->_internalBarrier();
110NativeStream RunCommandLaunchInfo::
111_internalNativeStream()
113 return m_command._internalNativeStream();
122void RunCommandLaunchInfo::
123_computeInitialKernelLaunchArgs()
125 int threads_per_block = m_command.nbThreadPerBlock();
126 if (threads_per_block<=0)
127 threads_per_block = 256;
128 Int64 big_b = (m_total_loop_size + threads_per_block - 1) / threads_per_block;
129 int blocks_per_grid = CheckedConvert::toInt32(big_b);
130 m_kernel_launch_args = KernelLaunchArgs(blocks_per_grid, threads_per_block, m_command._sharedMemory());
137computeParallelLoopOptions()
const
140 const bool use_dynamic_compute =
true;
144 if (use_dynamic_compute && opt.
grainSize() == 0) {
150 Int32 grain_size =
static_cast<Int32>((double)m_total_loop_size / (nb_thread * 2.0));
163void RunCommandLaunchInfo::
167 m_loop_run_info =
ForLoopRunInfo(computeParallelLoopOptions(), lti);
168 m_loop_run_info.setExecStat(m_command._internalCommandExecStat());
182KernelLaunchArgs RunCommandLaunchInfo::
183_computeKernelLaunchArgs(
const void* func)
const
185 impl::IRunnerRuntime* r = m_queue_impl->_internalRuntime();
187 return r->computeKernalLaunchArgs(m_kernel_launch_args, func,
194void RunCommandLaunchInfo::
195_addSyclEvent(
void* sycl_event_ptr)
197 m_command._internalNotifyBeginLaunchKernelSyclEvent(sycl_event_ptr);
203bool RunCommandLaunchInfo::
204_isUseCooperativeLaunch()
const
212bool RunCommandLaunchInfo::
213_isUseCudaLaunchKernel()
const
static Int32 maxAllowedThread()
Nombre maximum de threads autorisés pour le multi-threading.
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.
@ Thread
Politique d'exécution multi-thread.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indique si exec_policy correspond à un accélérateur.
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.