15#include "arcane/utils/StringBuilder.h"
16#include "arcane/utils/Collection.h"
18#include "arcane/core/MeshStats.h"
19#include "arcane/core/Item.h"
20#include "arcane/core/ItemGroup.h"
22#include "arcane/core/IMesh.h"
23#include "arcane/core/IItemFamily.h"
24#include "arcane/core/IParallelMng.h"
25#include "arcane/core/IVariable.h"
26#include "arcane/core/IVariableMng.h"
27#include "arcane/core/ISubDomain.h"
28#include "arcane/core/StringDictionary.h"
29#include "arcane/core/VariableCollection.h"
30#include "arcane/core/IVariableSynchronizer.h"
31#include "arcane/core/MeshHandle.h"
81template <>
void MeshStats::
84 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allNodes(), istat);
85 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allEdges(), istat);
86 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allFaces(), istat);
87 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allCells(), istat);
93template <>
void MeshStats::
94_statLabel<IMesh>(
const String& name)
96 info() <<
" -- MESH STATISTICS " << Trace::Width(8) << name
97 <<
" FOR " << m_mesh->
name();
103template <
typename T>
void MeshStats::
106 Trace::Setter setter(
traceMng(),
"Mesh");
108 const Integer nb_type = m_mesh->itemTypeMng()->types().size();
109 const Integer nb_kind = NB_ITEM_KIND;
111 const char* name[3] = {
"(All)",
"(Own)",
"(Ghost)" };
114 const Integer nstat = (m_parallel_mng->isParallel()) ? 3 : 1;
117 const Integer data_by_stat = nb_type + nb_kind;
118 const Integer all_data_count = nstat * data_by_stat;
122 for (
Integer istat = 0; istat < nstat; ++istat) {
123 const Integer first_type = istat * data_by_stat;
124 const Integer first_kind = first_type + nb_type;
129 _computeElementsOnGroup<T>(nb_local_type, nb_local_kind, istat);
138 m_parallel_mng->computeMinMaxSum(nb_data,
147 bool is_empty =
true;
148 for (
Integer istat = 0; istat < nstat; ++istat) {
149 const Integer first_type = istat * data_by_stat;
151 for (
Integer i = 0; i < nb_global_type.size(); ++i)
152 if (nb_global_type[i] != 0) {
163 ItemTypeMng* type_mng = m_mesh->itemTypeMng();
166 const Integer nb_rank = m_parallel_mng->commSize();
167 for (
Integer istat = 0; istat < nstat; ++istat) {
170 const Integer first_type = istat * data_by_stat;
171 const Integer first_kind = first_type + nb_type;
187 info() <<
" -------------------------------------------";
188 _statLabel<T>(name[istat]);
190 info() << Trace::Width(18) <<
"Item"
191 << Trace::Width(10) <<
"Myself"
192 << Trace::Width(10) <<
"Min"
193 << Trace::Width(8) <<
"Rank"
194 << Trace::Width(10) <<
"Max"
195 << Trace::Width(8) <<
"Rank"
196 << Trace::Width(10) <<
"Average"
197 << Trace::Width(10) <<
"Bal"
198 << Trace::Width(12) <<
"Total";
201 for (
Integer i = 0, s = nb_kind; i < s; ++i) {
204 nb_local_min_kind[i], min_rank_kind[i],
205 nb_local_max_kind[i], max_rank_kind[i],
206 nb_global_kind[i], nb_rank);
217 for (
Integer i = 0, s = nb_type; i < s; ++i) {
218 _printInfo(type_mng->typeName(i), nb_local_type[i],
219 nb_local_min_type[i], min_rank_type[i],
220 nb_local_max_type[i], max_rank_type[i],
221 nb_global_type[i], nb_rank);
228 info() <<
" -------------------------------------------";
232 _dumpCommunicatingRanks();
233 _dumpLegacyConnectivityMemoryUsage();
234 _dumpIncrementalConnectivityMemoryUsage();
241_dumpLegacyConnectivityMemoryUsage()
244 UniqueArray<String> var_names = {
"FamilyItemsData",
"FamilyItemsShared" };
245 IVariableMng* vm = m_mesh->variableMng();
246 Real total_memory = 0.0;
247 for (IItemFamily* family : m_mesh->itemFamilies()) {
248 String name = family->name();
249 Real family_memory = 0.0;
250 info(4) <<
"Family name=" << family->name();
251 for (
const String& s : var_names) {
252 IVariable* v = vm->findMeshVariable(m_mesh, name + s);
254 Real v_memory = v->allocatedMemory();
255 family_memory += v_memory;
256 info(4) <<
"Allocated Memory n=" << s <<
" v=" << v_memory;
259 info(4) <<
"Memory for family name=" << name <<
" mem=" << family_memory;
260 total_memory += family_memory;
262 info() <<
"Total memory for legacy connectivities mem=" << total_memory;
269_dumpIncrementalConnectivityMemoryUsage()
271 IVariableMng* vm = m_mesh->variableMng();
272 Real total_memory = 0.0;
273 VariableCollection used_variables = vm->usedVariables();
274 const String tag_name =
"ArcaneConnectivity";
275 for (VariableCollection::Enumerator iv(used_variables); ++iv;) {
277 if (!v->hasTag(tag_name))
279 if (v->meshHandle().meshOrNull() == m_mesh) {
280 Real v_memory = v->allocatedMemory();
281 info(4) <<
"Allocated Memory n=" << v->name() <<
" v=" << v_memory;
282 total_memory += v_memory;
285 info() <<
"Total memory for incremental connectivities mem=" << total_memory;
297 if (nb_global == 0 && nb_local == 0)
300 Int64 average = nb_global;
303 Real bal1 = (
Real)(nb_local_max - average);
305 bal1 = bal1 / (
Real)average;
307 info() << Trace::Width(18) << name
308 << Trace::Width(10) << nb_local
309 << Trace::Width(10) << nb_local_min
310 << Trace::Width(8) << min_rank
311 << Trace::Width(10) << nb_local_max
312 << Trace::Width(8) << max_rank
313 << Trace::Width(10) << average
314 << Trace::Width(10) << bal
315 << Trace::Width(12) << nb_global;
325 Int32 ik =
static_cast<Int32>(group.itemKind());
328 Int16 type = item.type();
329 if (istat == 0 || (istat == 1 && item.isOwn()) || (istat == 2 && !item.isOwn())) {
340_computeNeighboorsComm()
342 Integer nb_proc = m_parallel_mng->commSize();
344 StringBuilder out =
"";
345 vol_comm_out.fill(0);
351 vol_comm_out[item.owner()]++;
354 for (
Integer i = 0; i < nb_proc; ++i) {
356 out += vol_comm_out[i];
358 pinfo() <<
"Comm Proc " << m_parallel_mng->commRank() <<
" : " << out;
365_dumpCommunicatingRanks()
369 IItemFamily* cell_family = m_mesh->cellFamily();
370 IVariableSynchronizer* sync_info = cell_family->allItemsSynchronizer();
371 Int64 nb_comm_local = sync_info->communicatingRanks().size();
372 Int32 nb_comm_min_rank = 0;
373 Int32 nb_comm_max_rank = 0;
374 Int64 nb_comm_max = 0;
375 Int64 nb_comm_min = 0;
376 Int64 nb_comm_sum = 0;
377 IParallelMng* pm = m_parallel_mng;
378 pm->computeMinMaxSum(nb_comm_local, nb_comm_min, nb_comm_max, nb_comm_sum,
379 nb_comm_min_rank, nb_comm_max_rank);
380 Int64 average = nb_comm_sum / pm->commSize();
381 info() << String::format(
"CommunicatingSubDomains: local={0}, min={1}, max={2}"
382 " average={3} min_rank={4} max_rank={5}",
383 nb_comm_local, nb_comm_min, nb_comm_max, average,
384 nb_comm_min_rank, nb_comm_max_rank);
Déclarations des types généraux de Arcane.
Vue modifiable d'un tableau d'un type T.
constexpr ArrayView< T > subView(Integer abegin, Integer asize) noexcept
Sous-vue à partir de l'élément abegin et contenant asize éléments.
constexpr ConstArrayView< T > subConstView(Integer abegin, Integer asize) const noexcept
Sous-vue (constante) à partir de l'élément abegin et contenant asize éléments.
virtual String name() const =0
Nom du maillage.
virtual FaceGroup allFaces()=0
Groupe de toutes les faces.
virtual NodeGroup allNodes()=0
Groupe de tous les noeuds.
virtual CellGroup allCells()=0
Groupe de toutes les mailles.
virtual EdgeGroup allEdges()=0
Groupe de toutes les arêtes.
Interface d'une classe donnant des informations sur le maillage.
static IMeshStats * create(ITraceMng *trace, IMesh *mesh, IParallelMng *pm)
Création d'une instance par défaut.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface du gestionnaire de traces.
Groupe d'entités de maillage.
void dumpStats() override
Imprime des infos sur le maillage.
void dumpGraphStats() override
Imprime des infos sur le graphe du maillage.
Chaîne de caractères unicode.
Classe d'accès aux traces.
TraceMessage pinfo() const
Flot pour un message d'information en parallèle.
TraceMessage info() const
Flot pour un message d'information.
ITraceMng * traceMng() const
Gestionnaire de trace.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
std::int16_t Int16
Type entier signé sur 16 bits.
const char * itemKindName(eItemKind kind)
Nom du genre d'entité.
double Real
Type représentant un réel.
std::int32_t Int32
Type entier signé sur 32 bits.