13#include "arcane/utils/Array.h"
14#include "arcane/utils/String.h"
15#include "arcane/utils/CheckedConvert.h"
17#include "arcane/IParallelMng.h"
18#include "arcane/MathUtils.h"
19#include "arcane/SynchronizerMatrixPrinter.h"
32SynchronizerMatrixPrinter::
33SynchronizerMatrixPrinter(IVariableSynchronizer* synchronizer)
34 : m_synchronizer(synchronizer)
45SynchronizerMatrixPrinter::
46print(std::ostream & o)
const
48 IParallelMng * parallel_mng = m_synchronizer->parallelMng();
51 for(Integer i=0;i<communicating_ranks.size();++i)
52 shared_counts[i] = m_synchronizer->sharedItems(i).size();
54 for(Integer i=0;i<communicating_ranks.size();++i)
55 ghost_counts[i] = m_synchronizer->ghostItems(i).size();
57 comm_size[0] = communicating_ranks.size();
60 parallel_mng->gather(comm_size,all_comm_sizes,0);
62 parallel_mng->gatherVariable(communicating_ranks,all_communicating_ranks,0);
64 parallel_mng->gatherVariable(shared_counts,all_shared_counts,0);
66 parallel_mng->gatherVariable(ghost_counts,all_ghost_counts,0);
67 ARCANE_ASSERT((all_ghost_counts.size() == all_shared_counts.size()),(
"Incompatible shared / ghost counts"));
69 if (parallel_mng->commRank() == 0){
72 for(Integer i=0;i<all_comm_sizes.size();++i)
73 all_offsets[i+1] = all_offsets[i] + all_comm_sizes[i];
75 Int64 text_width0 = String::format(
"{0}",parallel_mng->commSize()).length();
76 for(Integer i=0;i<all_shared_counts.size();++i)
77 text_width0 = math::max(text_width0,String::format(
"{0} / {1}",all_shared_counts[i], all_ghost_counts[i]).length());
78 text_width0 = math::max(6,text_width0);
79 Int32 text_width = CheckedConvert::toInt32(text_width0);
81 o <<
"\n" << std::setw(text_width) <<
"" <<
" ";
82 for(Integer j=0;j<parallel_mng->commSize();++j)
83 o << std::setw(text_width) << j <<
" ";
86 for(Integer i=0;i<parallel_mng->commSize();++i) {
87 o << std::setw(text_width) << i <<
" : ";
88 Integer jstart = all_offsets[i];
89 Integer jend = all_offsets[i+1];
90 for(Integer j=0;j<parallel_mng->commSize();++j) {
91 if (jstart != jend && all_communicating_ranks[jstart] == j) {
92 o << std::setw(text_width) << String::format(
"{0} / {1}",all_shared_counts[jstart], all_ghost_counts[jstart]) <<
" ";
96 o << std::setw(text_width) <<
"" <<
" ";
100 o <<
"(i,j) = S/G : proc 'i' shares S items with 'j' / has G ghosts items from 'j'\n";
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
Int32 Integer
Type représentant un entier.