polaroidCameraMPI.cpp (1621B)
1 // File : polaroidCameraMPI.cpp 2 // Date : Wed Apr 27 14:40:05 2016 3 // Author : Fabian Wermelinger 4 // Description: Polaroid Cam app 5 // Copyright 2016 ETH Zurich. All Rights Reserved. 6 #include <iostream> 7 #include <cstdio> 8 #include <vector> 9 #include <string> 10 11 #include "ArgumentParser.h" 12 #include "OrganizerMPI.h" 13 #include "SceneProcessor.h" 14 15 16 using namespace std; 17 18 int main(int argc, char* argv[]) 19 { 20 MPI_Init(&argc, (char***)&argv); 21 22 OrganizerMPI worker(argc, argv); 23 ArgumentParser myparser(worker.argc(), (const char**)argv); 24 25 if (worker.isroot()) 26 { 27 cout << "Command Line: "; 28 for (int i = 0; i < argc; ++i) 29 cout << argv[i] << " "; 30 cout << endl; 31 myparser.print_args(); 32 cout.flush(); 33 } 34 worker.wait(); 35 36 vector<string> myscenes = worker.split_work(); 37 if (myscenes.size() > 0) 38 printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), myscenes.front().c_str()); 39 else 40 printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), "none"); 41 42 SceneProcessor myprocessor(myparser, worker); 43 44 if (myparser("-process").asInt(1212) == 1212) 45 myprocessor.process1212(myscenes); 46 else if (myparser("-process").asInt(1212) == 1122) 47 myprocessor.process1122(myscenes); 48 else 49 { 50 if (worker.isroot()) 51 cerr << "ERROR: Undefined processing \"" << myparser("-process").asInt(1212) << "\"" << endl; 52 abort(); 53 } 54 55 worker.wait(); 56 MPI_Finalize(); 57 58 return 0; 59 }