Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void displayOutput(map<string, int> res, int numProcs, double elapsedTime, int rank, int serviceCount, int serviceNum){
- map<string, int> total = map<string,int>();
- int totalres = total["0-1"] + total["1-2"] + total["2-5"] + total[">5"];
- vector<map<string,int>> counts;
- vector<int> ranks;
- counts.push_back(res);
- ranks.push_back(rank);
- MPI_Reduce(&res["0-1"], &total["0-1"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- MPI_Reduce(&res["1-2"], &total["1-2"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- MPI_Reduce(&res["2-5"], &total["2-5"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- MPI_Reduce(&res[">5"], &total[">5"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if(rank < 0) // kill the slaves don't need them anymore
- MPI_Finalize();
- printf("%28s%16s\n", "Service:", "PLACEHOLDER");
- printf("%28s%16d\n", "Service Code:", serviceNum);
- printf("%28s%16d\n", "Number of Service Locations:", serviceCount);
- printf("%28s%16d\n", "Number of Processes:", numProcs);
- printf("%28s%16g\n", "Elapsed Time in Seconds:", elapsedTime);
- cout << endl;
- for(int i = 0; i < counts.size(); ++i)
- {
- cout << "Process #" << ranks[i] + 1 << " Results..." << endl;
- cout << "Nearest Service (km) # of Addresses % of Addresses" << endl;
- for(map<string, int>::iterator it = counts[i].begin(); it != counts[i].end(); it++){
- cout << it->first << " : " << it->second << " : " << CalcFrequency(it->second, totalres) << endl;
- }
- cout << endl;
- cout << "Aggregate Results..." << endl;
- cout << "Nearest Service (km) # of Addresses % of Addresses" << endl;
- for(map<string, int>::iterator it = total.begin(); it != total.end(); it++){
- cout << it->first << " : " << it->second << " : PLACEHOLDER" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement