Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
RunCommand.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* RunCommand.cc (C) 2000-2024 */
9/* */
10/* Gestion d'une commande sur accélérateur. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/accelerator/core/RunCommand.h"
15
16#include "arcane/accelerator/core/RunQueue.h"
17#include "arcane/accelerator/core/NativeStream.h"
18#include "arcane/accelerator/core/internal/RunQueueImpl.h"
19#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
20#include "arcane/accelerator/core/internal/RunCommandImpl.h"
21#include "arcane/accelerator/core/internal/IRunQueueStream.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Accelerator
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32RunCommand::
33RunCommand(const RunQueue& run_queue)
34: m_p(run_queue._getCommandImpl())
35{
36 m_p->m_has_living_run_command = true;
37}
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42RunCommand::
43~RunCommand()
44{
45 m_p->m_has_living_run_command = false;
46 m_p->_notifyDestroyRunCommand();
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55const TraceInfo& RunCommand::
56traceInfo() const
57{
58 return m_p->traceInfo();
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64const String& RunCommand::
65kernelName() const
66{
67 return m_p->kernelName();
68}
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73Int32 RunCommand::
74nbThreadPerBlock() const
75{
76 return m_p->m_nb_thread_per_block;
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82RunCommand& RunCommand::
83addTraceInfo(const TraceInfo& ti)
84{
85 m_p->m_trace_info = ti;
86 return *this;
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92RunCommand& RunCommand::
93addKernelName(const String& v)
94{
95 m_p->m_kernel_name = v;
96 return *this;
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102RunCommand& RunCommand::
103addNbThreadPerBlock(Int32 v)
104{
105 if (v < 0)
106 v = 0;
107 if (v > 0 && v < 32)
108 v = 32;
109 m_p->m_nb_thread_per_block = v;
110 return *this;
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116void RunCommand::
117setParallelLoopOptions(const ParallelLoopOptions& opt)
118{
119 m_p->m_parallel_loop_options = opt;
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125const ParallelLoopOptions& RunCommand::
126parallelLoopOptions() const
127{
128 return m_p->m_parallel_loop_options;
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134extern "C++" ARCANE_ACCELERATOR_CORE_EXPORT
137{
138 return command.addTraceInfo(trace_info);
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144impl::NativeStream RunCommand::
145_internalNativeStream() const
146{
147 return m_p->internalStream()->nativeStream();
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
154_internalQueueImpl() const
155{
156 return m_p->m_queue;
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162impl::RunCommandImpl* RunCommand::
163_internalCreateImpl(impl::RunQueueImpl* queue)
164{
165 return new impl::RunCommandImpl(queue);
166}
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171void RunCommand::
172_internalDestroyImpl(impl::RunCommandImpl* p)
173{
174 delete p;
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180void RunCommand::
181_allocateReduceMemory(Int32 nb_grid)
182{
183 auto& mem_list = m_p->m_active_reduce_memory_list;
184 if (!mem_list.empty()) {
185 for (auto& x : mem_list)
186 x->setGridSizeAndAllocate(nb_grid);
187 }
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193void RunCommand::
194_internalNotifyBeginLaunchKernel()
195{
196 m_p->notifyBeginLaunchKernel();
197}
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
202void RunCommand::
203_internalNotifyEndLaunchKernel()
204{
205 m_p->notifyEndLaunchKernel();
206}
207
208/*---------------------------------------------------------------------------*/
209/*---------------------------------------------------------------------------*/
210
211void RunCommand::
212_internalNotifyBeginLaunchKernelSyclEvent(void* sycl_event_ptr)
213{
214 m_p->notifyLaunchKernelSyclEvent(sycl_event_ptr);
215}
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
219
220ForLoopOneExecStat* RunCommand::
221_internalCommandExecStat()
222{
223 return m_p->m_loop_one_exec_stat_ptr;
224}
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229} // namespace Arcane::Accelerator
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
Gestion d'une commande sur accélérateur.
RunCommand & addTraceInfo(const TraceInfo &ti)
Positionne le informations de trace.
Definition RunCommand.cc:83
Type opaque pour encapsuler une 'stream' native.
Implémentation d'une commande pour accélérateur.
File d'exécution pour accélérateur.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Options d'exécution d'une boucle parallèle en multi-thread.
Chaîne de caractères unicode.
Espace de nom pour l'utilisation des accélérateurs.