From af94e5c0bdc876c39882cabb5918cf36bba7f064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 8 Aug 2024 16:50:39 +0200 Subject: [PATCH] TMP: Debug --- include/openPMD/auxiliary/StringManip.hpp | 26 ++++++++++++++++--- src/ChunkInfo.cpp | 20 ++++++++++++++ .../python/openpmd_api/pipe/__main__.py | 2 +- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/include/openPMD/auxiliary/StringManip.hpp b/include/openPMD/auxiliary/StringManip.hpp index 36778f205f..2e3bb94c9c 100644 --- a/include/openPMD/auxiliary/StringManip.hpp +++ b/include/openPMD/auxiliary/StringManip.hpp @@ -195,26 +195,44 @@ namespace auxiliary return s.substr(begin - s.begin(), end.base() - begin); } + template inline std::string - join(std::vector const &vs, std::string const &delimiter) + join_generic(std::vector const &vs, std::string const &delimiter) { + auto as_string = [](T const &t) { + if constexpr (std::is_same_v) + { + return t; + } + else + { + return std::to_string(t); + } + }; switch (vs.size()) { case 0: return ""; case 1: - return vs[0]; + return as_string(vs[0]); default: std::ostringstream ss; - std::copy( + std::transform( vs.begin(), vs.end() - 1, - std::ostream_iterator(ss, delimiter.c_str())); + std::ostream_iterator(ss, delimiter.c_str()), + as_string); ss << *(vs.end() - 1); return ss.str(); } } + inline std::string + join(std::vector const &vs, std::string const &delimiter) + { + return join_generic(vs, delimiter); + } + /** * @brief Remove surrounding slashes from a string. * diff --git a/src/ChunkInfo.cpp b/src/ChunkInfo.cpp index 6162a49f3a..47496cb436 100644 --- a/src/ChunkInfo.cpp +++ b/src/ChunkInfo.cpp @@ -22,6 +22,7 @@ #include "openPMD/ChunkInfo_internal.hpp" #include "openPMD/auxiliary/Mpi.hpp" +#include "openPMD/auxiliary/StringManip.hpp" #include "openPMD/benchmark/mpi/OneDimensionalBlockSlicer.hpp" #include // std::sort @@ -409,6 +410,17 @@ namespace chunk_assignment PartialAssignment ByHostname::assign( PartialAssignment res, RankMeta const &in, RankMeta const &out) { + std::cout << "INRANKS:\n"; + for (auto const &[rank, name] : in) + { + std::cout << rank << ":\t" << name << '\n'; + } + std::cout << "\nOUTRANKS:\n"; + for (auto const &[rank, name] : out) + { + std::cout << rank << ":\t" << name << '\n'; + } + std::cout << std::endl; // collect chunks by hostname std::map chunkGroups; ChunkTable &sourceChunks = res.notAssigned; @@ -472,6 +484,14 @@ namespace chunk_assignment ranksOnTargetNode); } } + std::cout << res.notAssigned.size() << " Chunks unassigned:\n"; + for (auto const &chunk : res.notAssigned) + { + std::cout << "\tFROM " << chunk.sourceID << "\t[" + << auxiliary::join_generic(chunk.offset, ",") << "]\t[" + << auxiliary::join_generic(chunk.extent, ",") << "]" + << std::endl; + } return res; } diff --git a/src/binding/python/openpmd_api/pipe/__main__.py b/src/binding/python/openpmd_api/pipe/__main__.py index 15978c8a4b..f942b60948 100644 --- a/src/binding/python/openpmd_api/pipe/__main__.py +++ b/src/binding/python/openpmd_api/pipe/__main__.py @@ -293,7 +293,7 @@ def distribution_strategy(dataset_extent, return IncreaseGranularity( granularity, 1, io.FromPartialStrategy(io.ByHostname(io.RoundRobin()), - io.FailingStrategy())) + io.DiscardingStrategy())) elif strategy_identifier == 'all': return io.FromPartialStrategy(IncreaseGranularity(5), LoadAll(mpi_rank)) elif strategy_identifier == 'roundrobin':