int main(int argc, char** argv) { parse_args(argc, argv); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &RANK); MPI_Comm_size(MPI_COMM_WORLD, &WORLD_SIZE); if (RANK == 0) { printf("* width: %u\n", WIDTH); printf("* height: %u\n", HEIGHT); printf("* depth: %u\n", DEPTH); printf("\n"); comm = new CommunicatorMaster(WORLD_SIZE - 1); game(); delete comm; } else { Slave slave; slave.run(); } MPI_Finalize(); return 0; }
int main(int argc, char** argv) { cout << SectorVersionString << endl; SlaveConf global_conf; CmdLineParser clp; clp.parse(argc, argv); for (map<string, string>::const_iterator i = clp.m_mDFlags.begin(); i != clp.m_mDFlags.end(); ++ i) { if (i->first == "mh") global_conf.m_strMasterHost = i->second; else if (i->first == "mp") global_conf.m_iMasterPort = atoi(i->second.c_str()); else if (i->first == "h") { global_conf.m_strHomeDir = i->second; } else if (i->first == "ds") global_conf.m_llMaxDataSize = atoll(i->second.c_str()) * 1024 * 1024; else if (i->first == "log") global_conf.m_iLogLevel = atoi(i->second.c_str()); else { cout << "warning: unrecognized flag " << i->first << endl; help(); } } string base = ""; if (clp.m_vParams.size() == 1) base = clp.m_vParams.front(); else if (clp.m_vParams.size() > 1) cout << "warning: wrong parameters ignored.\n"; Slave s; if (s.init(&base, &global_conf) < 0) { cout << "error: failed to initialize the slave. check slave configurations.\n"; return-1; } if (s.connect() < 0) { cout << "error: failed to connect to the master, or the connection request is rejected.\n"; return -1; } s.run(); s.close(); return 0; }
int main(int argc, char** argv) { Slave s; int res; if (argc > 1) res = s.init(argv[1]); else res = s.init(); if (res < 0) return -1; if (s.connect() < 0) return -1; s.run(); return 1; }