Explorar o código

The second argument to 'mpi' specifies number of dpnodes.

The first argument passed to the 'mpi' process specifies the number of worker processes to start on each host, and now the second argument specifies the number of dpnode processes to start on each host. The remaining arguments are passed to the forked controller process.
Steven Engler %!s(int64=8) %!d(string=hai) anos
pai
achega
4199e3c1ff
Modificáronse 1 ficheiros con 12 adicións e 9 borrados
  1. 12 9
      mpi.cc

+ 12 - 9
mpi.cc

@@ -86,8 +86,8 @@ int main(int argc, char **argv)
     // Init MPI
     MPI_Init(&argc, &argv);
 
-    if (argc < 2) {
-	printf("You must pass at least one argument (the number of workers to start).\n");
+    if (argc < 3) {
+	printf("You must pass at least two arguments (the number of workers and number of dpnodes to start per node/rank).\n");
 	printf("The remaining arguments will be passed to the controller.\n");
 
 	MPI_Finalize();
@@ -109,6 +109,7 @@ int main(int argc, char **argv)
     char boundportaddr[259];
 
     unsigned int num_workers = strtol(argv[1], NULL, 10);
+    unsigned int num_dpnodes = strtol(argv[2], NULL, 10);
 
     if (rank == 0) {
 	// Start the controller
@@ -121,8 +122,8 @@ int main(int argc, char **argv)
 	    close_highfds_except(controllerfds[1]);
 
 	    char name[] = "controller";
-	    argv[1] = name;
-	    execv("./controller", argv+1);
+	    argv[2] = name;
+	    execv("./controller", argv+2);
 	    return 1;
 	} else {
 	    // Parent; close the write half of the pipe
@@ -159,11 +160,13 @@ int main(int argc, char **argv)
 	}
     }
 
-    if (fork_and_remember(children) == 0) {
-	// And a dpnode
-	close_highfds_except(-1);
-	execl("./dpnode", "./dpnode", boundaddr, portstr, NULL);
-	return 1;
+    // And dpnodes
+    for (int i=0; i<num_dpnodes; i++) {
+	if (fork_and_remember(children) == 0) {
+	    close_highfds_except(-1);
+	    execl("./dpnode", "./dpnode", boundaddr, portstr, NULL);
+	    return 1;
+	}
     }
 
     // Now wait for all the children