14#include "arcane/utils/Array.h"
15#include "arcane/utils/Iostream.h"
16#include "arcane/utils/String.h"
18#include "arcane/impl/VariableUtilities.h"
20#include "arcane/core/IVariable.h"
21#include "arcane/core/IParallelMng.h"
22#include "arcane/core/IVariableMng.h"
23#include "arcane/core/VariableDependInfo.h"
24#include "arcane/core/VariableCollection.h"
25#include "arcane/core/SerializeBuffer.h"
59void VariableUtilities::
60dumpAllVariableDependencies(std::ostream& ostr,
bool is_recursive)
63 for (VariableCollection::Enumerator ivar(used_variables); ++ivar;) {
72void VariableUtilities::
73dumpDependencies(
IVariable* var, std::ostream& ostr,
bool is_recursive)
76 _dumpDependencies(var, ostr, is_recursive);
82void VariableUtilities::
83_dumpDependencies(
IVariable* var, std::ostream& ostr,
bool is_recursive)
85 std::set<IVariable*> done_vars;
86 done_vars.insert(var);
96 <<
" nb_depend=" << nb_depend
101 for (
Integer i = 0; i < nb_depend; ++i) {
102 _dumpDependencies(depends[i], ostr, is_recursive, done_vars, 2);
111void VariableUtilities::
112_dumpDependencies(VariableDependInfo& vdi, std::ostream& ostr,
bool is_recursive,
113 std::set<IVariable*>& done_vars, Integer indent_level)
115 IVariable* var = vdi.variable();
116 bool no_cycle = done_vars.find(var) == done_vars.end();
117 bool do_depend = no_cycle;
120 done_vars.insert(var);
122 std::string indent_str;
123 for (Integer i = 0; i < indent_level; ++i)
124 indent_str.push_back(
' ');
126 UniqueArray<VariableDependInfo> depends;
127 var->dependInfos(depends);
128 Integer nb_depend = depends.size();
132 <<
" time=" << var->modifiedTime()
133 <<
" nb_depend=" << nb_depend
134 <<
" trace_info=" << vdi.traceInfo();
139 if (do_depend && nb_depend != 0) {
140 ostr << indent_str <<
"{\n";
141 for (Integer i = 0; i < nb_depend; ++i) {
142 _dumpDependencies(depends[i], ostr,
true, done_vars, indent_level + 2);
144 ostr << indent_str <<
"}\n";
163 bool dump_not_common)
166 for (VariableCollection::Enumerator i(input_variables); ++i;)
167 vars_to_check.
add(*i);
170 info(4) <<
"CHECK: nb_variable_to_compare=" << nb_var;
174 send_buf.
setMode(ISerializer::ModeReserve);
175 send_buf.reserveInteger(1);
176 for (
Integer i = 0; i < nb_var; ++i) {
177 send_buf.
reserve(vars_to_check[i]->fullName());
183 for (
Integer i = 0; i < nb_var; ++i) {
184 send_buf.
put(vars_to_check[i]->fullName());
191 std::map<String, Int32> var_occurences;
195 for (
Integer i = 0; i < nb_rank; ++i) {
197 info(5) <<
"String recv_nb_var_rank rank=" << i <<
" n=" << nb_var_rank;
198 for (
Integer z = 0; z < nb_var_rank; ++z) {
201 std::map<String, Int32>::iterator vo = var_occurences.find(x);
202 if (vo == var_occurences.end())
203 var_occurences.insert(std::make_pair(x, 1));
205 vo->second = vo->second + 1;
212 std::map<String, IVariable*> common_vars;
214 std::map<String, Int32>::const_iterator end_var = var_occurences.end();
215 for (
Integer i = 0; i < nb_var; ++i) {
217 std::map<String, Int32>::const_iterator i_var = var_occurences.find(var->
fullName());
218 if (i_var == end_var)
221 if (i_var->second != nb_rank) {
223 info() <<
"ERROR: can not compare variable '" << var->
fullName()
224 <<
"' because it is not defined on all replica nb_define=" << i_var->second;
227 common_vars.insert(std::make_pair(var->
fullName(), var));
234 VariableList sorted_common_vars;
236 std::map<String, IVariable*>::const_iterator end_var = common_vars.end();
237 std::map<String, IVariable*>::const_iterator i_var = common_vars.begin();
238 for (; i_var != end_var; ++i_var) {
239 sorted_common_vars.add(i_var->second);
243 return sorted_common_vars;
Integer size() const
Number of elements in the vector.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void put(Span< const Real > values) override
Add the array values.
void reserve(eBasicDataType dt, Int64 n) override
Reserves memory for n objects of type dt.
void allocateBuffer() override
Allocates the serializer memory.
Integer getInteger() override
Retrieve a size.
void get(ArrayView< Real > values) override
Retrieve the array values.
void setMode(eMode new_mode) override
Sets the current mode.
void putInteger(Integer value) override
Add the integer value.
Interface of the parallelism manager for a subdomain.
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual void allGather(ConstArrayView< char > send_buf, ArrayView< char > recv_buf)=0
Performs an all-gather operation across all processors. This is a collective operation....
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
Variable manager interface.
virtual String fullName() const =0
Full variable name (with family prefix).
virtual Int64 modifiedTime()=0
Time when the variable was updated.
virtual void dependInfos(Array< VariableDependInfo > &infos)=0
Dependency information.
Implementation of a buffer for serialization.
Unicode character string.
TraceMessage info() const
Flow for an information message.
1D data vector with value semantics (STL style).
virtual void dumpDependencies(IVariable *var, std::ostream &ostr, bool is_recursive)
Displays dependency information for a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.