14#include "IMeshStats.h"
16#include "arcane/utils/StringBuilder.h"
17#include "arcane/utils/Collection.h"
19#include "arcane/core/MeshStats.h"
20#include "arcane/core/Item.h"
21#include "arcane/core/ItemGroup.h"
23#include "arcane/core/IMesh.h"
24#include "arcane/core/IItemFamily.h"
25#include "arcane/core/IParallelMng.h"
26#include "arcane/core/IVariable.h"
27#include "arcane/core/IVariableMng.h"
28#include "arcane/core/ISubDomain.h"
29#include "arcane/core/StringDictionary.h"
30#include "arcane/core/VariableCollection.h"
31#include "arcane/core/IVariableSynchronizer.h"
32#include "arcane/core/MeshHandle.h"
46 return new MeshStats(trace, mesh, pm);
73MeshStats(ITraceMng* tm, IMesh* mesh)
76, m_parallel_mng(mesh->parallelMng())
101template <>
void MeshStats::
104 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allNodes(), istat);
105 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allEdges(), istat);
106 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allFaces(), istat);
107 _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allCells(), istat);
113template <>
void MeshStats::
114_statLabel<IMesh>(
const String& name)
116 info() <<
" -- MESH STATISTICS " << Trace::Width(8) << name
117 <<
" FOR " << m_mesh->
name();
123template <
typename T>
void MeshStats::
126 Trace::Setter setter(
traceMng(),
"Mesh");
128 const Integer nb_type = m_mesh->itemTypeMng()->types().size();
129 const Integer nb_kind = NB_ITEM_KIND;
131 const char* name[3] = {
"(All)",
"(Own)",
"(Ghost)" };
134 const Integer nstat = (m_parallel_mng->isParallel()) ? 3 : 1;
137 const Integer data_by_stat = nb_type + nb_kind;
138 const Integer all_data_count = nstat * data_by_stat;
142 for (
Integer istat = 0; istat < nstat; ++istat) {
143 const Integer first_type = istat * data_by_stat;
144 const Integer first_kind = first_type + nb_type;
149 _computeElementsOnGroup<T>(nb_local_type, nb_local_kind, istat);
158 m_parallel_mng->computeMinMaxSum(nb_data,
167 bool is_empty =
true;
168 for (
Integer istat = 0; istat < nstat; ++istat) {
169 const Integer first_type = istat * data_by_stat;
171 for (
Integer i = 0; i < nb_global_type.size(); ++i)
172 if (nb_global_type[i] != 0) {
183 ItemTypeMng* type_mng = m_mesh->itemTypeMng();
186 const Integer nb_rank = m_parallel_mng->commSize();
187 for (
Integer istat = 0; istat < nstat; ++istat) {
190 const Integer first_type = istat * data_by_stat;
191 const Integer first_kind = first_type + nb_type;
207 info() <<
" -------------------------------------------";
208 _statLabel<T>(name[istat]);
210 info() << Trace::Width(18) <<
"Item"
211 << Trace::Width(10) <<
"Myself"
212 << Trace::Width(10) <<
"Min"
213 << Trace::Width(8) <<
"Rank"
214 << Trace::Width(10) <<
"Max"
215 << Trace::Width(8) <<
"Rank"
216 << Trace::Width(10) <<
"Average"
217 << Trace::Width(10) <<
"Bal"
218 << Trace::Width(12) <<
"Total";
221 for (
Integer i = 0, s = nb_kind; i < s; ++i) {
224 nb_local_min_kind[i], min_rank_kind[i],
225 nb_local_max_kind[i], max_rank_kind[i],
226 nb_global_kind[i], nb_rank);
237 for (
Integer i = 0, s = nb_type; i < s; ++i) {
238 _printInfo(type_mng->typeName(i), nb_local_type[i],
239 nb_local_min_type[i], min_rank_type[i],
240 nb_local_max_type[i], max_rank_type[i],
241 nb_global_type[i], nb_rank);
248 info() <<
" -------------------------------------------";
252 _dumpCommunicatingRanks();
253 _dumpLegacyConnectivityMemoryUsage();
254 _dumpIncrementalConnectivityMemoryUsage();
261_dumpLegacyConnectivityMemoryUsage()
264 UniqueArray<String> var_names = {
"FamilyItemsData",
"FamilyItemsShared" };
265 IVariableMng* vm = m_mesh->variableMng();
266 Real total_memory = 0.0;
267 for (IItemFamily* family : m_mesh->itemFamilies()) {
268 String name = family->name();
269 Real family_memory = 0.0;
270 info(4) <<
"Family name=" << family->name();
271 for (
const String& s : var_names) {
272 IVariable* v = vm->findMeshVariable(m_mesh, name + s);
274 Real v_memory = v->allocatedMemory();
275 family_memory += v_memory;
276 info(4) <<
"Allocated Memory n=" << s <<
" v=" << v_memory;
279 info(4) <<
"Memory for family name=" << name <<
" mem=" << family_memory;
280 total_memory += family_memory;
282 info() <<
"Total memory for legacy connectivities mem=" << total_memory;
289_dumpIncrementalConnectivityMemoryUsage()
291 IVariableMng* vm = m_mesh->variableMng();
292 Real total_memory = 0.0;
293 VariableCollection used_variables = vm->usedVariables();
294 const String tag_name =
"ArcaneConnectivity";
295 for (VariableCollection::Enumerator iv(used_variables); ++iv;) {
297 if (!v->hasTag(tag_name))
299 if (v->meshHandle().meshOrNull() == m_mesh) {
300 Real v_memory = v->allocatedMemory();
301 info(4) <<
"Allocated Memory n=" << v->name() <<
" v=" << v_memory;
302 total_memory += v_memory;
305 info() <<
"Total memory for incremental connectivities mem=" << total_memory;
317 if (nb_global == 0 && nb_local == 0)
320 Int64 average = nb_global;
323 Real bal1 = (
Real)(nb_local_max - average);
325 bal1 = bal1 / (
Real)average;
327 info() << Trace::Width(18) << name
328 << Trace::Width(10) << nb_local
329 << Trace::Width(10) << nb_local_min
330 << Trace::Width(8) << min_rank
331 << Trace::Width(10) << nb_local_max
332 << Trace::Width(8) << max_rank
333 << Trace::Width(10) << average
334 << Trace::Width(10) << bal
335 << Trace::Width(12) << nb_global;
345 Int32 ik =
static_cast<Int32>(group.itemKind());
348 Int16 type = item.type();
349 if (istat == 0 || (istat == 1 && item.isOwn()) || (istat == 2 && !item.isOwn())) {
360_computeNeighboorsComm()
362 Integer nb_proc = m_parallel_mng->commSize();
364 StringBuilder out =
"";
365 vol_comm_out.fill(0);
371 vol_comm_out[item.owner()]++;
374 for (
Integer i = 0; i < nb_proc; ++i) {
376 out += vol_comm_out[i];
378 pinfo() <<
"Comm Proc " << m_parallel_mng->commRank() <<
" : " << out;
385_dumpCommunicatingRanks()
389 IItemFamily* cell_family = m_mesh->cellFamily();
390 IVariableSynchronizer* sync_info = cell_family->allItemsSynchronizer();
391 Int64 nb_comm_local = sync_info->communicatingRanks().size();
392 Int32 nb_comm_min_rank = 0;
393 Int32 nb_comm_max_rank = 0;
394 Int64 nb_comm_max = 0;
395 Int64 nb_comm_min = 0;
396 Int64 nb_comm_sum = 0;
397 IParallelMng* pm = m_parallel_mng;
398 pm->computeMinMaxSum(nb_comm_local, nb_comm_min, nb_comm_max, nb_comm_sum,
399 nb_comm_min_rank, nb_comm_max_rank);
400 Int64 average = nb_comm_sum / pm->commSize();
401 info() << String::format(
"CommunicatingSubDomains: local={0}, min={1}, max={2}"
402 " average={3} min_rank={4} max_rank={5}",
403 nb_comm_local, nb_comm_min, nb_comm_max, average,
404 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.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface du gestionnaire de traces.
Groupe d'entités de maillage.
Affiche des informations sur un maillage.
void dumpStats() override
Imprime des infos sur le maillage.
void dumpGraphStats() override
Imprime des infos sur le graphe du maillage.
Référence à une instance.
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.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
std::int32_t Int32
Type entier signé sur 32 bits.