Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. void displayOutput(map<string, int> res, int numProcs, double elapsedTime, int rank, int serviceCount, int serviceNum){
  2. map<string, int> total = map<string,int>();
  3.  
  4. int totalres = total["0-1"] + total["1-2"] + total["2-5"] + total[">5"];
  5.  
  6. vector<map<string,int>> counts;
  7. vector<int> ranks;
  8. counts.push_back(res);
  9. ranks.push_back(rank);
  10.  
  11. MPI_Reduce(&res["0-1"], &total["0-1"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
  12. MPI_Reduce(&res["1-2"], &total["1-2"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
  13. MPI_Reduce(&res["2-5"], &total["2-5"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
  14. MPI_Reduce(&res[">5"], &total[">5"], 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
  15.  
  16. if(rank < 0) // kill the slaves don't need them anymore
  17. MPI_Finalize();
  18.  
  19. printf("%28s%16s\n", "Service:", "PLACEHOLDER");
  20. printf("%28s%16d\n", "Service Code:", serviceNum);
  21. printf("%28s%16d\n", "Number of Service Locations:", serviceCount);
  22. printf("%28s%16d\n", "Number of Processes:", numProcs);
  23. printf("%28s%16g\n", "Elapsed Time in Seconds:", elapsedTime);
  24. cout << endl;
  25.  
  26. for(int i = 0; i < counts.size(); ++i)
  27. {
  28. cout << "Process #" << ranks[i] + 1 << " Results..." << endl;
  29. cout << "Nearest Service (km) # of Addresses % of Addresses" << endl;
  30. for(map<string, int>::iterator it = counts[i].begin(); it != counts[i].end(); it++){
  31. cout << it->first << " : " << it->second << " : " << CalcFrequency(it->second, totalres) << endl;
  32. }
  33. cout << endl;
  34.  
  35. cout << "Aggregate Results..." << endl;
  36. cout << "Nearest Service (km) # of Addresses % of Addresses" << endl;
  37. for(map<string, int>::iterator it = total.begin(); it != total.end(); it++){
  38. cout << it->first << " : " << it->second << " : PLACEHOLDER" << endl;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement