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.executionPolicy() != Accelerator::eExecutionPolicy::Sequential)
56 m_use_generic_copy_between_pure_and_partial = 2;
58 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_FORCE_MULTIPLE_COMMAND_FOR_MATERIAL_RESIZE",
true)) {
59 m_force_multiple_command_for_resize = (v.value());
60 info() <<
"Force using multiple command for resize = " << m_force_multiple_command_for_resize;
67void IncrementalComponentModifier::
68initialize(
bool is_debug)
70 m_is_debug = is_debug;
71 Int32 max_local_id = m_material_mng->mesh()->cellFamily()->maxLocalId();
72 Int32 nb_mat = m_material_mng->materials().size();
73 Int32 nb_env = m_material_mng->environments().size();
74 m_work_info.initialize(max_local_id, nb_mat, nb_env, m_queue);
75 m_work_info.is_verbose = is_debug || (traceMng()->verbosityLevel() >= 5);
81void IncrementalComponentModifier::
100void IncrementalComponentModifier::
104 const bool is_add = m_work_info.isAdd();
105 const bool is_device = m_queue.isAcceleratorPolicy();
118 m_work_info.pure_local_ids.clearHost();
119 m_work_info.partial_indexes.clearHost();
124 info(4) <<
"MatTransformCells is_add?=" <<
is_add <<
" indexer=" << indexer->
name()
125 <<
" mat_id=" <<
mat->id();
132 _resetTransformedCells(ids);
134 auto pure_local_ids = m_work_info.pure_local_ids.view(
is_device);
135 auto partial_indexes = m_work_info.partial_indexes.view(
is_device);
137 Int32
nb_pure = pure_local_ids.size();
139 info(4) <<
"NB_MAT_TRANSFORM pure=" <<
nb_pure
146 m_do_copy_between_partial_and_pure,
149 _copyBetweenPartialsAndGlobals(args);
168void IncrementalComponentModifier::
172 const bool is_add = m_work_info.isAdd();
173 const bool is_device = m_queue.isAcceleratorPolicy();
180 const bool is_copy =
is_add || !(m_material_mng->isUseMaterialValueWhenRemovingPartialValue());
182 Int32
nb_transformed = _computeCellsToTransformForEnvironments(ids);
183 info(4) <<
"Compute Cells for environments nb_transformed=" <<
nb_transformed;
192 if (
env->isMonoMaterial())
201 m_work_info.pure_local_ids.clearHost();
202 m_work_info.partial_indexes.clearHost();
207 info(4) <<
"EnvTransformCells is_add?=" <<
is_add
209 <<
" indexer=" << indexer->
name() <<
" nb_item=" << ids.size();
215 const Int32
nb_pure = pure_local_ids.size();
217 info(4) <<
"NB_ENV_TRANSFORM nb_pure=" <<
nb_pure <<
" name=" <<
env->name()
223 m_do_copy_between_partial_and_pure,
is_add,
225 _copyBetweenPartialsAndGlobals(
copy_args);
229 _resetTransformedCells(ids);
237Int32 IncrementalComponentModifier::
242 bool is_add = m_work_info.isAdd();
264void IncrementalComponentModifier::
268 info(4) <<
"MeshEnvironment::removeItemsDirect mat=" <<
mat->name();
275 mat->variableIndexer()->endUpdateRemove(m_work_info,
nb_to_remove, m_queue);
282 env->variableIndexer()->endUpdateRemove(m_work_info,
nb_to_remove, m_queue);
296void IncrementalComponentModifier::
300 info(4) <<
"MeshEnvironment::addItemsDirect"
301 <<
" mat=" <<
mat->name();
310 m_work_info.m_cells_is_partial.resize(
nb_to_add);
328void IncrementalComponentModifier::
337 list_builder.preAllocate(
nb_id);
339 _computeItemsToAdd(list_builder,
local_ids);
341 if (traceMng()->verbosityLevel() >= 5)
342 info() <<
"ADD_MATITEM_TO_INDEXER component=" <<
var_indexer->name()
343 <<
" nb_pure=" << list_builder.pureIndexes().
size()
344 <<
" nb_partial=" << list_builder.partialIndexes().
size()
345 <<
"\n pure=(" << list_builder.pureIndexes() <<
")"
346 <<
"\n partial=(" << list_builder.partialIndexes() <<
")";
358 if (m_do_init_new_items) {
369 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
373 copy_data.reserve(m_material_mng->nbVariable());
378 mv->_internalApi()->initializeNewItemsWithZero(
init_args);
380 functor::apply(mm, &IMeshMaterialMng::visitVariables, func_zero);
383 MDSpan<CopyBetweenDataInfo, MDDim1> x(copy_data.data(), MDIndex<1>(copy_data.size()));
384 m_work_info.m_variables_copy_data.copy(x, &m_queue);
385 _applyInitializeWithZero(init_args);
390 SmallSpan<Int32> partial_local_ids = list_builder.partialLocalIds();
392 CopyBetweenPartialAndGlobalArgs args(var_indexer->index(), partial_local_ids,
393 partial_indexes,
true,
true, m_queue);
394 _copyBetweenPartialsAndGlobals(args);
404void IncrementalComponentModifier::
412 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
414 if (m_force_multiple_command_for_resize)
420 copy_data.reserve(m_material_mng->nbVariable());
424 if (m_force_multiple_command_for_resize) {
432 auto*
mvi =
mv->_internalApi();
436 functor::apply(m_material_mng, &MeshMaterialMng::visitVariables, func2);
441 auto*
mvi =
mv->_internalApi();
444 functor::apply(m_material_mng, &MeshMaterialMng::visitVariables, func1);
450 m_work_info.m_variables_copy_data.copy(x, &m_queue);
451 _applyCopyVariableViews(m_queue);
466void IncrementalComponentModifier::
469 if (args.m_local_ids.
empty())
471 const bool do_copy = args.m_do_copy_between_partial_and_pure;
484 _resizeVariablesIndexer(args.m_var_index);
488 bool do_one_command = (m_use_generic_copy_between_pure_and_partial == 2);
491 copy_data.reserve(m_material_mng->nbVariable());
495 args2.m_use_generic_copy = (m_use_generic_copy_between_pure_and_partial >= 1);
499 auto*
mvi =
mv->_internalApi();
502 mvi->copyBetweenPartialAndGlobal(
args2);
505 functor::apply(m_material_mng, &MeshMaterialMng::visitVariables, func2);
509 m_work_info.m_variables_copy_data.copy(x, &queue);
510 _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.
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.
Chaîne de caractères unicode.
Active toujours les traces dans les parties Arcane concernant les matériaux.