Arcane  v3.14.10.0
Documentation utilisateur
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/internal/RunQueueImpl.h"
18#include "arcane/accelerator/core/internal/ReduceMemoryImpl.h"
19#include "arcane/accelerator/core/internal/RunCommandImpl.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Accelerator
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30RunCommand::
31RunCommand(const RunQueue& run_queue)
32: m_p(run_queue._getCommandImpl())
33{
34}
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39RunCommand::
40~RunCommand()
41{
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50const TraceInfo& RunCommand::
51traceInfo() const
52{
53 return m_p->traceInfo();
54}
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59const String& RunCommand::
60kernelName() const
61{
62 return m_p->kernelName();
63}
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68Int32 RunCommand::
69nbThreadPerBlock() const
70{
71 return m_p->m_nb_thread_per_block;
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77RunCommand& RunCommand::
78addTraceInfo(const TraceInfo& ti)
79{
80 m_p->m_trace_info = ti;
81 return *this;
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87RunCommand& RunCommand::
88addKernelName(const String& v)
89{
90 m_p->m_kernel_name = v;
91 return *this;
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97RunCommand& RunCommand::
98addNbThreadPerBlock(Int32 v)
99{
100 if (v < 0)
101 v = 0;
102 if (v > 0 && v < 32)
103 v = 32;
104 m_p->m_nb_thread_per_block = v;
105 return *this;
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111void RunCommand::
112setParallelLoopOptions(const ParallelLoopOptions& opt)
113{
114 m_p->m_parallel_loop_options = opt;
115}
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120const ParallelLoopOptions& RunCommand::
121parallelLoopOptions() const
122{
123 return m_p->m_parallel_loop_options;
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129extern "C++" ARCANE_ACCELERATOR_CORE_EXPORT
131operator<<(RunCommand& command, const TraceInfo& trace_info)
132{
133 return command.addTraceInfo(trace_info);
134}
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139RunQueue RunCommand::
140_internalQueue() const
141{
142 return RunQueue(m_p->m_queue);
143}
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148impl::RunQueueImpl* RunCommand::
149_internalQueueImpl() const
150{
151 return m_p->m_queue;
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157impl::RunCommandImpl* RunCommand::
158_internalCreateImpl(impl::RunQueueImpl* queue)
159{
160 return new impl::RunCommandImpl(queue);
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166void RunCommand::
167_internalDestroyImpl(impl::RunCommandImpl* p)
168{
169 delete p;
170}
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175void RunCommand::
176_allocateReduceMemory(Int32 nb_grid)
177{
178 auto& mem_list = m_p->m_active_reduce_memory_list;
179 if (!mem_list.empty()) {
180 for (auto& x : mem_list)
181 x->setGridSizeAndAllocate(nb_grid);
182 }
183}
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188void RunCommand::
189_internalNotifyBeginLaunchKernel()
190{
191 m_p->notifyBeginLaunchKernel();
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197void RunCommand::
198_internalNotifyEndLaunchKernel()
199{
200 m_p->notifyEndLaunchKernel();
201}
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
206void RunCommand::
207_internalNotifyBeginLaunchKernelSyclEvent(void* sycl_event_ptr)
208{
209 m_p->notifyLaunchKernelSyclEvent(sycl_event_ptr);
210}
211
212/*---------------------------------------------------------------------------*/
213/*---------------------------------------------------------------------------*/
214
215ForLoopOneExecStat* RunCommand::
216_internalCommandExecStat()
217{
218 return m_p->m_loop_one_exec_stat_ptr;
219}
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223
224} // namespace Arcane::Accelerator
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
Gestion d'une commande sur accélérateur.
RunCommand & addTraceInfo(const TraceInfo &ti)
Positionne le informations de trace.
Definition RunCommand.cc:78
File d'exécution pour un accélérateur.
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.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.