48 void vector(
char const* phase,
char const* direction,
int id,
int peer,
49 char const* stage, std::vector<T>
const& data)
52 std::string key = std::string(phase)+
"_"+direction+
"_"+std::to_string(
id)+
"_"+
53 std::to_string(peer)+
"_"+stage;
56 std::filesystem::create_directories(
directory());
57 std::ofstream out(std::filesystem::path(
directory())/(key+
".txt"));
58 if (!out)
throw std::runtime_error(
"Cannot open transfer audit: "+key);
59 out << data.size() <<
'\n' << std::setprecision(std::numeric_limits<double>::max_digits10);
60 for (
auto const& value : data)
62 if constexpr (std::is_integral_v<T>) out << +value <<
'\n';
63 else out << value <<
'\n';
66 if (!out)
throw std::runtime_error(
"Cannot finish transfer audit: "+key);
73 void plan(
char const* phase,
char const* direction,
int id,
int peer,
74 std::vector<int>
const& coarse, std::vector<int>
const& fine,
75 std::vector<std::vector<int>>
const& neighbors,
76 std::vector<std::vector<Scalar>>
const& weights)
79 std::vector<std::size_t> offsets{0};
80 std::vector<int> flatNeighbors;
81 std::vector<Scalar> flatWeights;
82 for (std::size_t k=0; k<neighbors.size(); ++k)
84 flatNeighbors.insert(flatNeighbors.end(),neighbors[k].begin(),neighbors[k].end());
85 flatWeights.insert(flatWeights.end(),weights[k].begin(),weights[k].end());
86 offsets.push_back(flatNeighbors.size());
88 vector(phase,direction,
id,peer,
"coarse",coarse);
89 vector(phase,direction,
id,peer,
"fine",fine);
90 vector(phase,direction,
id,peer,
"offsets",offsets);
91 vector(phase,direction,
id,peer,
"neighbors",flatNeighbors);
92 vector(phase,direction,
id,peer,
"weights",flatWeights);