Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
RunCommandMaterialEnumerate.h
Aller à la documentation de ce fichier.
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/* RunCommandMaterialEnumerate.h (C) 2000-2025 */
9/* */
10/* Exécution d'une boucle sur une liste de constituants. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ACCELERATOR_RUNCOMMANDMATERIALENUMERATE_H
13#define ARCANE_ACCELERATOR_RUNCOMMANDMATERIALENUMERATE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/core/materials/ComponentItemVectorView.h"
19#include "arcane/core/materials/MaterialsCoreGlobal.h"
20#include "arcane/core/materials/MatItem.h"
22
23#include "arcane/accelerator/KernelLauncher.h"
24#include "arcane/accelerator/RunCommand.h"
25#include "arcane/accelerator/RunCommandLaunchInfo.h"
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane::Materials
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35/*!
36 * \brief Index d'une boucle accélérateur sur les matériaux ou milieux.
37 *
38 * Cette classe permet de récupérer un EnvItemLocalId (pour un milieu) ou
39 * un MatItemLocalId (pour un matériau) ainsi que le CellLocalId de la maille
40 * globale associée.
41 */
42template <typename ConstituentItemLocalIdType_>
43class ConstituentAndGlobalCellIteratorValue
44{
45 public:
46
47 using ConstituentItemLocalIdType = ConstituentItemLocalIdType_;
48 using ComponentItemLocalId = Arcane::Materials::ComponentItemLocalId;
49 using MatVarIndex = Arcane::Materials::MatVarIndex;
50
51 public:
52
53 //! Struct interne simple pour éviter l'usage d'un std::tuple pour l'opérateur()
54 struct Data
55 {
56 public:
57
58 constexpr ARCCORE_HOST_DEVICE Data(ConstituentItemLocalIdType mvi, CellLocalId cid)
59 : m_mvi(mvi)
60 , m_cid(cid)
61 {}
62
63 public:
64
65 ConstituentItemLocalIdType m_mvi;
66 CellLocalId m_cid;
67 };
68
69 public:
70
71 constexpr ARCCORE_HOST_DEVICE ConstituentAndGlobalCellIteratorValue(ConstituentItemLocalIdType mvi, CellLocalId cid, Int32 index)
72 : m_internal_data{ mvi, cid }
73 , m_index(index)
74 {
75 }
76
77 /*!
78 * \brief Cet opérateur permet de renvoyer le couple [ConstituentItemLocalIdType, CellLocalId].
79 *
80 * L'utilisation classique est :
81 *
82 * \code
83 * // Pour un milieu \a envcellsv
84 * // evi est de type EnvItemLocalId
85 * cmd << RUNCOMMAND_MAT_ENUMERATE(EnvAndGlobalCell, iter, envcellsv) {
86 * auto [evi, cid] = iter();
87 * }
88 * // Pour un matériau \a matcellsv
89 * // mvi est de type MatItemLocalId
90 * cmd << RUNCOMMAND_MAT_ENUMERATE(MatAndGlobalCell, iter, matcellsv) {
91 * auto [mvi, cid] = iter();
92 * }
93 * \endcode
94 */
95 constexpr ARCCORE_HOST_DEVICE Data operator()()
96 {
97 return m_internal_data;
98 }
99
100 //! Accesseur sur la partie MatVarIndex
101 constexpr ARCCORE_HOST_DEVICE ConstituentItemLocalIdType varIndex() const { return m_internal_data.m_mvi; };
102
103 //! Accesseur sur la partie cell local id
104 constexpr ARCCORE_HOST_DEVICE CellLocalId globalCellId() const { return m_internal_data.m_cid; }
105
106 //! Index de l'itération courante
107 constexpr ARCCORE_HOST_DEVICE Int32 index() const { return m_index; }
108
109 private:
110
111 Data m_internal_data;
112 Int32 m_index = -1;
113};
114
115//! Type de la valeur de l'itérateur pour RUNCOMMAND_MAT_ENUMERATE(EnvAndGlobalCell,...)
117
118//! Type de la valeur de l'itérateur pour RUNCOMMAND_MAT_ENUMERATE(MatAndGlobalCell,...)
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124} // namespace Arcane::Materials
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129namespace Arcane::Accelerator::impl
130{
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134/*!
135 * \brief Commande pour itérer sur les AllEnvCell.
136 */
137class AllEnvCellRunCommand
138{
139 using AllEnvCellVectorView = Arcane::Materials::AllEnvCellVectorView;
140
141 public:
142
143 using IteratorValueType = Arcane::Materials::AllEnvCell;
144 using ContainerCreateViewType = AllEnvCellVectorView;
145
146 public:
147
148 /*!
149 * \brief Conteneur contenant les informations nécessaires pour la commande.
150 */
151 class Container
152 {
153 public:
154
155 explicit Container(ContainerCreateViewType view)
156 : m_view(view)
157 {
158 }
159
160 public:
161 public:
162
163 constexpr ARCCORE_HOST_DEVICE Int32 size() const { return m_view.size(); }
164
165 //! Accesseur pour le i-ème élément de la liste
166 ARCCORE_HOST_DEVICE IteratorValueType operator[](Int32 i) const
167 {
168 return m_view[i];
169 }
170
171 private:
172
173 AllEnvCellVectorView m_view;
174 };
175
176 public:
177
178 static AllEnvCellRunCommand create(RunCommand& run_command, const Container& items)
179 {
180 return AllEnvCellRunCommand(run_command, items);
181 }
182
183 private:
184
185 // Uniquement appelable depuis 'Container'
186 explicit AllEnvCellRunCommand(RunCommand& command, const Container& items)
187 : m_command(command)
188 , m_items(items)
189 {
190 }
191
192 public:
193
194 RunCommand& m_command;
195 Container m_items;
196};
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201class ConstituentCommandContainerBase
202{
203 protected:
204
205 using ComponentItemVectorView = Arcane::Materials::ComponentItemVectorView;
206 using ComponentItemLocalId = Arcane::Materials::ComponentItemLocalId;
207 using MatVarIndex = Arcane::Materials::MatVarIndex;
208
209 protected:
210
211 explicit ConstituentCommandContainerBase(ComponentItemVectorView view)
212 : m_items(view)
213 {
214 m_nb_item = m_items.nbItem();
215 m_matvar_indexes = m_items._matvarIndexes();
216 m_global_cells_local_id = m_items._internalLocalIds();
217 }
218
219 public:
220
221 constexpr ARCCORE_HOST_DEVICE Int32 size() const { return m_nb_item; }
222
223 protected:
224
225 ComponentItemVectorView m_items;
226 SmallSpan<const MatVarIndex> m_matvar_indexes;
227 SmallSpan<const Int32> m_global_cells_local_id;
228 Int32 m_nb_item = 0;
229};
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233/*!
234 * \brief Commande pour itérer sur les EnvCell ou MatCell.
235 */
236template <typename ConstituentItemLocalIdType_, typename ContainerCreateViewType_>
237class ConstituentRunCommandBase
238{
239 public:
240
241 using ThatClass = ConstituentRunCommandBase<ConstituentItemLocalIdType_, ContainerCreateViewType_>;
242 using CommandType = ThatClass;
243 using IteratorValueType = ConstituentItemLocalIdType_;
244 using ContainerCreateViewType = ContainerCreateViewType_;
245
246 public:
247
248 /*!
249 * \brief Conteneur contenant les informations nécessaires pour la commande.
250 */
251 class Container
253 {
254 public:
255
256 explicit Container(ContainerCreateViewType view)
258 {
259 }
260
261 public:
262
263 //! Accesseur pour le i-ème élément de la liste
264 constexpr ARCCORE_HOST_DEVICE IteratorValueType operator[](Int32 i) const
265 {
266 return { ComponentItemLocalId(m_matvar_indexes[i]) };
267 }
268 };
269
270 public:
271
272 static CommandType create(RunCommand& run_command, const Container& items)
273 {
274 return CommandType(run_command, items);
275 }
276
277 private:
278
279 // Uniquement appelable depuis 'Container'
280 explicit ConstituentRunCommandBase(RunCommand& command, const Container& items)
281 : m_command(command)
282 , m_items(items)
283 {
284 }
285
286 public:
287
288 RunCommand& m_command;
289 Container m_items;
290};
291
292using EnvCellRunCommand = ConstituentRunCommandBase<Arcane::Materials::EnvItemLocalId, Arcane::Materials::EnvCellVectorView>;
293using MatCellRunCommand = ConstituentRunCommandBase<Arcane::Materials::MatItemLocalId, Arcane::Materials::MatCellVectorView>;
294
295/*---------------------------------------------------------------------------*/
296/*---------------------------------------------------------------------------*/
297/*!
298 * \brief Classe pour les commandes MatAndGlobalCell et EnvAndGlobalCell.
299 */
300template <typename ConstituentItemLocalIdType_, typename ContainerCreateViewType_>
301class ConstituentAndGlobalCellRunCommandBase
302{
303 public:
304
305 using ThatClass = ConstituentAndGlobalCellRunCommandBase<ConstituentItemLocalIdType_, ContainerCreateViewType_>;
306 using CommandType = ThatClass;
308 using ContainerCreateViewType = ContainerCreateViewType_;
309
310 public:
311
312 /*!
313 * \brief Conteneur contenant les informations nécessaires pour la commande.
314 */
315 class Container
317 {
318 public:
319
320 explicit Container(ContainerCreateViewType view)
322 {
323 }
324
325 public:
326
327 //! Accesseur pour le i-ème élément de la liste
328 constexpr ARCCORE_HOST_DEVICE IteratorValueType operator[](Int32 i) const
329 {
330 return { ComponentItemLocalId(m_matvar_indexes[i]), CellLocalId(m_global_cells_local_id[i]), i };
331 }
332 };
333
334 public:
335
336 static CommandType create(RunCommand& run_command, const Container& items)
337 {
338 return CommandType(run_command, items);
339 }
340
341 private:
342
343 // Uniquement appelable depuis 'Container'
344 explicit ConstituentAndGlobalCellRunCommandBase(RunCommand& command, const Container& items)
345 : m_command(command)
346 , m_items(items)
347 {
348 }
349
350 public:
351
352 RunCommand& m_command;
353 Container m_items;
354};
355
356/*---------------------------------------------------------------------------*/
357/*---------------------------------------------------------------------------*/
358
359using EnvAndGlobalCellRunCommand = ConstituentAndGlobalCellRunCommandBase<Arcane::Materials::EnvItemLocalId, Arcane::Materials::EnvCellVectorView>;
360using MatAndGlobalCellRunCommand = ConstituentAndGlobalCellRunCommandBase<Arcane::Materials::MatItemLocalId, Arcane::Materials::MatCellVectorView>;
361
362/*---------------------------------------------------------------------------*/
363/*---------------------------------------------------------------------------*/
364
365/*---------------------------------------------------------------------------*/
366/*---------------------------------------------------------------------------*/
367/*!
368 * \brief Caractéristiques d'un énumérateur d'une commande sur les matériaux/milieux.
369 *
370 * Cette classe doit être spécialisée et définir les types suivants:
371 * - CommandType
372 * - IteratorValueType
373 * - ContainerType
374 * - ContainerCreateViewType
375 */
376template <typename MatItemType>
378
379/*---------------------------------------------------------------------------*/
380/*---------------------------------------------------------------------------*/
381/*!
382 * \brief Classe de base des caractéristiques des commandes sur les constituants.
383 */
384template <typename CommandType_>
386{
387 public:
388
389 using CommandType = CommandType_;
390 using IteratorValueType = CommandType::IteratorValueType;
391 using ContainerType = CommandType::Container;
392 using ContainerCreateViewType = CommandType::ContainerCreateViewType;
393
394 public:
395
396 static ContainerType createContainer(const ContainerCreateViewType& items)
397 {
398 return ContainerType{ items };
399 }
400};
401
402/*---------------------------------------------------------------------------*/
403/*---------------------------------------------------------------------------*/
404
405//! Spécialisation pour une vue sur un milieu et la maille globale associée
406template <>
408: public RunCommandConstituentItemTraitsBaseT<EnvAndGlobalCellRunCommand>
409{
410 public:
411
413 using BaseClass::createContainer;
414
415 static ContainerType createContainer(Arcane::Materials::IMeshEnvironment* env)
416 {
417 return ContainerType{ env->envView() };
418 }
419};
420
421/*---------------------------------------------------------------------------*/
422/*---------------------------------------------------------------------------*/
423
424//! Spécialisation pour une vue sur un matériau et la maille globale associée
425template <>
427: public RunCommandConstituentItemTraitsBaseT<MatAndGlobalCellRunCommand>
428{
429 public:
430
432 using BaseClass::createContainer;
433
434 static ContainerType createContainer(Arcane::Materials::IMeshMaterial* mat)
435 {
436 return ContainerType{ mat->matView() };
437 }
438};
439
440/*---------------------------------------------------------------------------*/
441/*---------------------------------------------------------------------------*/
442
443//! Spécialisation pour une vue sur les AllEvnCell
444template <>
449
450/*---------------------------------------------------------------------------*/
451/*---------------------------------------------------------------------------*/
452
453//! Spécialisation pour une vue sur un milieu.
454template <>
456: public RunCommandConstituentItemTraitsBaseT<EnvCellRunCommand>
457{
458 public:
459
461 using BaseClass::createContainer;
462
463 public:
464
465 static ContainerType createContainer(Arcane::Materials::IMeshEnvironment* env)
466 {
467 return ContainerType(env->envView());
468 }
469};
470
471/*---------------------------------------------------------------------------*/
472/*---------------------------------------------------------------------------*/
473
474//! Spécialisation pour une vue sur un matériau
475template <>
477: public RunCommandConstituentItemTraitsBaseT<MatCellRunCommand>
478{
479 public:
480
482 using BaseClass::createContainer;
483
484 static ContainerType createContainer(Arcane::Materials::IMeshMaterial* mat)
485 {
486 return ContainerType(mat->matView());
487 }
488};
489
490/*---------------------------------------------------------------------------*/
491/*---------------------------------------------------------------------------*/
492
493#if defined(ARCANE_COMPILING_CUDA_OR_HIP)
494/*
495 * Surcharge de la fonction de lancement de kernel pour GPU pour les ComponentItemLocalId et CellLocalId
496 */
497template <typename ContainerType, typename Lambda, typename... RemainingArgs> __global__ void
498doMatContainerGPULambda(ContainerType items, Lambda func, RemainingArgs... remaining_args)
499{
500 auto privatizer = Impl::privatize(func);
501 auto& body = privatizer.privateCopy();
502 Int32 i = blockDim.x * blockIdx.x + threadIdx.x;
504 if (i < items.size()) {
505 body(items[i], remaining_args...);
506 }
508}
509
510#endif // ARCANE_COMPILING_CUDA_OR_HIP
511
512/*---------------------------------------------------------------------------*/
513/*---------------------------------------------------------------------------*/
514
515#if defined(ARCANE_COMPILING_SYCL)
516
517template <typename ContainerType, typename Lambda, typename... RemainingArgs>
518class DoMatContainerSYCLLambda
519{
520 public:
521
522 void operator()(sycl::nd_item<1> x, SmallSpan<std::byte> shm_view,
523 ContainerType items, Lambda func,
524 RemainingArgs... remaining_args) const
525 {
526 auto privatizer = Impl::privatize(func);
527 auto& body = privatizer.privateCopy();
528
529 Int32 i = static_cast<Int32>(x.get_global_id(0));
530 Impl::SyclKernelRemainingArgsHelper::applyAtBegin(x, shm_view, remaining_args...);
531 if (i < items.size()) {
532 body(items[i], remaining_args...);
533 }
534 Impl::SyclKernelRemainingArgsHelper::applyAtEnd(x, shm_view, remaining_args...);
535 }
536
537 void operator()(sycl::id<1> x, ContainerType items, Lambda func) const
538 {
539 auto privatizer = Impl::privatize(func);
540 auto& body = privatizer.privateCopy();
541
542 Int32 i = static_cast<Int32>(x);
543 if (i < items.size()) {
544 body(items[i]);
545 }
546 }
547};
548
549#endif
550
551/*---------------------------------------------------------------------------*/
552/*---------------------------------------------------------------------------*/
553
554template <typename ContainerType, typename Lambda, typename... RemainingArgs>
555void _doConstituentItemsLambda(Int32 base_index, Int32 size, ContainerType items,
556 const Lambda& func, RemainingArgs... remaining_args)
557{
558 auto privatizer = Impl::privatize(func);
559 auto& body = privatizer.privateCopy();
560
561 ::Arcane::Impl::HostKernelRemainingArgsHelper::applyAtBegin(remaining_args...);
562 Int32 last_value = base_index + size;
563 for (Int32 i = base_index; i < last_value; ++i) {
564 body(items[i], remaining_args...);
565 }
566 ::Arcane::Impl::HostKernelRemainingArgsHelper::applyAtEnd(remaining_args...);
567}
568
569/*---------------------------------------------------------------------------*/
570/*---------------------------------------------------------------------------*/
571
572template <typename TraitsType, typename... RemainingArgs>
573class GenericConstituentCommandArgs
574{
575 public:
576
577 using ContainerType = typename TraitsType::ContainerType;
578
579 public:
580
581 explicit GenericConstituentCommandArgs(const ContainerType& container, const RemainingArgs&... remaining_args)
582 : m_container(container)
583 , m_remaining_args(remaining_args...)
584 {}
585
586 public:
587
588 ContainerType m_container;
589 std::tuple<RemainingArgs...> m_remaining_args;
590};
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
594
595template <typename ConstituentCommandType, typename... RemainingArgs>
596class GenericConstituentCommand
597{
598 public:
599
600 using ContainerType = typename ConstituentCommandType::Container;
601
602 public:
603
604 explicit GenericConstituentCommand(const ConstituentCommandType& command)
605 : m_command(command)
606 {}
607 explicit GenericConstituentCommand(const ConstituentCommandType& command, const std::tuple<RemainingArgs...>& remaining_args)
608 : m_command(command)
609 , m_remaining_args(remaining_args)
610 {}
611
612 public:
613
614 ConstituentCommandType m_command;
615 std::tuple<RemainingArgs...> m_remaining_args;
616};
617
618/*---------------------------------------------------------------------------*/
619/*---------------------------------------------------------------------------*/
620/*!
621 * \brief Applique l'énumération \a func sur la liste d'entité \a items.
622 *
623 * Le conteneur peut être issu de:
624 * - EnvAndGlobalCellRunCommand
625 * - EnvCellRunCommand
626 * - MatAndGlobalCellRunCommand
627 * - MatCellRunCommand
628 */
629template <typename ContainerType, typename Lambda, typename... RemainingArgs> void
630_applyConstituentCells(RunCommand& command, ContainerType items, const Lambda& func, const RemainingArgs&... remaining_args)
631{
632 using namespace Arcane::Materials;
633 // TODO: fusionner la partie commune avec 'applyLoop'
634 Int32 vsize = items.size();
635 if (vsize == 0)
636 return;
637
638 Impl::RunCommandLaunchInfo launch_info(command, vsize);
639 const eExecutionPolicy exec_policy = launch_info.executionPolicy();
640 launch_info.beginExecute();
641 switch (exec_policy) {
642 case eExecutionPolicy::CUDA:
643 _applyKernelCUDA(launch_info, ARCANE_KERNEL_CUDA_FUNC(doMatContainerGPULambda) < ContainerType, Lambda, RemainingArgs... >,
644 func, items, remaining_args...);
645 break;
646 case eExecutionPolicy::HIP:
647 _applyKernelHIP(launch_info, ARCANE_KERNEL_HIP_FUNC(doMatContainerGPULambda) < ContainerType, Lambda, RemainingArgs... >,
648 func, items, remaining_args...);
649 break;
650 case eExecutionPolicy::SYCL:
651 _applyKernelSYCL(launch_info, ARCANE_KERNEL_SYCL_FUNC(impl::DoMatContainerSYCLLambda) < ContainerType, Lambda, RemainingArgs... > {},
652 func, items, remaining_args...);
653 break;
654 case eExecutionPolicy::Sequential:
655 _doConstituentItemsLambda(0, vsize, items, func, remaining_args...);
656 break;
657 case eExecutionPolicy::Thread:
658 arcaneParallelFor(0, vsize, launch_info.loopRunInfo(),
659 [&](Int32 begin, Int32 size) {
660 _doConstituentItemsLambda(begin, size, items, func, remaining_args...);
661 });
662 break;
663 default:
664 ARCANE_FATAL("Invalid execution policy '{0}'", exec_policy);
665 }
666 launch_info.endExecute();
667}
668
669/*---------------------------------------------------------------------------*/
670/*---------------------------------------------------------------------------*/
671
672template <typename ConstituentCommandType, typename... RemainingArgs, typename Lambda>
673void operator<<(const GenericConstituentCommand<ConstituentCommandType, RemainingArgs...>& c, const Lambda& func)
674{
675 if constexpr (sizeof...(RemainingArgs) > 0) {
676 std::apply([&](auto... vs) {
677 impl::_applyConstituentCells(c.m_command.m_command, c.m_command.m_items, func, vs...);
678 },
679 c.m_remaining_args);
680 }
681 else
682 impl::_applyConstituentCells(c.m_command.m_command, c.m_command.m_items, func);
683}
684
685/*---------------------------------------------------------------------------*/
686/*---------------------------------------------------------------------------*/
687
688template <typename ConstituentItemType, typename ConstituentItemContainerType, typename... RemainingArgs> auto
689makeExtendedConstituentItemEnumeratorLoop(const ConstituentItemContainerType& container,
690 const RemainingArgs&... remaining_args)
691{
693 return GenericConstituentCommandArgs<TraitsType, RemainingArgs...>(TraitsType::createContainer(container), remaining_args...);
694}
695
696/*---------------------------------------------------------------------------*/
697/*---------------------------------------------------------------------------*/
698
699} // namespace Arcane::Accelerator::impl
700
701/*---------------------------------------------------------------------------*/
702/*---------------------------------------------------------------------------*/
703
704namespace Arcane::Accelerator
705{
706
707/*---------------------------------------------------------------------------*/
708/*---------------------------------------------------------------------------*/
709
710template <typename TraitsType, typename... RemainingArgs> auto
711operator<<(RunCommand& command, const impl::GenericConstituentCommandArgs<TraitsType, RemainingArgs...>& args)
712{
713 using CommandType = typename TraitsType::CommandType;
714 using GenericCommandType = impl::GenericConstituentCommand<CommandType, RemainingArgs...>;
715 return GenericCommandType(CommandType::create(command, args.m_container), args.m_remaining_args);
716}
717
718/*---------------------------------------------------------------------------*/
719/*---------------------------------------------------------------------------*/
720
721// TODO: rendre obsolète (il faut utiliser la version générique)
722inline auto
723operator<<(RunCommand& command, const impl::MatAndGlobalCellRunCommand::Container& view)
724{
725 using CommandType = impl::MatAndGlobalCellRunCommand;
726 return impl::GenericConstituentCommand<CommandType>(CommandType::create(command, view));
727}
728
729/*---------------------------------------------------------------------------*/
730/*---------------------------------------------------------------------------*/
731
732// TODO: rendre obsolète (il faut utiliser la version générique)
733inline auto
734operator<<(RunCommand& command, const impl::EnvAndGlobalCellRunCommand::Container& view)
735{
736 using CommandType = impl::EnvAndGlobalCellRunCommand;
737 return impl::GenericConstituentCommand<CommandType>(CommandType::create(command, view));
738}
739
740/*---------------------------------------------------------------------------*/
741/*---------------------------------------------------------------------------*/
742
743// TODO: rendre obsolète (il faut utiliser la version générique)
744inline auto
745operator<<(RunCommand& command, const impl::EnvCellRunCommand::Container& view)
746{
747 using CommandType = impl::EnvCellRunCommand;
748 return impl::GenericConstituentCommand<CommandType>(CommandType::create(command, view));
749}
750
751/*---------------------------------------------------------------------------*/
752/*---------------------------------------------------------------------------*/
753
754// TODO: rendre obsolète (il faut utiliser la version générique)
755inline auto
756operator<<(RunCommand& command, const impl::MatCellRunCommand::Container& view)
757{
758 using CommandType = impl::MatCellRunCommand;
759 return impl::GenericConstituentCommand<CommandType>(CommandType::create(command, view));
760}
761
762/*---------------------------------------------------------------------------*/
763/*---------------------------------------------------------------------------*/
764
765} // End namespace Arcane::Accelerator
766
767/*---------------------------------------------------------------------------*/
768/*---------------------------------------------------------------------------*/
769
770/*!
771 * \brief Macro pour itérer sur un matériau ou un milieu
772 *
773 * \param ConstituentItemNameType est le type de l'énumérateur.
774 * \param iter_name est le nom de l'itérateur
775 * \param env_or_mat_container est le conteneur sur lequel on itère.
776 *
777 * Les paramètres supplémentaires sont utilisés pour les réductions
778 * (voir \ref arcanedoc_acceleratorapi_reduction)
779 *
780 * \a ConstituentItemNameType doit être une des valeurs suivantes:
781 *
782 * - EnvAndGlobalCell
783 * - EnvCell
784 * - MatAndGlobalCell
785 * - MatCell
786 * - AllEnvCell
787 *
788 * Voir \ref arcanedoc_acceleratorapi_materials pour plus d'informations.
789 */
790#define RUNCOMMAND_MAT_ENUMERATE(ConstituentItemNameType, iter_name, env_or_mat_container, ...) \
791 A_FUNCINFO << ::Arcane::Accelerator::impl::makeExtendedConstituentItemEnumeratorLoop<ConstituentItemNameType>(env_or_mat_container __VA_OPT__(, __VA_ARGS__)) \
792 << [=] ARCCORE_HOST_DEVICE(::Arcane::Accelerator::impl::RunCommandConstituentItemEnumeratorTraitsT<ConstituentItemNameType>::IteratorValueType iter_name \
793 __VA_OPT__(ARCANE_RUNCOMMAND_REDUCER_FOR_EACH(__VA_ARGS__)))
794
795/*---------------------------------------------------------------------------*/
796/*---------------------------------------------------------------------------*/
797
798#endif
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classes, Types et macros pour gérer la concurrence.
void _applyConstituentCells(RunCommand &command, ContainerType items, const Lambda &func, const RemainingArgs &... remaining_args)
Applique l'énumération func sur la liste d'entité items.
static ARCCORE_DEVICE void applyAtEnd(Int32 index, RemainingArgs &... remaining_args)
Applique les fonctors des arguments additionnels en fin de kernel.
static ARCCORE_DEVICE void applyAtBegin(Int32 index, RemainingArgs &... remaining_args)
Applique les fonctors des arguments additionnels en début de kernel.
__host__ __device__ IteratorValueType operator[](Int32 i) const
Accesseur pour le i-ème élément de la liste.
constexpr __host__ __device__ IteratorValueType operator[](Int32 i) const
Accesseur pour le i-ème élément de la liste.
constexpr __host__ __device__ IteratorValueType operator[](Int32 i) const
Accesseur pour le i-ème élément de la liste.
Caractéristiques d'un énumérateur d'une commande sur les matériaux/milieux.
Classe de base des caractéristiques des commandes sur les constituants.
Maille arcane avec info matériaux et milieux.
Vue sur un vecteur sur les entités d'un composant.
Index d'une boucle accélérateur sur les matériaux ou milieux.
constexpr __host__ __device__ Int32 index() const
Index de l'itération courante.
constexpr __host__ __device__ CellLocalId globalCellId() const
Accesseur sur la partie cell local id.
constexpr __host__ __device__ Data operator()()
Cet opérateur permet de renvoyer le couple [ConstituentItemLocalIdType, CellLocalId].
constexpr __host__ __device__ ConstituentItemLocalIdType varIndex() const
Accesseur sur la partie MatVarIndex.
Maille arcane d'un milieu.
virtual EnvItemVectorView envView() const =0
Vue associée à ce milieu.
Interface d'un matériau d'un maillage.
virtual MatItemVectorView matView() const =0
Vue associée à ce matériau.
Représente un matériau d'une maille multi-matériau.
Représente un index sur les variables matériaux et milieux.
Vue d'un tableau d'éléments de type T.
Definition Span.h:801
void arcaneParallelFor(Integer i0, Integer size, InstanceType *itype, void(InstanceType::*lambda_function)(Integer i0, Integer size))
Applique en concurrence la fonction lambda lambda_function sur l'intervalle d'itération [i0,...
Active toujours les traces dans les parties Arcane concernant les matériaux.
ConstituentAndGlobalCellIteratorValue< EnvItemLocalId > EnvAndGlobalCellIteratorValue
Type de la valeur de l'itérateur pour RUNCOMMAND_MAT_ENUMERATE(EnvAndGlobalCell,.....
ConstituentAndGlobalCellIteratorValue< MatItemLocalId > MatAndGlobalCellIteratorValue
Type de la valeur de l'itérateur pour RUNCOMMAND_MAT_ENUMERATE(MatAndGlobalCell,.....
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int32_t Int32
Type entier signé sur 32 bits.