Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MetisGraphDigest.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* MetisGraphDigest.cc (C) 2000-2024 */
9/* */
10/* Calcule une somme de contrôle globale des entrées/sorties Metis. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/MD5HashAlgorithm.h"
15#include "arcane/utils/FatalErrorException.h"
16
17#include "arcane/core/IParallelMng.h"
18
19#include "arcane/std/internal/MetisGraphDigest.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace
31{
32MD5HashAlgorithm hash_algo;
33const Integer idx_t_size = sizeof(idx_t);
34const Integer real_t_size = sizeof(real_t);
35
36} // namespace
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41MetisGraphDigest::
42MetisGraphDigest(IParallelMng* pm)
43: TraceAccessor(pm->traceMng())
44, m_parallel_mng(pm)
45, m_my_rank(pm->commRank())
46, m_nb_rank(pm->commSize())
47{
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
57String MetisGraphDigest::
59{
61
62 bool is_master_io = m_parallel_mng->isMasterIO();
63 Int32 io_master_rank = m_parallel_mng->masterIORank();
64
66
67 m_parallel_mng->gatherVariable(my_digest, concat_digest, io_master_rank);
68
69 if (is_master_io) {
71 hash_algo.computeHash64(concat_digest, final_digest);
72 digest_string = Convert::toHexaString(final_digest);
73 info() << "DigestString s=" << digest_string;
74 }
75
76 return digest_string;
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82void MetisGraphDigest::
83_computeHash(Span<const idx_t> data, ByteArray& output, const char* name)
84{
86 hash_algo.computeHash64(Arccore::asBytes(data), bytes);
87 info() << "COMPUTE_HASH=" << name << " v=" << Convert::toHexaString(bytes);
88 output.addRange(bytes);
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94void MetisGraphDigest::
95_computeHash(Span<const real_t> data, ByteArray& output, const char* name)
96{
97 UniqueArray<Byte> bytes;
98 hash_algo.computeHash64(Arccore::asBytes(data), bytes);
99 info() << "COMPUTE_HASH=" << name << " v=" << Convert::toHexaString(bytes);
100 output.addRange(bytes);
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105#define COMPUTE_HASH1(array, output) _computeHash(array, output, #array)
106#define COMPUTE_HASH(array, n, output) _computeHash({ array, n }, output, #array)
107
108String MetisGraphDigest::
109computeInputDigest(const bool need_part, const int nb_options, const MetisGraphView& my_graph,
110 const idx_t* vtxdist, const idx_t* wgtflag, const idx_t* numflag, const idx_t* ncon,
111 const idx_t* nparts, const real_t* tpwgts, const real_t* ubvec, const real_t* ipc2redist,
112 const idx_t* options)
113{
115
116 // Signature du graph lui-meme
117
118 COMPUTE_HASH1(my_graph.xadj, hash_value);
119 COMPUTE_HASH1(my_graph.adjncy, hash_value);
120 COMPUTE_HASH1(my_graph.vwgt, hash_value);
121
122 if (my_graph.have_vsize) {
123 COMPUTE_HASH1(my_graph.vsize, hash_value);
124 }
125
126 if (my_graph.have_adjwgt) {
127 COMPUTE_HASH1(my_graph.adjwgt, hash_value);
128 }
129
130 if (need_part) {
131 COMPUTE_HASH1(my_graph.part, hash_value);
132 }
133
134 // Ajout de la signature des options, des dimensions
135
136 COMPUTE_HASH(vtxdist, m_nb_rank + 1, hash_value);
137 COMPUTE_HASH(wgtflag, 1, hash_value);
138 COMPUTE_HASH(numflag, 1, hash_value);
139 COMPUTE_HASH(ncon, 1, hash_value);
140 COMPUTE_HASH(nparts, 1, hash_value);
141 COMPUTE_HASH(tpwgts, (*nparts) * (*ncon), hash_value);
142 COMPUTE_HASH(ubvec, (*ncon), hash_value);
143
144 if (ipc2redist) {
145 COMPUTE_HASH(ipc2redist, 1, hash_value);
146 }
147
148 // Cf. doc Metis : si options[0] == 1 alors la taille de "options" est 3 ou 4
149 if ((*options) == 1) {
150 COMPUTE_HASH(options, nb_options, hash_value);
151 }
152 else {
153 COMPUTE_HASH(options, 1, hash_value);
154 }
155
156 return _digestString(hash_value);
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162String MetisGraphDigest::
163computeOutputDigest(const MetisGraphView& my_graph, const idx_t* edgecut)
164{
166
167 COMPUTE_HASH1(my_graph.part, hash_value);
168 COMPUTE_HASH(edgecut, 1, hash_value);
169
170 return _digestString(hash_value);
171}
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175} // End namespace Arcane
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
Tableau d'items de types quelconques.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
detail::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets non modifiables.
Definition Span.h:881