Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
SynchronizerMatrixPrinter.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* SynchronizerMatrixPrinter.h (C) 2011-2011 */
9/* */
10/* Affiche la matrix de synchronization. */
11/*---------------------------------------------------------------------------*/
12
13#include "arcane/utils/Array.h"
14#include "arcane/utils/String.h"
15#include "arcane/utils/CheckedConvert.h"
16
17#include "arcane/IParallelMng.h"
18#include "arcane/MathUtils.h"
19#include "arcane/SynchronizerMatrixPrinter.h"
20
21#include <iomanip>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32SynchronizerMatrixPrinter::
33SynchronizerMatrixPrinter(IVariableSynchronizer* synchronizer)
34 : m_synchronizer(synchronizer)
35{
36}
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44void
45SynchronizerMatrixPrinter::
46print(std::ostream & o) const
47{
48 IParallelMng * parallel_mng = m_synchronizer->parallelMng();
49 Int32ConstArrayView communicating_ranks = m_synchronizer->communicatingRanks();
50 Int32UniqueArray shared_counts(communicating_ranks.size());
51 for(Integer i=0;i<communicating_ranks.size();++i)
52 shared_counts[i] = m_synchronizer->sharedItems(i).size();
53 Int32UniqueArray ghost_counts(communicating_ranks.size());
54 for(Integer i=0;i<communicating_ranks.size();++i)
55 ghost_counts[i] = m_synchronizer->ghostItems(i).size();
56 Int32UniqueArray comm_size(1);
57 comm_size[0] = communicating_ranks.size();
58
59 Int32UniqueArray all_comm_sizes(parallel_mng->commSize());
60 parallel_mng->gather(comm_size,all_comm_sizes,0);
61 Int32UniqueArray all_communicating_ranks;
62 parallel_mng->gatherVariable(communicating_ranks,all_communicating_ranks,0);
63 Int32UniqueArray all_shared_counts;
64 parallel_mng->gatherVariable(shared_counts,all_shared_counts,0);
65 Int32UniqueArray all_ghost_counts;
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"));
68
69 if (parallel_mng->commRank() == 0){
70 Int32UniqueArray all_offsets(all_comm_sizes.size()+1);
71 all_offsets[0] = 0;
72 for(Integer i=0;i<all_comm_sizes.size();++i)
73 all_offsets[i+1] = all_offsets[i] + all_comm_sizes[i];
74
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);
80
81 o << "\n" << std::setw(text_width) << "" << " ";
82 for(Integer j=0;j<parallel_mng->commSize();++j)
83 o << std::setw(text_width) << j << " ";
84 o << "\n";
85
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]) << " ";
93 ++jstart;
94 }
95 else
96 o << std::setw(text_width) << "" << " ";
97 }
98 o << "\n";
99 }
100 o << "(i,j) = S/G : proc 'i' shares S items with 'j' / has G ghosts items from 'j'\n";
101 }
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107} // End namespace Arcane
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
-*- 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.
Definition UtilsTypes.h:640
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:515
Int32 Integer
Type représentant un entier.