diff --git a/GenericIO.cxx b/GenericIO.cxx index ac00f34cead32e317ad408ae62df1303abdcbf39..bcae435f6735aa18650b426d730e57e737c5313e 100644 --- a/GenericIO.cxx +++ b/GenericIO.cxx @@ -1793,39 +1793,6 @@ void GenericIO::readData(int EffRank, size_t RowOffset, int Rank, } } -#ifndef GENERICIO_NO_MPI -void GenericIO::rebalanceSourceRanks() { - if(Redistributing) { - int NRanks, Rank; - MPI_Comm_rank(Comm, &Rank); - MPI_Comm_size(Comm, &NRanks); - - std::vector<std::pair<int, size_t>> rank_sizes; - std::vector<std::tuple<int, size_t, std::vector<int>>> new_source_ranks; - for(int i=0; i<NRanks; ++i) { - new_source_ranks.emplace_back(std::make_tuple(i, 0ul, std::vector<int>())); - } - for(int i=0; i<readNRanks(); ++i) { - rank_sizes.emplace_back(std::make_pair(i, readNumElems(i))); - } - std::sort(rank_sizes.begin(), rank_sizes.end(), [](const auto& p1, const auto& p2){ return p1.second > p2.second; }); - // Distribute ranks - for(size_t i=0; i<rank_sizes.size(); ++i) { - // Assign to first rank - std::get<2>(new_source_ranks[0]).push_back(rank_sizes[i].first); - std::get<1>(new_source_ranks[0]) += rank_sizes[i].second; - // Reorder ranks (could be optimized since array already sorted) - std::stable_sort(new_source_ranks.begin(), new_source_ranks.end(), [](const auto& s1, const auto& s2){ return std::get<1>(s1) < std::get<1>(s2); }); - } - // copy own array - SourceRanks.resize(0); - std::copy(std::get<2>(new_source_ranks[Rank]).begin(), std::get<2>(new_source_ranks[Rank]).end(), std::back_inserter(SourceRanks)); - } else { - std::cerr << "rebalancing source ranks has no effect when Redistributing==false" << std::endl; - } -} -#endif - void GenericIO::getVariableInfo(vector<VariableInfo> &VI) { if (FH.isBigEndian()) getVariableInfo<true>(VI); diff --git a/GenericIO.h b/GenericIO.h index 02bf68563c8d257d17ff35cc9e95ea49c46955d5..32414150b42f9c4756527df5da9815581508dd82 100644 --- a/GenericIO.h +++ b/GenericIO.h @@ -439,9 +439,6 @@ public: int readGlobalRankNumber(int EffRank = -1); void readData(int EffRank = -1, bool PrintStats = true, bool CollStats = true); -#ifndef GENERICIO_NO_MPI - void rebalanceSourceRanks(); -#endif void getSourceRanks(std::vector<int> &SR); void close() { diff --git a/python/genericio.cpp b/python/genericio.cpp index a29d478f35d38ecbcf05d88bb8237410cc05dcaf..64bc989327285faf1fc6e315f4c06c0b05dae675 100644 --- a/python/genericio.cpp +++ b/python/genericio.cpp @@ -204,14 +204,9 @@ std::map<std::string, py::array> read_genericio( PyGenericIO::MismatchBehavior redistribute=PyGenericIO::MismatchBehavior::MismatchRedistribute, bool print_stats=true, bool collective_stats=true, - bool rebalance_source_ranks=false, int eff_rank=-1 ) { PyGenericIO reader(filename, method, redistribute, eff_rank); -#ifndef GENERICIO_NO_MPI - if(rebalance_source_ranks) - reader.rebalanceSourceRanks(); -#endif return reader.read(var_names, print_stats, collective_stats, eff_rank); } @@ -383,7 +378,6 @@ PYBIND11_MODULE(pygio, m) { .def_static("setNaturalDefaultPartition", &PyGenericIO::setNaturalDefaultPartition) .def_static("setDefaultFileIOType", &PyGenericIO::setDefaultFileIOType) #ifndef GENERICIO_NO_MPI - .def("rebalance_source_ranks", &PyGenericIO::rebalanceSourceRanks) .def_static("setCollectiveMPIIOThreshold", &PyGenericIO::setCollectiveMPIIOThreshold) #endif ; @@ -423,12 +417,6 @@ PYBIND11_MODULE(pygio, m) { collective_stats: bool if ``True``, aggregate statistics among reading ranks (if using MPI) - rebalance_sourceranks: bool - if ``True``, the code will re-assign the file ranks to the reading - MPI ranks to equalize the data size each rank is reading. Only - relevant if using MPI and more ranks were used to write the file - than reading. - Returns ------- data: Mapping[str, np.ndarray] @@ -441,7 +429,6 @@ PYBIND11_MODULE(pygio, m) { py::arg("redistribute")=PyGenericIO::MismatchBehavior::MismatchRedistribute, py::arg("print_stats")=true, py::arg("collective_stats")=true, - py::arg("rebalance_sourceranks")=false, py::arg("eff_rank")=-1, py::return_value_policy::move);