14#include "arcane/utils/Iterator.h"
15#include "arcane/utils/List.h"
16#include "arcane/utils/ScopedPtr.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/StringBuilder.h"
19#include "arcane/utils/IMemoryInfo.h"
20#include "arcane/utils/ITraceMng.h"
21#include "arcane/utils/IProfilingService.h"
22#include "arcane/utils/IMessagePassingProfilingService.h"
23#include "arcane/utils/ValueConvert.h"
24#include "arcane/utils/TimeoutException.h"
25#include "arcane/utils/GoBackwardException.h"
26#include "arcane/utils/OStringStream.h"
27#include "arcane/utils/FloatingPointExceptionSentry.h"
28#include "arcane/utils/JSONWriter.h"
30#include "arcane/core/IApplication.h"
31#include "arcane/core/IServiceLoader.h"
32#include "arcane/core/ISubDomain.h"
33#include "arcane/core/CommonVariables.h"
34#include "arcane/core/IVariableMng.h"
35#include "arcane/core/IEntryPoint.h"
36#include "arcane/core/IEntryPointMng.h"
37#include "arcane/core/IMesh.h"
38#include "arcane/core/IMeshSubMeshTransition.h"
39#include "arcane/core/IModule.h"
40#include "arcane/core/Directory.h"
41#include "arcane/core/IModuleMng.h"
42#include "arcane/core/Timer.h"
43#include "arcane/core/ITimeLoop.h"
44#include "arcane/core/ITimeLoopMng.h"
45#include "arcane/core/TimeLoopEntryPointInfo.h"
46#include "arcane/core/TimeLoopSingletonServiceInfo.h"
47#include "arcane/core/IParallelMng.h"
48#include "arcane/core/IMainFactory.h"
49#include "arcane/core/ICaseMng.h"
50#include "arcane/core/ICaseFunction.h"
51#include "arcane/core/IServiceFactory.h"
52#include "arcane/core/IModuleFactory.h"
53#include "arcane/core/ServiceBuilder.h"
54#include "arcane/core/ServiceInfo.h"
55#include "arcane/core/ServiceUtils.h"
56#include "arcane/core/CaseOptions.h"
57#include "arcane/core/ICaseDocument.h"
58#include "arcane/core/IVerifierService.h"
59#include "arcane/core/IMeshPartitioner.h"
60#include "arcane/core/IVariableFilter.h"
61#include "arcane/core/ITimeStats.h"
62#include "arcane/core/XmlNodeIterator.h"
63#include "arcane/core/ServiceFinder2.h"
64#include "arcane/core/VariableCollection.h"
65#include "arcane/core/Observable.h"
66#include "arcane/core/IParallelReplication.h"
67#include "arcane/core/IItemFamily.h"
68#include "arcane/core/IConfiguration.h"
69#include "arcane/core/IMeshUtilities.h"
70#include "arcane/core/IVariableUtilities.h"
71#include "arcane/core/IItemEnumeratorTracer.h"
72#include "arcane/core/ObservablePool.h"
73#include "arcane/core/parallel/IStat.h"
74#include "arcane/core/IVariableSynchronizer.h"
75#include "arcane/core/IVariableSynchronizerMng.h"
76#include "arcane/core/VariableComparer.h"
78#include "arcane/accelerator/core/IAcceleratorMng.h"
79#include "arcane/accelerator/core/Runner.h"
81#include "arcane/impl/DefaultBackwardMng.h"
106 ModuleState(
bool is_optional,
const String& alias)
108 , m_is_optional(is_optional)
135 ~TimeLoopMng()
override;
139 void build()
override;
165 void setBackwardMng(
IBackwardMng* backward_mng)
override;
174 _createOwnDefaultBackwardMng();
195 void execRestoreEntryPoints();
203 return m_observables[type];
215 const TimeLoopEntryPointInfoCollection& entry_points_info,
274 bool m_stop_time_loop;
275 bool m_stop_has_error;
276 bool m_final_time_reached;
281 bool m_verif_same_parallel;
283 bool m_verification_active;
286 bool m_verification_only_at_exit =
false;
290 bool m_my_own_backward_mng;
299 String m_message_class_name;
315 void _execOneEntryPoint(
IEntryPoint* ic,
Integer index_value = 0,
bool do_verif =
false);
317 void _resetTimer()
const;
318 void _checkVerif(
const String& entry_point_name,
Integer index,
bool do_verif);
319 void _checkVerifSameOnAllReplica(
const String& entry_point_name);
320 void _createOwnDefaultBackwardMng();
324 void _callSpecificEntryPoint();
341TimeLoopMng(ISubDomain* sd)
342: TraceAccessor(sd->traceMng())
344, m_entry_point_mng(m_sub_domain->entryPointMng())
345, m_default_time_loop(nullptr)
346, m_used_time_loop(nullptr)
347, m_current_entry_point_ptr(nullptr)
348, m_stop_time_loop(false)
349, m_stop_has_error(false)
350, m_final_time_reached(false)
351, m_current_entry_point(0)
352, m_verif_type(VerifNone)
353, m_verif_same_parallel(false)
355, m_verification_active(false)
356, m_verification_at_entry_point(false)
357, m_backward_mng(nullptr)
358, m_my_own_backward_mng(false)
359, m_message_class_name(
"TimeLoopMng")
360, m_alarm_timer_value(0)
368 if (!builtInGetValue(v, s))
370 m_alarm_timer_value = v;
376 m_verif_same_parallel =
true;
379 m_observables.add(eTimeLoopEventType::BeginEntryPoint);
380 m_observables.add(eTimeLoopEventType::EndEntryPoint);
381 m_observables.add(eTimeLoopEventType::BeginIteration);
382 m_observables.add(eTimeLoopEventType::EndIteration);
392 ITimeLoop* tm = i->second;
396 if (m_my_own_backward_mng)
413 if (verif_env ==
"READ") {
415 info() <<
"Checking in read mode";
417 if (verif_env ==
"WRITE") {
419 info() <<
"Checking in write mode";
421 if (verif_env ==
"CHECKSYNC") {
423 info() <<
"Checking synchronizations";
425 if (verif_env ==
"CHECKREPLICA") {
427 info() <<
"Checking variables values between replica";
430 m_verification_active =
true;
436 if (s ==
"RELATIVE") {
438 info() <<
"Using 'Relative' method to compute difference of variable values";
440 if (s ==
"LOCALNORMMAX") {
442 info() <<
"Using 'LocalNormMax' method to compute difference of variable values";
450 info() <<
"Do verification at each entry point";
455 if (s ==
"1" || s ==
"true" || s ==
"TRUE") {
456 m_verification_only_at_exit =
true;
457 info() <<
"Do verification only at exit";
466 info() <<
"Use specific entry point: " << s;
471 if (m_verification_active) {
481 if (
subDomain()->parallelMng()->isMasterIO()) {
490 if (!msg_pass_prof_str.null()) {
494 if (msg_pass_prof_str ==
"JSON") {
495 service_name =
"JsonMessagePassingProfiling";
497 else if (msg_pass_prof_str ==
"OTF2") {
498 service_name =
"Otf2MessagePassingProfiling";
500 ServiceBuilder<IMessagePassingProfilingService> srv(this->
subDomain());
501 m_msg_pass_prof_srv = srv.createReference(service_name,
SB_AllowNull);
510_createOwnDefaultBackwardMng()
514 m_my_own_backward_mng =
true;
523 ARCANE_ASSERT((backward_mng), (
"IBackwardMng pointer null"));
527 if (m_my_own_backward_mng)
533 m_my_own_backward_mng =
false;
543 info() <<
"-- Executing init entry points";
550 _execOneEntryPoint(ic);
561 info() <<
"-- Executing build entry points";
566 _execOneEntryPoint(ic);
574execRestoreEntryPoints()
577 info() <<
"-- Executing restore entry points";
581 _execOneEntryPoint(ic);
592 info() <<
"-- Executing entry points after mesh change";
596 info() <<
"Execute: " << ic->
name();
597 _execOneEntryPoint(ic);
608 info() <<
"-- Executing entry points after mesh refinement";
612 info() <<
"Execute: " << ic->
name();
613 _execOneEntryPoint(ic);
624 info() <<
"-- Executing terminal entry points";
628 _execOneEntryPoint(ic);
633 JSONWriter json_writer(JSONWriter::FormatFlags::None);
634 json_writer.beginObject();
635 _dumpTimeInfos(json_writer);
636 json_writer.endObject();
637 traceMng()->
plog() <<
"TimeStats:" << json_writer.getBuffer();
642 if (m_msg_pass_prof_srv.get() && m_msg_pass_prof_srv->implName() ==
"JsonMessagePassingProfiling") {
644 std::ofstream file(fullname.
localstr());
645 m_msg_pass_prof_srv->printInfos(file);
656 m_observables[eTimeLoopEventType::BeginEntryPoint]->notifyAllObservers();
658 m_observables[eTimeLoopEventType::EndEntryPoint]->notifyAllObservers();
661 _checkVerif(ic->
name(), index, do_verif);
670 _checkVerif(name, 0,
true);
677_checkVerif(
const String& entry_point_name,
Integer index,
bool do_verif)
689 if (service_name1.
empty())
690 service_name1 =
"ArcaneBasicVerifier2";
695 warning() <<
"No verification service is available."
696 <<
" No verification will be performed";
700 info() <<
"Use the service <" << service_name1
701 <<
"> for verification";
708 VariableCollection variables(
subDomain()->variableMng()->usedVariables());
709 for (VariableCollection::Enumerator i(variables); ++i;) {
713 if (var->isPartial())
715 VariableComparerResults r = variable_comparer.
apply(var, sync_compare_args);
716 nb_error += r.nbDifference();
719 info() <<
"Error in synchronization nb_error=" << nb_error
720 <<
" entry_point=" << entry_point_name;
725 _checkVerifSameOnAllReplica(entry_point_name);
730 if (current_iter >= 0) {
732 StringBuilder path = Directory(
m_verif_path).file(
"verif_file");
733 if (m_verif_same_parallel) {
738 StringBuilder sub_dir;
740 sub_dir += current_iter;
742 sub_dir += entry_point_name;
750 if (m_verif_same_parallel)
751 parallel_sequential =
false;
757 ServiceFinder2T<IVerifierService,ISubDomain> sf(app,sd);
758 ScopedPtrT<IVerifierService> current_save(sf.find(service_name1));
759 if (current_save.get()){
762 current_save->writeReferenceFile();
770 FloatingPointExceptionSentry fpes(
false);
785_checkVerifSameOnAllReplica(
const String& entry_point_name)
787 info() <<
"CHECK: comparing variables values on all replica"
788 <<
" entry_point_name=" << entry_point_name;
790 IParallelMng* replica_pm = sd->parallelMng()->replication()->replicaParallelMng();
791 IVariableMng* vm = sd->variableMng();
792 VariableCollection variables(vm->usedVariables());
793 VariableList vars_to_check;
794 for (VariableCollection::Enumerator i(variables); ++i;) {
798 if (var->isPartial())
804 vars_to_check.add(var);
806 VariableCollection common_vars = vm->utilities()->filterCommonVariables(replica_pm, vars_to_check,
true);
809 VariableComparer variable_comparer;
811 VariableComparerArgs compare_args = variable_comparer.buildForCheckIfSameOnAllReplica();
812 compare_args.setMaxPrint(10);
813 FloatingPointExceptionSentry fpes(
false);
814 for (VariableCollection::Enumerator ivar(common_vars); ++ivar;) {
815 IVariable* var = *ivar;
816 VariableComparerResults r = variable_comparer.apply(var, compare_args);
817 nb_error += r.nbDifference();
822 info() <<
"Errors in comparing values between replica nb_error=" << nb_error
823 <<
" entry_point=" << entry_point_name;
887 if (current_iteration == 0) {
889 global_iteration = 1;
890 current_iteration = 1;
895 if (m_stop_time_loop) {
896 if (m_stop_has_error)
906 execRestoreEntryPoints();
909 m_mesh_partitioner.clear();
913 bool mesh_partition_done =
false;
914 if (!m_mesh_partitioner.empty()) {
916 mesh_partition_done =
true;
933 bool is_active =
true;
934 f->
value(global_time, is_active);
935 bool mod_disabled = mod->
disabled();
936 bool mod_new_disabled = !is_active;
937 if (mod_new_disabled != mod_disabled) {
938 if (mod_new_disabled)
939 info() <<
"The module " << mod->
name() <<
" is desactivated";
941 info() <<
"The module " << mod->
name() <<
" is activated";
948 m_observables[eTimeLoopEventType::BeginIteration]->notifyAllObservers();
963 _execOneEntryPoint(*i, index,
true);
976 _checkVerif(
"_EndLoop", 0,
true);
978 m_observables[eTimeLoopEventType::EndIteration]->notifyAllObservers();
981 bool force_prepare_dump =
false;
983 if (!m_verif_same_parallel)
984 force_prepare_dump =
true;
988 if (force_prepare_dump_str ==
"TRUE" || force_prepare_dump_str ==
"1" || force_prepare_dump_str ==
"true")
989 force_prepare_dump =
true;
991 if (force_prepare_dump) {
992 info() <<
"TimeLoopMng::doOneIteration(): Force prepareDump()";
998 if (m_stop_time_loop) {
999 if (m_stop_has_error)
1025 IMesh*
mesh = mesh_partitioner->primaryMesh();
1029 mesh->utilities()->partitionAndExchangeMeshWithReplication(mesh_partitioner,
false);
1031 info() <<
"Time spent to repartition the mesh (unit: second): "
1042 JSONWriter json_writer(JSONWriter::FormatFlags::None);
1043 json_writer.beginObject();
1044 json_writer.write(
"Mesh",
mesh->name());
1045 json_writer.write(
"Iteration", current_iteration);
1046 json_writer.write(
"CommunicatingRanks", communicating_ranks);
1047 json_writer.endObject();
1048 plog() <<
"MeshPartitionCommunicatingInfos:" << json_writer.getBuffer();
1054 Timer::Action ts_action1(sd,
"OnMeshChangeEntryPoints",
true);
1058 m_mesh_partitioner.clear();
1068_callSpecificEntryPoint()
1088 log() <<
"Registering the time loop " << name;
1092 ARCANE_FATAL(
"The time loop '{0}' is defined twice", name);
1116 info() <<
"Available time loops: ";
1118 info() <<
"Time loop <" << tl.second->name() <<
">";
1123 logdate() <<
"Using time loop " << name;
1131 service_loader->loadModules(sd,
false);
1138 for (
const auto& it : m_module_state_list) {
1141 if (!module_state.m_is_optional || module_state.m_is_active) {
1144 ARCANE_FATAL(
"The module \"{0}\" was not created.", module_state.m_alias);
1147 info() <<
"The entry points of the module \""
1148 << module_state.m_alias <<
"\" won't be executed (inactive module).";
1152 _createSingletonServices(service_loader.
get());
1203 auto_load_ends.add(ic);
1206 for (
Integer i = 0, s = auto_load_ends.
count(); i < s; ++i) {
1225 if (ti.isRequired())
1226 ARCANE_FATAL(
"Unable to find a singleton service named '{0}'", name);
1227 info() <<
"The optional singleton service named '" << name <<
"' was not found";
1229 info() <<
"Loading singleton service '" << name <<
"'";
1234 ICaseDocument* doc = cm->caseDocument();
1236 XmlNode services_element = doc->servicesElement();
1237 String ustr_name(
"name");
1238 String ustr_active(
"active");
1239 XmlNodeList services = services_element.children(
"service");
1240 for (XmlNode x : services) {
1241 String name = x.attrValue(ustr_name);
1242 XmlNode active_node = x.attr(ustr_active);
1243 bool is_active =
true;
1244 if (!active_node.null())
1245 is_active = active_node.valueAsBoolean(
true);
1257 const TimeLoopEntryPointInfoCollection& entry_points_info,
1264 const String& timeloop_call_name = entry_point_info.name();
1269 auto it = m_module_state_list.find(module_name);
1270 if (it == m_module_state_list.end())
1271 ARCANE_FATAL(
"No module named '{0}' is referenced", module_name);
1274 if (!module_state.m_is_optional || module_state.m_is_active) {
1275 if (!module_state.m_alias.
null())
1276 module_name = module_state.m_alias;
1279 call_alias += entry_point_name;
1282 log() <<
"Looking for entry point '" << call_alias <<
"'";
1284 ARCANE_FATAL(
"No entry point named '{0}' is referenced", call_alias);
1290 msg() <<
"The entry point '" << call_alias <<
"' declared \"" << ep_where
1291 <<
"\" can't be in the entry point list \""
1292 << where <<
"\" of the time loop";
1306 entry_points.add(entry_point);
1320 const String& module_name = *i;
1322 m_module_state_list.insert(ModuleStateMap::value_type(module_name, ms));
1327 const String& module_name = *i;
1329 m_module_state_list.insert(ModuleStateMap::value_type(module_name, ms));
1342 String ustr_module(
"module");
1343 String ustr_false(
"false");
1344 String ustr_name(
"name");
1345 String ustr_alias(
"alias");
1346 String ustr_active(
"active");
1348 if (i->name() != ustr_module)
1355 XmlNode active_node = module_node.
attr(ustr_active);
1357 if (!active_node.
null())
1366 name = ilang->second->moduleName();
1368 auto it = m_module_state_list.find(name);
1369 if (it == m_module_state_list.end())
1372 ARCANE_FATAL(
"Error in configuring active modules: no module named '{0}' is registered.",
1376 ms.m_is_active = active;
1380 if (!ms.m_is_optional && !ms.m_is_active) {
1381 pwarning() <<
"The module \"" << ms.m_alias
1382 <<
"\" can't be declared mandatory in the time loop"
1383 <<
" while being inactive in the input data."
1384 <<
" Its activity is therefore forced. ";
1385 ms.m_is_active =
true;
1396 String& entry_point_name)
1398 std::string std_timeloop_call_name(timeloop_call_name.
localstr());
1399 size_t index = std_timeloop_call_name.find_first_of(
'.');
1400 if (index == std::string::npos) {
1401 ARCANE_FATAL(
"The string '{0}' is not a valid reference to an entry point (has to be of type "
1402 "'module_name.entry_point_name)",
1403 timeloop_call_name);
1405 std::string std_module_name = std_timeloop_call_name.substr(0, index);
1406 std::string std_entry_point_name = std_timeloop_call_name.substr(index + 1);
1407 module_name = std_module_name;
1408 entry_point_name = std_entry_point_name;
1432 ARCANE_FATAL(
"Two modules with same name '{0}'", module_name);
1434 info(5) <<
"Registering module in factory map name=" << module_name;
1441 warning() <<
"Two modules with same translated name=" << translated_name
1442 <<
" ignoring name=" << module_name;
1446 info(5) <<
"Registering module in lang factory map name=" << translated_name;
1463 info() <<
"Loading module " <<
module->name()
1464 << " (Version " << module->versionInfo() << ")";
1480 log() <<
"Adding the entry point `" << entry_point->
module()->
name() <<
"::" << entry_point->
name() <<
"' to the execution";
1489 else if (where == IEntryPoint::WExit) {
1512 debug() <<
"Adding the module `" << c->
name() <<
"' to the execution";
1531 Real total_real_time = 0.0;
1532 Real compute_real_time = 0.0;
1533 json_writer.writeKey(
"EntryPoints");
1534 json_writer.beginArray();
1540 json_writer.write(
"Name", ep->
name());
1541 json_writer.write(
"TotalCpuTime", s2);
1542 json_writer.write(
"TotalElapsedTime", s2);
1544 json_writer.write(
"Where", ep->
where());
1546 info(5) <<
"CPU_TIME where=" << ep->
where() <<
" name=" << ep->
name() <<
" S=" << s2;
1547 total_real_time += s2;
1549 compute_real_time += s2;
1552 json_writer.endArray();
1553 info(4) <<
"TOTAL_REAL_TIME COMPUTE=" << compute_real_time <<
" TOTAL=" << total_real_time;
1557 info() <<
"Information on the execution time";
1559 Accelerator::IAcceleratorMng* acc_mng =
m_sub_domain->acceleratorMng();
1560 if (acc_mng->isInitialized()) {
1561 Accelerator::Runner* runner = acc_mng->defaultRunner();
1562 info() <<
" TotalRunner (" << runner->executionPolicy() <<
") = "
1563 << runner->cumulativeCommandTime() <<
" seconds";
1566 info() <<
" TotalElapsed = " << total_exec_time <<
" seconds";
1567 info() <<
" CumulativeElapsed = " << scv.globalElapsedTime()
1569 info() <<
" T = Total time spent in the function or in the module (s)";
1570 info() <<
" TC = Total time spend per call (ms)";
1571 info() <<
" TCC = Total time spent per call and per cell (ns)";
1572 info() <<
" N = Number of time the function was called";
1574 info() <<
" Use the clock time (elapsed) for the statistics";
1576 std::ostringstream o;
1577 std::ios_base::fmtflags f = o.flags(std::ios::right);
1581 nb_cell = mesh->
nbCell();
1585 o <<
"\n Name T TC TCC % N\n";
1588 IModule* module = *j;
1589 Real total_time_module = 0.;
1590 Real total_time_module_entry_point = 0.;
1592 IEntryPoint* ic = *i;
1593 if (ic->module() != module)
1598 Real total_time = ic->totalElapsedTime();
1601 const String& ep_name = ic->name();
1603 Int64 l = ep_name.length();
1605 o.write(ep_name.localstr(), 34);
1616 Real r = (1e3 * total_time) / nb_call;
1618 total_time_module += r;
1619 total_time_module_entry_point += total_time;
1624 r = (r * 1e6) / nb_cell;
1629 if (total_exec_time > 0)
1641 o << module->name();
1649 Real r = (total_time_module * 1e6) / nb_cell;
1661 if (pm->isParallel()) {
1662 JSONWriter::Object jo(json_writer,
"MessagePassingStats");
1663 Parallel::IStat* s = pm->stat();
1665 s->printCollective(pm);
1666 s->dumpJSON(json_writer);
1671 JSONWriter::Object jo(json_writer,
"VariablesStats");
1672 m_sub_domain->variableMng()->dumpStatsJSON(json_writer);
1675 JSONWriter::Object jo(json_writer,
"TimeStats");
1681 JSONWriter::Object jo(json_writer,
"Profiling");
1682 ps->dumpJSON(json_writer);
1696 Real total_elapsed_time = 0.0;
1698 Real s1 = (*i)->totalElapsedTime();
1699 total_elapsed_time += s1;
1701 return total_elapsed_time;
1711 _createOwnDefaultBackwardMng();
1725 _createOwnDefaultBackwardMng();
1737 names.add(i->first);
1747 time_loops.add(i->second);
1766 m_stop_reason = reason;
1775 m_stop_time_loop =
true;
1776 m_stop_has_error = has_error;
1778 m_final_time_reached =
true;
1781 else if (is_final_time)
1796 _createOwnDefaultBackwardMng();
1799 info() <<
"Repartioning required but inactive due to a backward process active";
1802 m_mesh_partitioner.add(mesh_partitioner);
1812 bool is_end =
false;
1813 bool is_end_by_max_loop =
false;
1817 if (m_alarm_timer_value > 0) {
1818 info() <<
"Set the timeout before alarm at " << m_alarm_timer_value <<
" seconds";
1823 _createOwnDefaultBackwardMng();
1826 bool want_specific_profiling =
false;
1832 info() <<
"Specific profiling activated";
1833 want_specific_profiling =
true;
1842 Int64 block_size = 0;
1843 bool is_bad = builtInGetValue(block_size, s);
1844 if (!is_bad && block_size > 2) {
1845 info() <<
"Set Memory StackTraceMinAllocSize to " << block_size;
1852 if (m_msg_pass_prof_srv.get())
1853 m_msg_pass_prof_srv->startProfiling();
1863 if (want_specific_profiling)
1867 _callSpecificEntryPoint();
1871 if (max_loop != 0 && m_nb_loop >= max_loop) {
1872 info() <<
"===================================================";
1873 info() <<
"====== MAXIMUM NUMBER OF ITERATION REACHED =======";
1874 info() <<
"===================================================";
1875 is_end_by_max_loop =
true;
1881 if (max_loop != 0 && (1 + m_nb_loop) >= max_loop) {
1886 if (mem_info && mem_info->isCollecting()) {
1887 mem_info->endCollect();
1891 std::ostringstream ostr;
1893 mem_info->printAllocatedMemory(ostr, iteration - 1);
1895 mem_info->printAllocatedMemory(ostr, iteration - 2);
1897 mem_info->printAllocatedMemory(ostr, iteration - 5);
1898 info() <<
"ITERATION_MemoryInfo: " << ostr.str();
1899 mem_info->beginCollect();
1908 if (m_msg_pass_prof_srv.get())
1909 m_msg_pass_prof_srv->stopProfiling();
1918 if (m_verification_only_at_exit) {
1919 info() <<
"Doing verification at exit";
1927 if (m_msg_pass_prof_srv.get())
1928 m_msg_pass_prof_srv->stopProfiling();
1929 if (IItemEnumeratorTracer::singleton())
1930 IItemEnumeratorTracer::singleton()->dumpStats();
1931 info() <<
"End of compute loop: reason=" << (int)m_stop_reason;
1932 if (is_end_by_max_loop)
1934 if (m_final_time_reached)
1948 if (m_alarm_timer_value > 0)
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Integer count() const
Number of elements in the collection.
bool empty() const
True if the collection is empty.
EnumeratorT< ICaseOptions * > Enumerator
VariableScalarInt32 m_global_iteration
Current iteration.
Real globalTime() const
Current time.
Int32 globalIteration() const
Current iteration number.
Constant iterator interval.
const String & additionalInfo() const
Returns the additional information.
Exception to request a backward step in the time loop.
virtual IMainFactory * mainFactory() const =0
Main factory.
virtual String userName() const =0
User name.
Interface managing backward strategies.
virtual ITraceMng * traceMng() const =0
Trace manager.
Interface of a part of a dataset.
virtual String language() const =0
Language used in the dataset.
Interface of a class managing an XML document of the dataset.
virtual XmlNode modulesElement()=0
Returns the element containing the module descriptions.
Interface of a dataset function.
virtual void value(Real param, Real &v) const =0
Value v of the option for parameter param.
virtual CaseOptionsCollection blocks() const =0
Collection of option blocks.
virtual ICaseDocument * caseDocument()=0
XML document of the dataset (can be null if no dataset).
Interface for a list of data set options.
virtual ICaseFunction * activateFunction()=0
Function indicating the activation status of the option.
virtual IModule * caseModule() const =0
Returns the associated module or nullptr if none exists.
virtual void merge(const IConfiguration *c)=0
Merges this configuration with configuration c.
Interface for the entry point manager.
virtual IEntryPoint * findEntryPoint(const String &s)=0
Entry point by name s.
virtual EntryPointCollection entryPoints()=0
List of entry points.
Interface of a module entry point.
virtual void executeEntryPoint()=0
Calls the entry point.
virtual Real totalElapsedTime() const =0
Elapsed execution time (clock time) in this entry point (in milliseconds).
static const char *const WComputeLoop
called during the calculation loop
static const char *const WBuild
called for module construction
static const char *const WStartInit
called during new case initialization
static const char *const WRestore
called to restore variables during a rollback
virtual Integer nbCall() const =0
Returns the number of times the entry point has been executed.
static const char *const WOnMeshRefinement
called after mesh refinement
@ PAutoLoadEnd
Automatically loaded at the end. This means that a module possessing an entry point with this propert...
@ PAutoLoadBegin
Automatically loaded at the beginning. This means that a module possessing an entry point with this p...
virtual int property() const =0
Returns the properties of the entry point.
static const char *const WOnMeshChanged
called after a mesh change
static const char *const WContinueInit
called during continuation initialization
virtual String where() const =0
Returns where the entry point is called.
static const char *const WInit
called during initialization
virtual IModule * module() const =0
Returns the module associated with the entry point.
virtual String name() const =0
Returns the name of the entry point.
Interface of an entity family.
virtual IVariableSynchronizer * allItemsSynchronizer()=0
Synchronizer on all entities of the family.
virtual IServiceLoader * createServiceLoader()=0
Creates an instance of the service loader.
virtual ITimeLoop * createTimeLoop(IApplication *sm, const String &name)=0
Creates a time loop named name.
Interface for a memory usage information collector.
virtual void setIteration(Integer iteration)=0
Sets the current iteration number.
virtual void setStackTraceMinAllocSize(Int64 alloc_size)=0
Sets the minimum size of allocations whose call stack is traced.
virtual Integer nbCell()=0
Number of mesh cells.
Interface of a mesh partitioner.
virtual void prepareForDump()=0
Prepares the instance for dumping.
Information about a module factory.
virtual String moduleName() const =0
Name of the module created by this factory.
virtual Ref< IModule > createModule(ISubDomain *parent, const MeshHandle &mesh_handle)=0
Creates a module.
virtual const IServiceInfo * serviceInfo() const =0
Information about the module that can be created by this factory.
Module manager interface.
virtual ModuleCollection modules() const =0
List of modules.
virtual void setUsed(bool v)=0
Indicates whether a module is used or not (internal).
virtual String name() const =0
Module name.
virtual bool disabled() const =0
true if the module is disabled
virtual void setDisabled(bool v)=0
Temporarily activates or deactivates the module (internal).
Interface of an observable.
Interface of the parallelism manager for a subdomain.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual IParallelReplication * replication() const =0
Replication information.
virtual bool isParallel() const =0
Returns true if the execution is parallel.
virtual bool hasReplication() const =0
Indicates if replication is active.
Interface of a profiling service.
virtual bool isInitialized() const
Indicates if initialize() has already been called.
virtual void initialize()=0
Initializes the profiling service.
virtual void reset()=0
Resets the counters.
virtual void printInfos(bool dump_file=false)=0
Displays profiling information.
Interface for service or module information.
virtual String tagName(const String &lang) const =0
Name of the service XML element for the language lang. If lang is null, returns the default name.
Service loading interface.
virtual bool loadSingletonService(ISubDomain *sd, const String &name)=0
Loads the subdomain singleton service with name name.
Interface of the subdomain manager.
virtual IModuleMng * moduleMng()=0
Returns the module manager.
virtual const CommonVariables & commonVariables() const =0
Information on standard variables.
virtual IMesh * defaultMesh()=0
Default mesh.
virtual ITimeStats * timeStats() const =0
Execution time statistics.
virtual IApplication * application()=0
Application.
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
virtual const IConfiguration * configuration() const =0
Associated configuration.
virtual IVariableMng * variableMng()=0
Returns the variable manager.
virtual IMainFactory * mainFactory()=0
Main factory.
virtual ICaseMng * caseMng()=0
Returns the dataset manager.
Interface for the time loop manager.
Interface of a time loop.
static const char * WRestore
called to restore variables during a rollback
virtual StringCollection optionalModulesName() const =0
List of names of optional modules.
static const char * WOnMeshChanged
called after a mesh change
static const char * WExit
called upon termination of the code.
virtual StringCollection requiredModulesName() const =0
List of names of required modules.
virtual TimeLoopSingletonServiceInfoCollection singletonServices() const =0
List of singleton services.
static const char * WOnMeshRefinement
called after mesh refinement
static const char * WBuild
called when reading the dataset
static const char * WComputeLoop
called during the calculation loop
static const char * WInit
called during initialization, initialization of a restart, or a new case
virtual String name() const =0
Name of the time loop.
virtual void dumpCurrentStats(const String &name)=0
Displays statistics for an action.
virtual void notifyNewIterationLoop()=0
Notifies that a new iteration of the calculation loop begins.
virtual void flush()=0
Flushes all streams.
virtual TraceMessage plog()=0
Stream for a parallel log message.
virtual IVariableSynchronizerMng * synchronizerMng() const =0
Interface of the variable synchronization manager.
virtual void flushPendingStats()=0
Processes pending statistics.
Interface of a variable synchronization service.
virtual Int32ConstArrayView communicatingRanks()=0
Ranks of subdomains with which communication occurs.
@ PNoReplicaSync
Indicates that the variable does not necessarily have the same value across replicas.
@ PNoNeedSync
Indicates that the variable is not necessarily synchronized.
ListEnumeratorT< IEntryPoint * > Enumerator
Output stream linked to a String.
Class allowing automatic start and stop of a service.
T * get() const
Returns the object referenced by the instance.
InstanceType * get() const
Associated instance or nullptr if none.
Reference to an instance.
Encapsulation of an automatically destructing pointer.
Utility class to find one or more services implementing the InterfaceType interface.
Unicode character string constructor.
Unicode character string.
bool null() const
Returns true if the string is null.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
bool empty() const
True if the string is empty (null or "").
Info about a time loop entry point.
bool finalTimeReached() const override
Returns true if the final time has been reached.
IObservable * observable(eTimeLoopEventType type) override
Observable on the instance.
ModuleFactoryMap m_module_factory_map
State of all referenced modules.
TimeLoopMap m_time_loop_list
List of time loops.
void registerActionMeshPartition(IMeshPartitionerBase *mesh_partitioner) override
Schedules a mesh partitioning using the partition tool mesh_partitioner.
EntryPointCollection usedTimeLoopEntryPoints() override
List of all entry points for the current time loop.
void _processEntryPoints(EntryPointList &entry_points, const TimeLoopEntryPointInfoCollection &entry_points_info, const char *where)
Adds the entry points proposed in entry_points_info to the list entry_points.
@ VerifSameReplica
Checks that variables are synchronized.
@ VerifWrite
Indicates that values are generated for checking.
@ VerifNone
Indicates that no checks are performed.
@ VerifRead
Indicates that values are reread and checked.
ITimeLoop * createTimeLoop(const String &name) override
Creates a time loop named name.
std::map< String, ITimeLoop * > TimeLoopMap
List of time loops.
EntryPointList m_exit_entry_points
List of entry points to execute upon termination.
EntryPointCollection loopEntryPoints() override
Returns the list of 'ComputeLoop' type entry points in the time loop.
ITimeLoop * usedTimeLoop() const override
Returns the time loop used.
EntryPointList m_on_mesh_changed_entry_points
List of entry points to execute after a mesh change.
ITimeLoop * m_default_time_loop
Default time loop.
void doVerification(const String &name) override
Performs a verification.
void stopComputeLoop(bool is_final_time, bool has_error) override
Indicates that the compute loop must stop.
void execInitEntryPoints(bool is_continue) override
Executes the initialization entry points.
std::map< String, ModuleState > ModuleStateMap
List of module states.
IEntryPoint * nextEntryPoint() override
Returns the next function to call.
bool _createModule(const String &module_name)
Creates a module from its name.
eTimeLoopStopReason stopReason() const override
Reason for stopping the code.
void doExecNextEntryPoint(bool &is_last) override
void execExitEntryPoints() override
Executes the exit entry points.
static void _extractModuleAndEntryPointName(const String &timeloop_call_name, String &module_name, String &entry_point_name)
EntryPointList m_build_entry_points
List of entry points to execute during build.
EntryPointList m_used_time_loop_entry_points
List of all entry points of the used time loop.
Integer m_current_entry_point
Next entry point to execute.
int doOneIteration() override
Starts the execution of a compute loop iteration.
void execOnMeshRefinementEntryPoints() override
Executes the entry points after refinement.
ISubDomain * subDomain() const override
< Returns the sub-domain manager
std::map< String, IModuleFactoryInfo * > ModuleFactoryMap
List of module factories indexed by their name.
bool m_verification_at_entry_point
If true, performs checks at every entry point, otherwise only at the end of the iteration.
void timeLoops(TimeLoopCollection &time_loops) const override
Returns in time_loops the list of time loops.
EntryPointList m_restore_entry_points
List of entry points to execute during a backward step.
EntryPointList m_on_mesh_refinement_entry_points
List of entry points to execute after a refinement.
ISubDomain * m_sub_domain
Sub-domain manager.
ModuleFactoryMap m_lang_module_factory_map
List of module factories.
Integer nbLoop() const override
Number of compute loops performed.
bool isDoingBackward() override
True if currently in a backward step.
int doComputeLoop(Integer max_loop) override
Executes the compute loop.
void timeLoopsName(StringCollection &names) const override
Returns in names the list of time loop names.
void goBackward() override
Performs a backward step.
void setStopReason(eTimeLoopStopReason reason) override
Positions the reason for stopping the code.
EntryPointList m_loop_entry_points
List of entry points to execute.
IEntryPointMng * m_entry_point_mng
Entry point manager.
EntryPointList m_init_entry_points
List of entry points to execute during initialization.
String m_specific_entry_point_name
For testing, specific entry point to call.
ModuleList m_list_execute_module
List of modules to execute.
Real cpuTimeUsed() const override
Returns the CPU time used in seconds.
void execBuildEntryPoints() override
Executes the build entry points.
void setBackwardSavePeriod(Integer n) override
Positions the period between two saves for backward step. If this value is null, backward step is dis...
IEntryPoint * m_current_entry_point_ptr
Currently executing entry point.
IBackwardMng * m_backward_mng
Backward manager;.
ITimeLoop * m_used_time_loop
Used time loop.
void setUsedTimeLoop(const String &name) override
Positions the time loop to be executed. Selects the time loop named name as the one to be executed....
eVerifType m_verif_type
Verification type.
void _fillModuleStateMap(ITimeLoop *time_loop)
void _doMeshPartition()
Performs a mesh partitioning.
void execOnMeshChangedEntryPoints() override
Executes the entry points after load balancing.
void _addExecuteEntryPoint(IEntryPoint *)
Adds an entry point to execute.
IEntryPoint * currentEntryPoint() override
Returns the entry point currently being executed or 0 if there is none.
void _fillModuleFactoryMap()
Fills m_module_factory_map with the list of available factories.
void registerTimeLoop(ITimeLoop *timeloop) override
Registration and selection of the time loop.
Ref< IVerifierService > m_verifier_service
List of module factories in the data file language.
String m_verif_path
Save/read directory for verifications.
void setVerificationActive(bool is_active) override
Positions the state of the verification mode.
Info of a time loop singleton service.
Exception when a timeout occurs.
Positions the name of the currently executing action.
Sentinel for the timer. The sentinel associated with a timer allows it to be triggered upon its const...
@ TimerReal
Timer using real time.
Real lastActivationTime() const
Returns the time (in seconds) spent during the last activation of the timer.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage pinfo() const
Flow for a parallel information message.
TraceMessage logdate() const
Flow for a log message preceded by the date.
TraceMessage log() const
Flow for a log message.
TraceMessage info() const
Flow for an information message.
TraceMessage warning() const
Flow for a warning message.
TraceMessage plog() const
Flow for a log message.
ITraceMng * traceMng() const
Trace manager.
TraceMessage pwarning() const
Formatting the stream by length.
1D data vector with value semantics (STL style).
Arguments for VariableComparer methods.
void setMaxPrint(Int32 v)
Sets the number of errors to display in the listing.
Class to perform comparisons between variables.
VariableComparerResults apply(IVariable *var, const VariableComparerArgs &compare_args)
Applies the comparison compare_args to the variable var.
VariableComparerArgs buildForCheckIfSync()
Creates a comparison to verify that a variable is synchronized.
XmlNode attr(const String &name, bool throw_exception=false) const
Returns the attribute of name name.
String attrValue(const String &name, bool throw_exception=false) const
Value of attribute name.
bool null() const
True if the node is null.
ConstIterT< XmlNode > const_iter
Type of a constant iterator over the entire array.
bool valueAsBoolean(bool throw_exception=false) const
Node value converted to boolean.
VariableRefScalarT< Integer > VariableScalarInteger
Scalar variable of integer type.
Int64 toInt64(Real r)
Converts a Real to Int64.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ SB_AllowNull
Allows the service to be absent.
eTimeLoopStopReason
Reason for stopping the code.
@ MaxIterationReached
Stop because maximum number of iterations specified was reached.
@ NoStop
Indicates that the code is not yet in stop mode.
@ FinalTimeReached
Stop because final time was reached.
@ NoReason
No specific reason.
@ Error
Stop due to an error.
std::int64_t Int64
Signed integer type of 64 bits.
eVariableComparerComputeDifferenceMethod
Method used to calculate the difference between two values v1 and v2.
@ Relative
Uses (v1-v2) / v1.
@ LocalNormMax
Uses (v1-v2) / local_norm_max.
Int32 Integer
Type representing an integer.
Collection< String > StringCollection
Collection of strings.
List< IModule * > ModuleList
Array of modules.
List< IEntryPoint * > EntryPointList
Array of entry points.
Collection< ICaseOptions * > CaseOptionsCollection
Collection of dataset options.
Collection< ITimeLoop * > TimeLoopCollection
Collection of time loops.
Collection< IModuleFactoryInfo * > ModuleFactoryInfoCollection
Collection of module factory information.
double Real
Type representing a real number.
Collection< IEntryPoint * > EntryPointCollection
Collection of entry points.
@ DT_String
UTF-8 character string data type.