Skip to content

Commit fae5965

Browse files
authored
Merge pull request #7445 from rhc54/topic/tests
Save the old ORTE simple tests
2 parents 3366f3e + 7e2874a commit fae5965

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5267
-0
lines changed

test/simple/Makefile.include

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- makefile -*-
2+
#
3+
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4+
# University Research and Technology
5+
# Corporation. All rights reserved.
6+
# Copyright (c) 2004-2005 The University of Tennessee and The University
7+
# of Tennessee Research Foundation. All rights
8+
# reserved.
9+
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10+
# University of Stuttgart. All rights reserved.
11+
# Copyright (c) 2004-2005 The Regents of the University of California.
12+
# All rights reserved.
13+
# Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
15+
# Copyright (c) 2017 Intel, Inc. All rights reserved.
16+
# $COPYRIGHT$
17+
#
18+
# Additional copyrights may follow
19+
#
20+
# $HEADER$
21+
#
22+
23+
# Note that this file does not stand on its own. It is included by a
24+
# higher-level Makefile so that Automake features such as "make dist"
25+
# work properly (and include all the relevant files in this directory
26+
# in the distribution tarball).
27+
28+
# If you are looking for the file that builds these examples, look at
29+
# "Makefile" in this same directory (it is *NOT* generated by
30+
# Automake).
31+
32+
EXTRA_DIST += \
33+
test/mpi/Makefile \
34+
test/mpi/abort.c \
35+
test/mpi/accept.c \
36+
test/mpi/bad_exit.c \
37+
test/mpi/concurrent_spawn.c \
38+
test/mpi/connect.c \
39+
test/mpi/crisscross.c \
40+
test/mpi/delayed_abort.c \
41+
test/mpi/hello_barrier.c \
42+
test/mpi/hello.c \
43+
test/mpi/loop_child.c \
44+
test/mpi/loop_spawn.c \
45+
test/mpi/mpi_barrier.c \
46+
test/mpi/mpi_no_op.c \
47+
test/mpi/mpi_spin.c \
48+
test/mpi/multi_abort.c \
49+
test/mpi/pubsub.c \
50+
test/mpi/sendrecv_blaster.c \
51+
test/mpi/simple_spawn.c \
52+
test/mpi/slave.c \
53+
test/mpi/spawn_multiple.c \
54+
test/mpi/ziatest.c \
55+
test/mpi/ziaprobe.c \
56+
test/mpi/singleton_client_server.c \
57+
test/mpi/spawn_tree.c \
58+
test/mpi/info_spawn.c \
59+
test/mpi/pmix.c \
60+
test/mpi/xlib.c

test/simple/abort.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* -*- C -*-
2+
*
3+
* $HEADER$
4+
*
5+
* The most basic of MPI applications
6+
*/
7+
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
#include <unistd.h>
11+
12+
#include "mpi.h"
13+
14+
int main(int argc, char* argv[])
15+
{
16+
int rank, size;
17+
int errcode;
18+
19+
if (1 < argc) {
20+
errcode = strtol(argv[1], NULL, 10);
21+
} else {
22+
errcode = 2;
23+
}
24+
25+
MPI_Init(&argc, &argv);
26+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27+
MPI_Comm_size(MPI_COMM_WORLD, &size);
28+
29+
printf("Hello, World, I am %d of %d\n", rank, size);
30+
31+
if (1 == size) {
32+
MPI_Abort(MPI_COMM_WORLD, errcode);
33+
} else {
34+
if (1 == rank) {
35+
MPI_Abort(MPI_COMM_WORLD, errcode);
36+
} else {
37+
errcode = 0;
38+
sleep(99999999);
39+
}
40+
}
41+
42+
MPI_Finalize();
43+
return errcode;
44+
}

test/simple/accept.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* -*- C -*-
2+
*
3+
* $HEADER$
4+
*
5+
* Test of connect/accept - the accept (server) side
6+
*/
7+
8+
#include <stdio.h>
9+
#include "mpi.h"
10+
11+
int main(int argc, char* argv[])
12+
{
13+
int rank, size;
14+
MPI_Info info;
15+
char port[MPI_MAX_PORT_NAME];
16+
MPI_Comm client;
17+
18+
MPI_Init(&argc, &argv);
19+
20+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21+
MPI_Comm_size(MPI_COMM_WORLD, &size);
22+
23+
printf("Hello, World, I am %d of %d\n", rank, size);
24+
fflush(stdout);
25+
26+
MPI_Info_create(&info);
27+
MPI_Info_set(info, "ompi_global_scope", "true");
28+
29+
if (0 == rank) {
30+
MPI_Open_port(MPI_INFO_NULL, port);
31+
MPI_Publish_name("test-pub", info, port);
32+
MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &client);
33+
}
34+
35+
MPI_Barrier(client);
36+
37+
if (0 == rank) {
38+
MPI_Unpublish_name("test-pub", info, port);
39+
MPI_Close_port(port);
40+
}
41+
42+
MPI_Finalize();
43+
return 0;
44+
}

test/simple/add_host.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <sys/types.h>
4+
#include <unistd.h>
5+
#include <sys/param.h>
6+
7+
#include "opal/runtime/opal.h"
8+
9+
#include <mpi.h>
10+
11+
int main(int argc, char* argv[])
12+
{
13+
int msg, rc;
14+
MPI_Comm parent, child;
15+
int rank, size;
16+
const char *hostname;
17+
pid_t pid;
18+
char *env_rank,*env_nspace;
19+
MPI_Info info;
20+
21+
env_rank = getenv("PMIX_RANK");
22+
env_nspace = getenv("PMIX_NAMESPACE");
23+
pid = getpid();
24+
hostname = opal_gethostname();
25+
26+
printf("[%s:%s pid %ld] starting up on node %s!\n", env_nspace, env_rank, (long)pid, hostname);
27+
28+
MPI_Init(NULL, NULL);
29+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30+
printf("%d completed MPI_Init\n", rank);
31+
MPI_Comm_size(MPI_COMM_WORLD, &size);
32+
MPI_Comm_get_parent(&parent);
33+
/* If we get COMM_NULL back, then we're the parent */
34+
if (MPI_COMM_NULL == parent) {
35+
pid = getpid();
36+
printf("Parent [pid %ld] about to spawn!\n", (long)pid);
37+
MPI_Info_create(&info);
38+
MPI_Info_set(info, "add-host", "rhc002:24");
39+
if (MPI_SUCCESS != (rc = MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 3, info,
40+
0, MPI_COMM_WORLD, &child, MPI_ERRCODES_IGNORE))) {
41+
printf("Child failed to spawn\n");
42+
return rc;
43+
}
44+
printf("Parent done with spawn\n");
45+
if (0 == rank) {
46+
msg = 38;
47+
printf("Parent sending message to child\n");
48+
MPI_Send(&msg, 1, MPI_INT, 0, 1, child);
49+
}
50+
MPI_Comm_disconnect(&child);
51+
printf("Parent disconnected\n");
52+
/* do it again */
53+
MPI_Info_set(info, "add-host", "rhc003:24");
54+
if (MPI_SUCCESS != (rc = MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 3, info,
55+
0, MPI_COMM_WORLD, &child, MPI_ERRCODES_IGNORE))) {
56+
printf("Child failed to spawn\n");
57+
return rc;
58+
}
59+
printf("Parent done with second spawn\n");
60+
if (0 == rank) {
61+
msg = 38;
62+
printf("Parent sending message to second children\n");
63+
MPI_Send(&msg, 1, MPI_INT, 0, 1, child);
64+
}
65+
MPI_Comm_disconnect(&child);
66+
printf("Parent disconnected again\n");
67+
}
68+
/* Otherwise, we're the child */
69+
else {
70+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
71+
MPI_Comm_size(MPI_COMM_WORLD, &size);
72+
pid = getpid();
73+
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
74+
if (0 == rank) {
75+
MPI_Recv(&msg, 1, MPI_INT, 0, 1, parent, MPI_STATUS_IGNORE);
76+
printf("Child %d received msg: %d\n", rank, msg);
77+
}
78+
MPI_Comm_disconnect(&parent);
79+
printf("Child %d disconnected\n", rank);
80+
}
81+
82+
MPI_Finalize();
83+
fprintf(stderr, "%d: exiting\n", pid);
84+
return 0;
85+
}

test/simple/attach.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* -*- C -*-
2+
*
3+
* $HEADER$
4+
*
5+
* The most basic of MPI applications
6+
*/
7+
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
#include <sys/types.h>
11+
#include <sys/stat.h>
12+
#include <fcntl.h>
13+
#include <unistd.h>
14+
15+
int main(int argc, char* argv[])
16+
{
17+
unsigned char fifo_cmd = 1;
18+
int fd;
19+
20+
if (1 > argc) {
21+
fprintf(stderr, "usage: attach <full-path-to-debugger-fifo-file>\n");
22+
exit(1);
23+
}
24+
25+
fd = open(argv[1], O_WRONLY);
26+
write(fd, &fifo_cmd, sizeof(unsigned char));
27+
close(fd);
28+
29+
return 0;
30+
}

test/simple/bad_exit.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <unistd.h>
4+
#include <mpi.h>
5+
6+
#define RANK_DEATH 1
7+
8+
int main(int argc, char **argv)
9+
{
10+
int rank;
11+
MPI_Init(&argc,&argv);
12+
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
13+
14+
sleep(2);
15+
if (rank==RANK_DEATH) {
16+
printf("Rank %d exiting without calling finalize...\n", rank);
17+
exit(1);
18+
}
19+
sleep(2);
20+
printf("Rank %d calling MPI_Finalize\n", rank);
21+
MPI_Finalize();
22+
printf("Rank %d exiting\n", rank);
23+
return 0;
24+
}
25+

test/simple/badcoll.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
#include <unistd.h>
3+
#include "mpi.h"
4+
5+
const int count = 1234;
6+
int buffer[1234] = {0};
7+
8+
int main(int argc, char *argv[])
9+
{
10+
int rank, size, i;
11+
12+
MPI_Init(&argc, &argv);
13+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
14+
MPI_Comm_size(MPI_COMM_WORLD, &size);
15+
16+
17+
for (i=0; i < 1000; i++) {
18+
fprintf(stderr, "%d: Executing Bcast #%d\n", rank, i);
19+
MPI_Bcast(buffer, count, MPI_INT, 0, MPI_COMM_WORLD);
20+
if (0 != rank) {
21+
sleep(1);
22+
}
23+
}
24+
25+
MPI_Finalize();
26+
return 0;
27+
}
28+

test/simple/bcast_loop.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <mpi.h>
2+
#include <stdio.h>
3+
4+
int main(int argc, char* argv[])
5+
{
6+
int myid, nprocs, tag;
7+
int i, m, nt;
8+
MPI_Status status;
9+
double workarray1[561], workarray2[561];
10+
const int numm = 50000;
11+
const int numt = 142;
12+
13+
MPI_Init(NULL, NULL);
14+
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
15+
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
16+
17+
for (m = 0; m < numm; ++m) {
18+
if (0 == (m % 1000)) {
19+
printf("rank %d, m = %d\n", myid, m);
20+
}
21+
for (nt = 0; nt <= numt; ++nt) {
22+
if (0 == myid) {
23+
for (i = 0; i < 561; ++i) {
24+
workarray1[i] = numm * numt * i;
25+
workarray2[i] = numm * numt * (i + 1);
26+
}
27+
}
28+
MPI_Bcast(workarray1, 561, MPI_DOUBLE, 0, MPI_COMM_WORLD);
29+
MPI_Bcast(workarray2, 561, MPI_DOUBLE, 0, MPI_COMM_WORLD);
30+
}
31+
}
32+
MPI_Finalize();
33+
34+
return 0;
35+
}
36+

0 commit comments

Comments
 (0)