14#include "arcane/materials/internal/IncrementalComponentModifier.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FunctorUtils.h"
18#include "arcane/utils/ValueConvert.h"
20#include "arcane/core/IItemFamily.h"
21#include "arcane/core/materials/IMeshMaterialVariable.h"
23#include "arcane/materials/internal/MeshMaterialMng.h"
24#include "arcane/materials/internal/ConstituentConnectivityList.h"
25#include "arcane/materials/internal/AllEnvData.h"
27#include "arcane/accelerator/core/ProfileRegion.h"
38IncrementalComponentModifier::
39IncrementalComponentModifier(AllEnvData* all_env_data,
const RunQueue& queue)
40: TraceAccessor(all_env_data->traceMng())
41, m_all_env_data(all_env_data)
42, m_material_mng(all_env_data->m_material_mng)
43, m_work_info(queue.allocationOptions(), queue.memoryRessource())
49 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_USE_GENERIC_COPY_BETWEEN_PURE_AND_PARTIAL",
true)) {
50 m_use_generic_copy_between_pure_and_partial = v.value();
55 if (queue.isAcceleratorPolicy())
56 m_use_generic_copy_between_pure_and_partial = 2;
63void IncrementalComponentModifier::
64initialize(
bool is_debug)
66 m_is_debug = is_debug;
67 Int32 max_local_id = m_material_mng->mesh()->cellFamily()->maxLocalId();
68 Int32 nb_mat = m_material_mng->materials().size();
69 Int32 nb_env = m_material_mng->environments().size();
70 m_work_info.initialize(max_local_id, nb_mat, nb_env, m_queue);
71 m_work_info.is_verbose = is_debug || (traceMng()->verbosityLevel() >= 5);
77void IncrementalComponentModifier::
96void IncrementalComponentModifier::
100 const bool is_add = m_work_info.isAdd();
101 const bool is_device = m_queue.isAcceleratorPolicy();
114 m_work_info.pure_local_ids.clearHost();
115 m_work_info.partial_indexes.clearHost();
120 info(4) <<
"MatTransformCells is_add?=" <<
is_add <<
" indexer=" << indexer->
name()
121 <<
" mat_id=" <<
mat->id();
128 _resetTransformedCells(ids);
130 auto pure_local_ids = m_work_info.pure_local_ids.view(
is_device);
131 auto partial_indexes = m_work_info.partial_indexes.view(
is_device);
133 Int32
nb_pure = pure_local_ids.size();
135 info(4) <<
"NB_MAT_TRANSFORM pure=" <<
nb_pure
142 m_do_copy_between_partial_and_pure,
145 _copyBetweenPartialsAndGlobals(args);
164void IncrementalComponentModifier::
168 const bool is_add = m_work_info.isAdd();
169 const bool is_device = m_queue.isAcceleratorPolicy();
176 const bool is_copy =
is_add || !(m_material_mng->isUseMaterialValueWhenRemovingPartialValue());
178 Int32
nb_transformed = _computeCellsToTransformForEnvironments(ids);
179 info(4) <<
"Compute Cells for environments nb_transformed=" <<
nb_transformed;
188 if (
env->isMonoMaterial())
197 m_work_info.pure_local_ids.clearHost();
198 m_work_info.partial_indexes.clearHost();
203 info(4) <<
"EnvTransformCells is_add?=" <<
is_add
205 <<
" indexer=" << indexer->
name() <<
" nb_item=" << ids.size();
211 const Int32
nb_pure = pure_local_ids.size();
213 info(4) <<
"NB_ENV_TRANSFORM nb_pure=" <<
nb_pure <<
" name=" <<
env->name()
219 m_do_copy_between_partial_and_pure,
is_add,
221 _copyBetweenPartialsAndGlobals(
copy_args);
225 _resetTransformedCells(ids);
233Int32 IncrementalComponentModifier::
238 bool is_add = m_work_info.isAdd();
260void IncrementalComponentModifier::
264 info(4) <<
"MeshEnvironment::removeItemsDirect mat=" <<
mat->name();
271 mat->variableIndexer()->endUpdateRemove(m_work_info,
nb_to_remove, m_queue);
278 env->variableIndexer()->endUpdateRemove(m_work_info,
nb_to_remove, m_queue);
292void IncrementalComponentModifier::
296 info(4) <<
"MeshEnvironment::addItemsDirect"
297 <<
" mat=" <<
mat->name();
306 m_work_info.m_cells_is_partial.resize(
nb_to_add);
324void IncrementalComponentModifier::
333 list_builder.preAllocate(
nb_id);
335 _computeItemsToAdd(list_builder,
local_ids);
337 if (traceMng()->verbosityLevel() >= 5)
338 info() <<
"ADD_MATITEM_TO_INDEXER component=" <<
var_indexer->name()
339 <<
" nb_pure=" << list_builder.pureIndexes().
size()
340 <<
" nb_partial=" << list_builder.partialIndexes().
size()
341 <<
"\n pure=(" << list_builder.pureIndexes() <<
")"
342 <<
"\n partial=(" << list_builder.partialIndexes() <<
")";
354 if (m_do_init_new_items) {
365 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
369 copy_data.reserve(m_material_mng->nbVariable());
374 mv->_internalApi()->initializeNewItemsWithZero(
init_args);
376 functor::apply(mm, &IMeshMaterialMng::visitVariables, func_zero);
379 MDSpan<CopyBetweenDataInfo, MDDim1> x(copy_data.data(), MDIndex<1>(copy_data.size()));
380 m_work_info.m_variables_copy_data.copy(x, &m_queue);
381 _applyInitializeWithZero(init_args);
386 SmallSpan<Int32> partial_local_ids = list_builder.partialLocalIds();
388 CopyBetweenPartialAndGlobalArgs args(var_indexer->index(), partial_local_ids,
389 partial_indexes,
true,
true, m_queue);
390 _copyBetweenPartialsAndGlobals(args);
400void IncrementalComponentModifier::
403 RunQueue& queue = m_material_mng->_internalApi()->runQueue();
410 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
414 copy_data.reserve(m_material_mng->nbVariable());
419 auto*
mvi =
mv->_internalApi();
422 functor::apply(m_material_mng, &MeshMaterialMng::visitVariables, func1);
427 m_work_info.m_variables_copy_data.copy(x, &queue);
428 _applyCopyVariableViews(queue);
443void IncrementalComponentModifier::
446 if (args.m_local_ids.
empty())
448 const bool do_copy = args.m_do_copy_between_partial_and_pure;
461 _resizeVariablesIndexer(args.m_var_index);
465 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
468 copy_data.reserve(m_material_mng->nbVariable());
472 args2.m_use_generic_copy = (m_use_generic_copy_between_pure_and_partial >= 1);
476 auto*
mvi =
mv->_internalApi();
479 mvi->copyBetweenPartialAndGlobal(
args2);
482 functor::apply(m_material_mng, &MeshMaterialMng::visitVariables, func2);
486 m_work_info.m_variables_copy_data.copy(x, &queue);
487 _applyCopyBetweenPartialsAndGlobals(
args2, queue);
Région pour le profiling.
Permet de modifier l'asynchronisme de la file pendant la durée de vie de l'instance.
File d'exécution pour un accélérateur.
void barrier() const
Bloque tant que toutes les commandes associées à la file ne sont pas terminées.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Classe d'aide à la construction d'une liste de ComponentItem pour un MeshMaterialVariableIndexer.
Gestion des listes de connectivité des constituants.
Int32 fillCellsToTransform(SmallSpan< const Int32 > cells_local_id, Int16 env_id, SmallSpan< bool > cells_do_transform, bool is_add, RunQueue &queue)
Replit cells_do_transform en indiquant is la maille passe de pure à partielle.
void fillCellsIsPartial(SmallSpan< const Int32 > cells_local_id, Int16 env_id, SmallSpan< bool > cells_is_partial, RunQueue &queue)
Replit cells_is_partial en indiquant is la maille est partielle pour le milieu env_id.
Arguments des méthodes de copie entre valeurs partielles et globales.
Interface d'un milieu d'un maillage.
Interface du gestionnaire des matériaux et des milieux d'un maillage.
Interface d'une variable matériau d'un maillage.
Arguments des méthodes de copie entre valeurs partielles et globales.
Indexer pour les variables materiaux.
void transformCells(ConstituentModifierWorkInfo &args, RunQueue &queue, bool is_from_env)
Transforme des mailles entre pure et partielle.
const String & name() const
Nom de l'indexeur.
Arguments des méthodes de copie entre valeurs partielles et globales.
constexpr ARCCORE_HOST_DEVICE bool empty() const noexcept
Retourne true si le tableau est vide (dimension nulle)
constexpr ARCCORE_HOST_DEVICE SizeType size() const noexcept
Retourne la taille du tableau.
Active toujours les traces dans les parties Arcane concernant les matériaux.