Add some new tests to the ORTE collection
This commit was SVN r22328.
Этот коммит содержится в:
родитель
313acba4ce
Коммит
06d1f2cfe2
@ -1,4 +1,4 @@
|
||||
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave_spawn slave cell_spawn reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster hello++ hellof90
|
||||
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave_spawn slave cell_spawn reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster hello++ hellof90 early_abort
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
|
45
orte/test/mpi/early_abort.c
Обычный файл
45
orte/test/mpi/early_abort.c
Обычный файл
@ -0,0 +1,45 @@
|
||||
/* -*- C -*-
|
||||
*
|
||||
* $HEADER$
|
||||
*
|
||||
* The most basic of MPI applications
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "mpi.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rank, size;
|
||||
char *rk;
|
||||
|
||||
/* get the MPI rank from the environ */
|
||||
if (NULL == (rk = getenv("OMPI_COMM_WORLD_RANK"))) {
|
||||
fprintf(stderr, "FAILED TO GET RANK\n");
|
||||
exit(1);
|
||||
}
|
||||
if (1 < argc) {
|
||||
/* rank 0 exits first */
|
||||
if (0 == strcmp(rk, "0")) {
|
||||
exit(1);
|
||||
} else {
|
||||
sleep(1);
|
||||
}
|
||||
} else {
|
||||
if (0 == strcmp(rk, "0")) {
|
||||
sleep(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||
|
||||
printf("Hello, World, I am %d of %d\n", rank, size);
|
||||
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
16
orte/test/mpi/spawn-problem/Makefile
Исполняемый файл
16
orte/test/mpi/spawn-problem/Makefile
Исполняемый файл
@ -0,0 +1,16 @@
|
||||
CC=mpicc
|
||||
|
||||
all: start ch_rec
|
||||
|
||||
|
||||
start:start.o
|
||||
$(CC) -o start start.o
|
||||
|
||||
ch_rec: ch_rec.o
|
||||
$(CC) -o ch_rec ch_rec.o
|
||||
|
||||
clean:
|
||||
rm -f *.o ch_rec start
|
||||
|
||||
run:
|
||||
mpirun -np 1 start
|
52
orte/test/mpi/spawn-problem/ch_rec.c
Обычный файл
52
orte/test/mpi/spawn-problem/ch_rec.c
Обычный файл
@ -0,0 +1,52 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mpi.h>
|
||||
|
||||
int main (int argc, char **argv){
|
||||
char buff[30];
|
||||
MPI_Status st;
|
||||
MPI_Comm comm[2], parent;
|
||||
MPI_Request req[2];
|
||||
int errcodes[1];
|
||||
int level;
|
||||
int x = 6, i, j;
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_get_parent(&parent);
|
||||
argv++;
|
||||
level = atoi(argv[0]);
|
||||
printf("level = %d\n",level);
|
||||
|
||||
MPI_Recv(&buff, sizeof(char)*30, MPI_CHAR, MPI_ANY_SOURCE,
|
||||
MPI_ANY_TAG, parent, &st);
|
||||
printf("Parent sent: %s\n", buff);
|
||||
|
||||
if(level < x){
|
||||
sprintf(argv[0], "%d", level+1);
|
||||
MPI_Comm_spawn("ch_rec", argv, 1, MPI_INFO_NULL, 0, MPI_COMM_SELF,
|
||||
&comm[0], errcodes);
|
||||
sprintf(buff,"level %d (pid:%d)", level, getpid());
|
||||
MPI_Send(&buff, sizeof(char)*30, MPI_CHAR, 0, 100, comm[0]);
|
||||
MPI_Irecv(&buff, sizeof(char)*30, MPI_CHAR, MPI_ANY_SOURCE,
|
||||
MPI_ANY_TAG, comm[0], &req[0]);
|
||||
|
||||
//sleep(2);
|
||||
sprintf(argv[0], "%d", (level+1));
|
||||
MPI_Comm_spawn("ch_rec", argv, 1, MPI_INFO_NULL, 0, MPI_COMM_SELF,
|
||||
&comm[1], errcodes);
|
||||
sprintf(buff,"level %d (pid:%d)", level, getpid());
|
||||
MPI_Send(&buff, sizeof(char)*30, MPI_CHAR, 0, 100, comm[1]);
|
||||
MPI_Irecv(&buff, sizeof(char)*30, MPI_CHAR, MPI_ANY_SOURCE,
|
||||
MPI_ANY_TAG, comm[1], &req[1]);
|
||||
|
||||
for(i=0; i<2; i++){
|
||||
MPI_Waitany(2, req, &j, MPI_STATUS_IGNORE);
|
||||
printf("Child %d sent: %s\n", j, buff);
|
||||
}
|
||||
}
|
||||
sprintf(buff,"level %d (pid:%d)", level, getpid());
|
||||
MPI_Send(&buff, sizeof(char)*30, MPI_CHAR, 0, 100, parent);
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
28
orte/test/mpi/spawn-problem/start.c
Обычный файл
28
orte/test/mpi/spawn-problem/start.c
Обычный файл
@ -0,0 +1,28 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mpi.h>
|
||||
|
||||
int main (int argc, char **argv){
|
||||
char buff[30];
|
||||
MPI_Status st;
|
||||
MPI_Comm comm;
|
||||
int errcodes[1];
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
int level = 0;
|
||||
printf("level %d\n", level);
|
||||
|
||||
sprintf(argv[0], "%d", level+1);
|
||||
MPI_Comm_spawn("ch_rec", argv, 1, MPI_INFO_NULL, 0, MPI_COMM_SELF,
|
||||
&comm, errcodes);
|
||||
sprintf(buff,"level %d (pid:%d)", level, getpid());
|
||||
MPI_Send(&buff, sizeof(char)*30, MPI_CHAR, 0, 100, comm);
|
||||
|
||||
MPI_Recv(&buff, sizeof(char)*30, MPI_CHAR, MPI_ANY_SOURCE,
|
||||
MPI_ANY_TAG, comm, &st);
|
||||
printf("Child sent: %s\n", buff);
|
||||
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user