13#include "arcane/utils/Array.h"
14#include "arcane/utils/String.h"
15#include "arcane/utils/CheckedConvert.h"
17#include "arcane/core/IParallelMng.h"
19#include "arcane/core/SynchronizerMatrixPrinter.h"
32SynchronizerMatrixPrinter::
34: m_synchronizer(synchronizer)
44void SynchronizerMatrixPrinter::
45print(std::ostream& o)
const
47 IParallelMng* parallel_mng = m_synchronizer->parallelMng();
50 for (Integer i = 0; i < communicating_ranks.size(); ++i)
51 shared_counts[i] = m_synchronizer->sharedItems(i).size();
53 for (Integer i = 0; i < communicating_ranks.size(); ++i)
54 ghost_counts[i] = m_synchronizer->ghostItems(i).size();
56 comm_size[0] = communicating_ranks.size();
59 parallel_mng->gather(comm_size, all_comm_sizes, 0);
61 parallel_mng->gatherVariable(communicating_ranks, all_communicating_ranks, 0);
63 parallel_mng->gatherVariable(shared_counts, all_shared_counts, 0);
65 parallel_mng->gatherVariable(ghost_counts, all_ghost_counts, 0);
66 ARCANE_ASSERT((all_ghost_counts.size() == all_shared_counts.size()), (
"Incompatible shared / ghost counts"));
68 if (parallel_mng->commRank() == 0) {
71 for (Integer i = 0; i < all_comm_sizes.size(); ++i)
72 all_offsets[i + 1] = all_offsets[i] + all_comm_sizes[i];
74 Int64 text_width0 = String::format(
"{0}", parallel_mng->commSize()).length();
75 for (Integer i = 0; i < all_shared_counts.size(); ++i)
76 text_width0 = math::max(text_width0, String::format(
"{0} / {1}", all_shared_counts[i], all_ghost_counts[i]).length());
77 text_width0 = math::max(6, text_width0);
78 Int32 text_width = CheckedConvert::toInt32(text_width0);
81 << 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";
Various mathematical functions.
Interface of a variable synchronization service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.