Arcane  v4.1.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
core/RunCommandLaunchInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* RunCommandLaunchInfo.h (C) 2000-2025 */
9/* */
10/* Informations pour l'exécution d'une 'RunCommand'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ACCELERATOR_CORE_RUNCOMMANDLAUNCHINFO_H
13#define ARCANE_ACCELERATOR_CORE_RUNCOMMANDLAUNCHINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Profiling.h"
18#include "arccore/base/ForLoopRunInfo.h"
19
20#include "arcane/accelerator/core/KernelLaunchArgs.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Accelerator::impl
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
35class ARCANE_ACCELERATOR_CORE_EXPORT RunCommandLaunchInfo
36{
37 // Les fonctions suivantes permettent de lancer les kernels.
38 template <typename SyclKernel, typename Lambda, typename LambdaArgs, typename... ReducerArgs>
39 friend void _applyKernelSYCL(impl::RunCommandLaunchInfo& launch_info, SyclKernel kernel, Lambda& func,
40 const LambdaArgs& args, const ReducerArgs&... reducer_args);
41 template <typename CudaKernel, typename Lambda, typename LambdaArgs, typename... RemainingArgs>
42 friend void _applyKernelCUDA(impl::RunCommandLaunchInfo& launch_info, const CudaKernel& kernel, Lambda& func,
43 const LambdaArgs& args, [[maybe_unused]] const RemainingArgs&... other_args);
44 template <typename HipKernel, typename Lambda, typename LambdaArgs, typename... RemainingArgs>
45 friend void _applyKernelHIP(impl::RunCommandLaunchInfo& launch_info, const HipKernel& kernel, const Lambda& func,
46 const LambdaArgs& args, [[maybe_unused]] const RemainingArgs&... other_args);
47
48 public:
49
50 using ThreadBlockInfo = KernelLaunchArgs;
51
52 public:
53
54 RunCommandLaunchInfo(RunCommand& command, Int64 total_loop_size);
55 ~RunCommandLaunchInfo();
56 RunCommandLaunchInfo(const RunCommandLaunchInfo&) = delete;
57 RunCommandLaunchInfo operator=(const RunCommandLaunchInfo&) = delete;
58
59 public:
60
61 eExecutionPolicy executionPolicy() const { return m_exec_policy; }
62
69 void beginExecute();
70
77 void endExecute();
78
84 KernelLaunchArgs kernelLaunchArgs() const { return m_kernel_launch_args; }
85
87 ParallelLoopOptions computeParallelLoopOptions() const;
88
95 const ForLoopRunInfo& loopRunInfo() const { return m_loop_run_info; }
96
98 Int64 totalLoopSize() const { return m_total_loop_size; }
99
100 private:
101
102 RunCommand& m_command;
103 bool m_has_exec_begun = false;
104 bool m_is_notify_end_kernel_done = false;
106 KernelLaunchArgs m_kernel_launch_args;
107 ForLoopRunInfo m_loop_run_info;
108 Int64 m_total_loop_size = 0;
109 impl::RunQueueImpl* m_queue_impl = nullptr;
110
111 private:
112
113 Int32 _sharedMemorySize() const;
114 KernelLaunchArgs _threadBlockInfo(const void* func, Int32 shared_memory_size) const;
115 NativeStream _internalNativeStream();
116 void _doEndKernelLaunch();
117 KernelLaunchArgs _computeKernelLaunchArgs() const;
118
119 // Pour test uniquement avec CUDA
120 bool _isUseCooperativeLaunch() const;
121 bool _isUseCudaLaunchKernel() const;
122
123 private:
124
125 void _computeLoopRunInfo();
126
127 // Pour SYCL: enregistre l'évènement associé à la dernière commande de la file
128 // \a sycl_event_ptr est de type 'sycl::event*'.
129 void _addSyclEvent(void* sycl_event_ptr);
130};
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
135} // End namespace Arcane::Accelerator::impl
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140#endif
Gestion d'une commande sur accélérateur.
Arguments pour lancer un kernel.
Type opaque pour encapsuler une 'stream' native.
Object temporaire pour conserver les informations d'exécution d'une commande et regrouper les tests.
Int64 totalLoopSize() const
Taille totale de la boucle.
void beginExecute()
Indique qu'on commence l'exécution de la commande.
KernelLaunchArgs kernelLaunchArgs() const
Informations sur le nombre de block/thread/grille du noyau à lancer.
void endExecute()
Signale la fin de l'exécution.
friend void _applyKernelCUDA(impl::RunCommandLaunchInfo &launch_info, const CudaKernel &kernel, Lambda &func, const LambdaArgs &args, const RemainingArgs &... other_args)
Fonction générique pour exécuter un kernel CUDA.
const ForLoopRunInfo & loopRunInfo() const
Informations d'exécution de la boucle.
friend void _applyKernelHIP(impl::RunCommandLaunchInfo &launch_info, const HipKernel &kernel, const Lambda &func, const LambdaArgs &args, const RemainingArgs &... other_args)
Fonction générique pour exécuter un kernel HIP.
File d'exécution pour accélérateur.
Informations d'exécution d'une boucle.
Options d'exécution d'une boucle parallèle en multi-thread.
eExecutionPolicy
Politique d'exécution pour un Runner.
@ Sequential
Politique d'exécution séquentielle.
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.