Skip to content

Commit

Permalink
TMP: Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Dec 11, 2024
1 parent 2f4a3e6 commit af94e5c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
26 changes: 22 additions & 4 deletions include/openPMD/auxiliary/StringManip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,44 @@ namespace auxiliary
return s.substr(begin - s.begin(), end.base() - begin);
}

template <typename T>
inline std::string
join(std::vector<std::string> const &vs, std::string const &delimiter)
join_generic(std::vector<T> const &vs, std::string const &delimiter)
{
auto as_string = [](T const &t) {
if constexpr (std::is_same_v<T, std::string>)
{
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<std::string>(ss, delimiter.c_str()));
std::ostream_iterator<std::string>(ss, delimiter.c_str()),
as_string);
ss << *(vs.end() - 1);
return ss.str();
}
}

inline std::string
join(std::vector<std::string> const &vs, std::string const &delimiter)
{
return join_generic(vs, delimiter);
}

/**
* @brief Remove surrounding slashes from a string.
*
Expand Down
20 changes: 20 additions & 0 deletions src/ChunkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <algorithm> // std::sort
Expand Down Expand Up @@ -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<std::string, ChunkTable> chunkGroups;
ChunkTable &sourceChunks = res.notAssigned;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/binding/python/openpmd_api/pipe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit af94e5c

Please sign in to comment.