2006-10-03 06:07:58 +04:00
|
|
|
#include <stdio.h>
|
2006-10-20 22:05:16 +04:00
|
|
|
#include <sys/types.h>
|
2008-09-24 19:41:42 +04:00
|
|
|
#include <unistd.h>
|
2006-10-20 22:05:16 +04:00
|
|
|
|
2006-10-03 06:07:58 +04:00
|
|
|
#include <mpi.h>
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2007-05-22 17:29:07 +04:00
|
|
|
int msg, rc;
|
2006-10-03 06:07:58 +04:00
|
|
|
MPI_Comm parent, child;
|
2006-10-20 19:27:29 +04:00
|
|
|
int rank, size;
|
|
|
|
char hostname[512];
|
2006-10-20 22:05:16 +04:00
|
|
|
pid_t pid;
|
2006-10-03 06:07:58 +04:00
|
|
|
|
2013-12-21 00:42:39 +04:00
|
|
|
pid = getpid();
|
|
|
|
printf("[pid %ld] starting up!\n", (long)pid);
|
2006-10-03 06:07:58 +04:00
|
|
|
MPI_Init(NULL, NULL);
|
2007-02-02 17:34:53 +03:00
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
2013-12-21 00:42:39 +04:00
|
|
|
printf("%d completed MPI_Init\n", rank);
|
2007-02-02 17:34:53 +03:00
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
2006-10-03 06:07:58 +04:00
|
|
|
MPI_Comm_get_parent(&parent);
|
|
|
|
/* If we get COMM_NULL back, then we're the parent */
|
|
|
|
if (MPI_COMM_NULL == parent) {
|
2006-10-20 22:05:16 +04:00
|
|
|
pid = getpid();
|
|
|
|
printf("Parent [pid %ld] about to spawn!\n", (long)pid);
|
2008-02-28 04:57:57 +03:00
|
|
|
if (MPI_SUCCESS != (rc = MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 3, MPI_INFO_NULL,
|
2013-12-21 00:42:39 +04:00
|
|
|
0, MPI_COMM_WORLD, &child, MPI_ERRCODES_IGNORE))) {
|
2007-05-22 00:13:31 +04:00
|
|
|
printf("Child failed to spawn\n");
|
2007-05-22 17:29:07 +04:00
|
|
|
return rc;
|
2007-05-22 00:13:31 +04:00
|
|
|
}
|
2006-10-03 06:07:58 +04:00
|
|
|
printf("Parent done with spawn\n");
|
2007-02-02 17:34:53 +03:00
|
|
|
if (0 == rank) {
|
|
|
|
msg = 38;
|
|
|
|
printf("Parent sending message to child\n");
|
|
|
|
MPI_Send(&msg, 1, MPI_INT, 0, 1, child);
|
|
|
|
}
|
2006-10-03 06:07:58 +04:00
|
|
|
MPI_Comm_disconnect(&child);
|
|
|
|
printf("Parent disconnected\n");
|
|
|
|
}
|
|
|
|
/* Otherwise, we're the child */
|
|
|
|
else {
|
2006-10-20 19:27:29 +04:00
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
|
|
gethostname(hostname, 512);
|
2006-10-20 22:05:16 +04:00
|
|
|
pid = getpid();
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
|
2007-02-02 17:34:53 +03:00
|
|
|
if (0 == rank) {
|
|
|
|
MPI_Recv(&msg, 1, MPI_INT, 0, 1, parent, MPI_STATUS_IGNORE);
|
|
|
|
printf("Child %d received msg: %d\n", rank, msg);
|
|
|
|
}
|
2006-10-03 06:07:58 +04:00
|
|
|
MPI_Comm_disconnect(&parent);
|
2006-10-20 19:27:29 +04:00
|
|
|
printf("Child %d disconnected\n", rank);
|
2006-10-03 06:07:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
MPI_Finalize();
|
Roll in the revamped IOF subsystem. Per the devel mailing list email, this is a complete rewrite of the iof framework designed to simplify the code for maintainability, and to support features we had planned to do, but were too difficult to implement in the old code. Specifically, the new code:
1. completely and cleanly separates responsibilities between the HNP, orted, and tool components.
2. removes all wireup messaging during launch and shutdown.
3. maintains flow control for stdin to avoid large-scale consumption of memory by orteds when large input files are forwarded. This is done using an xon/xoff protocol.
4. enables specification of stdin recipients on the mpirun cmd line. Allowed options include rank, "all", or "none". Default is rank 0.
5. creates a new MPI_Info key "ompi_stdin_target" that supports the above options for child jobs. Default is "none".
6. adds a new tool "orte-iof" that can connect to a running mpirun and display the output. Cmd line options allow selection of any combination of stdout, stderr, and stddiag. Default is stdout.
7. adds a new mpirun and orte-iof cmd line option "tag-output" that will tag each line of output with process name and stream ident. For example, "[1,0]<stdout>this is output"
This is not intended for the 1.3 release as it is a major change requiring considerable soak time.
This commit was SVN r19767.
2008-10-18 04:00:49 +04:00
|
|
|
fprintf(stderr, "%d: exiting\n", pid);
|
2006-10-03 06:07:58 +04:00
|
|
|
return 0;
|
|
|
|
}
|