Skip to content

Commit cafb414

Browse files
committed
feature: output math lib logs on all ranks.
1 parent c7bd18c commit cafb414

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

source/module_base/gather_math_lib_info.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
// This file defines the math lib wrapper for output information before executing computations.
2+
3+
/*
4+
When INFO is defined in cmake configure, a macro of GATHER_INFO will be defined.
5+
This macro will be used to output information before executing computations.
6+
Results will output to OUT/math_info.log, see ModuleBase::Global_File::make_dir_out .
7+
*/
8+
29
#include <ostream>
310
#undef GATHER_INFO
411
#include "module_base/blas_connector.h"

source/module_base/global_file.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ void ModuleBase::Global_File::make_dir_out(
142142
if(rank==0)
143143
{
144144
open_log(GlobalV::ofs_warning, "warning", calculation, restart);
145+
}
146+
145147
#ifdef GATHER_INFO
146-
open_log(GlobalV::ofs_info, "math_info", calculation, restart);
148+
open_log(GlobalV::ofs_info, "math_info_" + std::to_string(rank), calculation, restart);
147149
#endif
148-
}
150+
149151
return;
150152
}
151153

@@ -224,10 +226,11 @@ void ModuleBase::Global_File::close_all_log(const int rank, const bool out_alllo
224226
if (rank==0)
225227
{
226228
close_log(GlobalV::ofs_warning, "warning.log");
229+
}
230+
227231
#ifdef GATHER_INFO
228-
close_log(GlobalV::ofs_info, "math_info");
232+
close_log(GlobalV::ofs_info, "math_info");
229233
#endif
230-
}
231234
return;
232235
}
233236
}

source/module_base/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ remove_definitions(-D__MPI)
22
AddTest(
33
TARGET base_blas_connector
44
LIBS ${math_libs}
5-
SOURCES blas_connector_test.cpp ../gather_math_lib_info.cpp
5+
SOURCES blas_connector_test.cpp
66
)
77
AddTest(
88
TARGET base_timer

0 commit comments

Comments
 (0)