/* ---- This file is part of SECONDO. Copyright (C) 2020, Faculty of Mathematics and Computer Science, Database Systems for New Applications. SECONDO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SECONDO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SECONDO; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ---- */ #include "../BalancedCollect.h" #include #include #include #include using namespace std; void trim(std::string& str, std::string whiteSpaces=" \r\n\t") { std::string::size_type pos = str.find_last_not_of(whiteSpaces); if(pos != std::string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(whiteSpaces); if(pos != std::string::npos){ str.erase(0, pos); } } else { str.erase(str.begin(), str.end()); } } int main(int argc, char** argv){ if(argc!=4){ cout << "3 arguments required" << endl; return 1; } vector slotsizes; ifstream in(argv[1]); string line; uint64_t completeSize = 0; while(in.good() && !in.eof()){ getline(in,line); trim(line); if(line.length()>0){ double s = atoi(line.c_str()); slotsizes.push_back(s); completeSize += s; } } in.close(); int noWorkers = atoi(argv[2]); string mode(argv[3]); if(mode!="simple" && mode!="complete"){ cout << "third argument mut be one of simple or complete" << endl; return 1; } bool simple = mode=="simple" ; cout << "slots : " << slotsizes.size() << endl; cout << "noWorkers : " << noWorkers << endl; cout << " mode : " << (simple?"simple":"complete") << endl; vector res = distributed2::loadbalance::getMapping(slotsizes,noWorkers,simple); if(res.size() != slotsizes.size()){ cout << "Error, size is different"; cout << "slotsizes " << slotsizes.size() << endl; cout << "res size " << res.size(); return 1; } vector workerSizes; vector > > worker; for(int i=0;i > w; worker.push_back(w); } size_t maxSize = 0; for(size_t i=0;i maxSize){ maxSize = workerSizes[w]; } pair slot(i,slotsize); worker[w].push_back(slot); } double avgSize = (double) completeSize/noWorkers; for(size_t i=0;i >& v = worker[i]; for(size_t i = 0; i< v.size();i++ ){ if(i>0) cout << " + "; cout << v[i].second <<"(" << v[i].first <<")"; } cout << " = " << workerSizes[i] << endl; } uint32_t minWS = maxSize; for(size_t i=0;i