14#include "arcane/utils/StringBuilder.h" 
   15#include "arcane/utils/Collection.h" 
   17#include "arcane/core/MeshStats.h" 
   18#include "arcane/core/Item.h" 
   19#include "arcane/core/ItemGroup.h" 
   21#include "arcane/core/IMesh.h" 
   22#include "arcane/core/IItemFamily.h" 
   23#include "arcane/core/IParallelMng.h" 
   24#include "arcane/core/IVariable.h" 
   25#include "arcane/core/IVariableMng.h" 
   26#include "arcane/core/ISubDomain.h" 
   27#include "arcane/core/StringDictionary.h" 
   28#include "arcane/core/VariableCollection.h" 
   29#include "arcane/core/IVariableSynchronizer.h" 
   30#include "arcane/core/MeshHandle.h" 
   80template <> 
void MeshStats::
 
   83  _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allNodes(), istat);
 
   84  _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allEdges(), istat);
 
   85  _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allFaces(), istat);
 
   86  _computeElementsOnGroup(nb_type, nb_kind, m_mesh->
allCells(), istat);
 
   92template <> 
void MeshStats::
 
   93_statLabel<IMesh>(
const String& name)
 
   95  info() << 
" -- MESH STATISTICS " << Trace::Width(8) << name
 
   96         << 
"    FOR " << m_mesh->
name();
 
  102template <
typename T> 
void MeshStats::
 
  105  Trace::Setter setter(
traceMng(), 
"Mesh");
 
  108  const Integer nb_kind = NB_ITEM_KIND;
 
  110  const char* name[3] = { 
"(All)", 
"(Own)", 
"(Ghost)" };
 
  113  const Integer nstat = (m_parallel_mng->isParallel()) ? 3 : 1;
 
  116  const Integer data_by_stat = nb_type + nb_kind;
 
  117  const Integer all_data_count = nstat * data_by_stat;
 
  121  for (
Integer istat = 0; istat < nstat; ++istat) {
 
  122    const Integer first_type = istat * data_by_stat;
 
  123    const Integer first_kind = first_type + nb_type;
 
  128    _computeElementsOnGroup<T>(nb_local_type, nb_local_kind, istat);
 
  137  m_parallel_mng->computeMinMaxSum(nb_data,
 
  146    bool is_empty = 
true;
 
  147    for (
Integer istat = 0; istat < nstat; ++istat) {
 
  148      const Integer first_type = istat * data_by_stat;
 
  150      for (
Integer i = 0; i < nb_global_type.size(); ++i)
 
  151        if (nb_global_type[i] != 0) {
 
  162  ItemTypeMng* type_mng = m_mesh->itemTypeMng();
 
  165  const Integer nb_rank = m_parallel_mng->commSize();
 
  166  for (
Integer istat = 0; istat < nstat; ++istat) {
 
  169    const Integer first_type = istat * data_by_stat;
 
  170    const Integer first_kind = first_type + nb_type;
 
  186    info() << 
" -------------------------------------------";
 
  187    _statLabel<T>(name[istat]);
 
  189    info() << Trace::Width(18) << 
"Item" 
  190           << Trace::Width(10) << 
"Myself" 
  191           << Trace::Width(10) << 
"Min" 
  192           << Trace::Width(8) << 
"Rank" 
  193           << Trace::Width(10) << 
"Max" 
  194           << Trace::Width(8) << 
"Rank" 
  195           << Trace::Width(10) << 
"Average" 
  196           << Trace::Width(10) << 
"Bal" 
  197           << Trace::Width(12) << 
"Total";
 
  200    for (
Integer i = 0, s = nb_kind; i < s; ++i) {
 
  203                 nb_local_min_kind[i], min_rank_kind[i],
 
  204                 nb_local_max_kind[i], max_rank_kind[i],
 
  205                 nb_global_kind[i], nb_rank);
 
  216    for (
Integer i = 0, s = nb_type; i < s; ++i) {
 
  217      _printInfo(type_mng->typeName(i), nb_local_type[i],
 
  218                 nb_local_min_type[i], min_rank_type[i],
 
  219                 nb_local_max_type[i], max_rank_type[i],
 
  220                 nb_global_type[i], nb_rank);
 
  227    info() << 
" -------------------------------------------";
 
  231  _dumpCommunicatingRanks();
 
  232  _dumpLegacyConnectivityMemoryUsage();
 
  233  _dumpIncrementalConnectivityMemoryUsage();
 
  240_dumpLegacyConnectivityMemoryUsage()
 
  243  UniqueArray<String> var_names = { 
"FamilyItemsData", 
"FamilyItemsShared" };
 
  244  IVariableMng* vm = m_mesh->variableMng();
 
  245  Real total_memory = 0.0;
 
  246  for (IItemFamily* family : m_mesh->itemFamilies()) {
 
  247    String name = family->name();
 
  248    Real family_memory = 0.0;
 
  249    info(4) << 
"Family name=" << family->name();
 
  250    for (
const String& s : var_names) {
 
  251      IVariable* v = vm->findMeshVariable(m_mesh, name + s);
 
  253        Real v_memory = v->allocatedMemory();
 
  254        family_memory += v_memory;
 
  255        info(4) << 
"Allocated Memory n=" << s << 
" v=" << v_memory;
 
  258    info(4) << 
"Memory for family name=" << name << 
" mem=" << family_memory;
 
  259    total_memory += family_memory;
 
  261  info() << 
"Total memory for legacy connectivities mem=" << total_memory;
 
  268_dumpIncrementalConnectivityMemoryUsage()
 
  270  IVariableMng* vm = m_mesh->variableMng();
 
  271  Real total_memory = 0.0;
 
  272  VariableCollection used_variables = vm->usedVariables();
 
  273  const String tag_name = 
"ArcaneConnectivity";
 
  274  for (VariableCollection::Enumerator iv(used_variables); ++iv;) {
 
  276    if (!v->hasTag(tag_name))
 
  278    if (v->meshHandle().meshOrNull() == m_mesh) {
 
  279      Real v_memory = v->allocatedMemory();
 
  280      info(4) << 
"Allocated Memory n=" << v->name() << 
" v=" << v_memory;
 
  281      total_memory += v_memory;
 
  284  info() << 
"Total memory for incremental connectivities mem=" << total_memory;
 
  296  if (nb_global == 0 && nb_local == 0)
 
  299  Int64 average = nb_global;
 
  302  Real bal1 = (
Real)(nb_local_max - average);
 
  304    bal1 = bal1 / (
Real)average;
 
  306  info() << Trace::Width(18) << name
 
  307         << Trace::Width(10) << nb_local
 
  308         << Trace::Width(10) << nb_local_min
 
  309         << Trace::Width(8) << min_rank
 
  310         << Trace::Width(10) << nb_local_max
 
  311         << Trace::Width(8) << max_rank
 
  312         << Trace::Width(10) << average
 
  313         << Trace::Width(10) << bal
 
  314         << Trace::Width(12) << nb_global;
 
  324  Int32 ik = 
static_cast<Int32>(group.itemKind());
 
  327    int type = item.type();
 
  328    if (istat == 0 || (istat == 1 && item.isOwn()) || (istat == 2 && !item.isOwn())) {
 
  339_computeNeighboorsComm()
 
  341  Integer nb_proc = m_parallel_mng->commSize();
 
  343  StringBuilder out = 
"";
 
  344  vol_comm_out.fill(0);
 
  350    vol_comm_out[item.owner()]++;
 
  353  for (
Integer i = 0; i < nb_proc; ++i) {
 
  355    out += vol_comm_out[i];
 
  357  pinfo() << 
"Comm Proc " << m_parallel_mng->commRank() << 
" : " << out;
 
  364_dumpCommunicatingRanks()
 
  368  IItemFamily* cell_family = m_mesh->cellFamily();
 
  369  IVariableSynchronizer* sync_info = cell_family->allItemsSynchronizer();
 
  370  Int64 nb_comm_local = sync_info->communicatingRanks().size();
 
  371  Int32 nb_comm_min_rank = 0;
 
  372  Int32 nb_comm_max_rank = 0;
 
  373  Int64 nb_comm_max = 0;
 
  374  Int64 nb_comm_min = 0;
 
  375  Int64 nb_comm_sum = 0;
 
  376  IParallelMng* pm = m_parallel_mng;
 
  377  pm->computeMinMaxSum(nb_comm_local, nb_comm_min, nb_comm_max, nb_comm_sum,
 
  378                       nb_comm_min_rank, nb_comm_max_rank);
 
  379  Int64 average = nb_comm_sum / pm->commSize();
 
  380  info() << String::format(
"CommunicatingSubDomains: local={0}, min={1}, max={2}" 
  381                           " average={3} min_rank={4} max_rank={5}",
 
  382                           nb_comm_local, nb_comm_min, nb_comm_max, average,
 
  383                           nb_comm_min_rank, nb_comm_max_rank);
 
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.
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.
static Integer nbBasicItemType()
nombre de types disponibles
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.
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.