Skip to content

Commit 85a6b9b

Browse files
committed
If necessary, output the kernel matrix assembly runtime for each MPI rank separately.
1 parent 1eaccb8 commit 85a6b9b

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

include/plssvm/csvm.hpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141

4242
#include "fmt/color.h" // fmt::fg, fmt::color::orange
4343
#include "fmt/format.h" // fmt::format
44+
#include "fmt/ranges.h" // fmt::join
4445
#include "igor/igor.hpp" // igor::parser
4546

4647
#include <algorithm> // std::max_element, std::all_of
4748
#include <chrono> // std::chrono::{time_point, steady_clock, duration_cast}
4849
#include <cstddef> // std::size_t
50+
#include <cstdint> // std::int64_t
4951
#include <limits> // std::numeric_limits::lowest
5052
#include <memory> // std::unique_ptr
5153
#include <optional> // std::optional, std::make_optional, std::nullopt
@@ -967,10 +969,22 @@ std::tuple<aos_matrix<real_type>, std::vector<real_type>, std::vector<unsigned l
967969
const auto assembly_duration = std::chrono::duration_cast<std::chrono::milliseconds>(assembly_end_time - assembly_start_time);
968970

969971
if (used_solver != solver_type::cg_implicit) {
970-
detail::log(verbosity_level::full | verbosity_level::timing,
971-
comm_,
972-
"Assembled the kernel matrix in {}.\n",
973-
assembly_duration);
972+
if (comm_.size() > 1) {
973+
// gather kernel matrix assembly runtimes from each MPI rank
974+
const std::vector<std::chrono::milliseconds> durations = comm_.gather(assembly_duration);
975+
976+
detail::log(verbosity_level::full | verbosity_level::timing,
977+
comm_,
978+
"Assembled the kernel matrix in {} ({}).\n",
979+
*std::max_element(durations.cbegin(), durations.cend()),
980+
fmt::join(durations, "|"));
981+
982+
} else {
983+
detail::log(verbosity_level::full | verbosity_level::timing,
984+
comm_,
985+
"Assembled the kernel matrix in {}.\n",
986+
assembly_duration);
987+
}
974988
}
975989
PLSSVM_DETAIL_TRACKING_PERFORMANCE_TRACKER_ADD_TRACKING_ENTRY((detail::tracking::tracking_entry{ "kernel_matrix", "kernel_matrix_assembly", assembly_duration }));
976990

0 commit comments

Comments
 (0)