Skip to content

Commit 49a98d9

Browse files
authored
Merge pull request #5 from hppritcha/topic/initial_sessions_tests
sessions: initial set of sessions tests
2 parents 295507c + e6a2fab commit 49a98d9

File tree

7 files changed

+605
-0
lines changed

7 files changed

+605
-0
lines changed

sessions/Makefile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
# University Research and Technology
4+
# Corporation. All rights reserved.
5+
# Copyright (c) 2004-2018 The University of Tennessee and The University
6+
# of Tennessee Research Foundation. All rights
7+
# reserved.
8+
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
# University of Stuttgart. All rights reserved.
10+
# Copyright (c) 2004-2005 The Regents of the University of California.
11+
# All rights reserved.
12+
# Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
13+
# Copyright (c) 2011-2016 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
15+
# Copyright (c) 2013 Mellanox Technologies, Inc. All rights reserved.
16+
# Copyright (c) 2017-2018 Research Organization for Information Science
17+
# and Technology (RIST). All rights reserved.
18+
# Copyright (c) 2019 Triad National Security, LLC. All rights
19+
# reserved.
20+
#
21+
# $COPYRIGHT$
22+
#
23+
# Additional copyrights may follow
24+
#
25+
# $HEADER$
26+
#
27+
28+
# Use the Open MPI-provided wrapper compilers.
29+
30+
MPICC = mpicc
31+
MPIFC = mpifort
32+
33+
# Example programs to build
34+
35+
EXAMPLES = \
36+
sessions_ex1.o \
37+
sessions_ex2 \
38+
sessions_ex3 \
39+
sessions_ex4 \
40+
sessions_test
41+
42+
43+
# Default target. Always build the C MPI examples. Only build the
44+
# others if we have the appropriate Open MPI / OpenSHMEM language
45+
# bindings.
46+
47+
all: sessions_ex1.o sessions_ex2 sessions_test
48+
@ if which ompi_info >/dev/null 2>&1 ; then \
49+
$(MAKE) mpi; \
50+
fi
51+
52+
mpi:
53+
@ if ompi_info --parsable | grep -q bindings:use_mpi_f08:yes >/dev/null; then \
54+
$(MAKE) sessions_ex3 ; \
55+
fi
56+
@ if ompi_info --parsable | egrep -q bindings:use_mpi:\"\?yes >/dev/null; then \
57+
$(MAKE) sessions_ex4 ; \
58+
fi
59+
60+
61+
# The usual "clean" target
62+
63+
clean:
64+
rm -f $(EXAMPLES) *~ *.o
65+
66+
# Don't rely on default rules for the Fortran and Java examples
67+
68+
sessions_ex1.o: sessions_ex1.c
69+
$(MPICC) -c $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@
70+
sessions_ex2: sessions_ex2.c
71+
$(MPICC) $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@
72+
sessions_ex3: sessions_ex3.f90
73+
$(MPIFC) $(FCFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@
74+
sessions_ex4: sessions_ex4.f90
75+
$(MPIFC) $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@
76+
sessions_test: sessions_test.c
77+
$(MPICC) $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@
78+

sessions/README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Tests for MPI Sessions extensions to the MPI API
2+
3+
To build these tests you will need the following package:
4+
5+
- MPI Sessions prototype
6+
7+
## Installing the prototype
8+
9+
```
10+
git clone --recursive git@github.com:hpc/ompi.git
11+
cd ompi
12+
git checkout sessions_new
13+
./autogen.pl
14+
./configure --prefix=my_sandbox
15+
make -j install
16+
```
17+
18+
## Installing the tests
19+
20+
```
21+
export PATH=my_sandbox/bin:$PATH
22+
git clone https://github.com/open-mpi/ompi-tests-public.git
23+
cd ompi-tests-public/sessions
24+
make
25+
```
26+
27+
## Running the tests
28+
29+
Assuming the checkout of the prototype occurred after 6/26/20, the tests can
30+
be run using either the ```mpirun``` installed as part of the build of the
31+
prototype, or prte/prun can be used.
32+
33+
When using prte, the tests can be run as follows:
34+
35+
```
36+
prte --daemonize
37+
prun -n 4 ./sessions_ex2 mpi://world
38+
prun -n 4 ./sessions_ex3
39+
prun -n 4 ./sessions_ex4
40+
prun -n 4 ./sessions_test
41+
```
42+
43+
To run using mpirun:
44+
45+
```
46+
mpirun -np 4 ./sessions_ex2 mpi://world
47+
mpirun -np 4 ./sessions_ex3
48+
mpirun -np 4 ./sessions_ex4
49+
mpirun -np 4 ./sessions_test
50+
```
51+
52+
This example assumes your system has at least 4 slots available for MPI processes.
53+
54+
Note the third example may not have been built if you are using an old Fortran compiler
55+
that isn't able to generate the ```mpi_f08``` Fortran module.
56+
57+
## Special instructions for using prte/prun on a Cray XC and SLURM
58+
59+
On Cray XE/XC systems running SLURM, prte has to use a different procedure for launching
60+
processes on the first node of a SLURM allocation. Namely, prte launches a prte daemon
61+
using the local slurmd daemon. As a consequence, there are effectively two prte daemons
62+
on the head node, the prte launched on the command line and a second launched via slurmd.
63+
64+
To avoid annoying things like loss of stdout/stdin from the processes launched on the head
65+
node owing to having two prte daemons running on the node, additional arguments most be added to the prte and prun commands:
66+
67+
```
68+
prte --daemonize --system-server
69+
prun -n 4 --system-server-first (additional arguments)
70+
```
71+
72+
73+
# Old instructions
74+
75+
These instructions are applicable if you are working with a checkout
76+
of the MPI Sessions prototype prior to 6/26/20.
77+
78+
To build these tests you will need the following several packages:
79+
80+
- most recent version of PMIx
81+
- most recent version of prrte
82+
- MPI Sessions prototype
83+
84+
## Installing PMIx
85+
86+
```
87+
git clone git@github.com:pmix/pmix.git
88+
cd pmix
89+
./autogen.pl
90+
./configure --prefix=my_sandbox --with-libevent
91+
make -j install
92+
```
93+
94+
## Installing prrte
95+
96+
```
97+
git clone git@github.com:pmix/prrte.git
98+
cd prrte
99+
./autogen.pl
100+
./configure --prefix=my_sandbox --with-libevent --with-pmix=my_sandbox
101+
make -j install
102+
```
103+
104+
## Installing the prototype
105+
106+
```
107+
git clone git@github.com:hpc/ompi.git
108+
cd ompi
109+
git checkout sessions_new
110+
./autogen.pl
111+
./configure --prefix=my_sandbox --with-libevent --with-pmix=my_sandbox
112+
make -j install
113+
```
114+
115+
## Installing and running these tests
116+
117+
```
118+
export PATH=my_sandbox/bin:$PATH
119+
make
120+
prte --daemonize
121+
prun -n 4 ./sessions_ex2 mpi://world
122+
prun -n 4 ./sessions_ex3
123+
prun -n 4 ./sessions_ex4
124+
prun -n 4 ./sessions_test
125+
```
126+
This example assumes your system has at least 4 slots available for MPI processes.
127+
128+
## Special instructions for Cray XC and SLURM
129+
130+
On Cray XE/XC systems running SLURM, prte has to use a different procedure for launching
131+
processes on the first node of a SLURM allocation. Namely, prte launches a prte daemon
132+
using the local slurmd daemon. As a consequence, there are effectively two prte daemons
133+
on the head node, the prte launched on the command line and a second launched via slurmd.
134+
135+
To avoid annoying things like loss of stdout/stdin from the processes launched on the head
136+
node owing to having two prte daemons running on the node, additional arguments most be added to the prte and prun commands:
137+
138+
```
139+
prte --daemonize --system-server
140+
prun -n 4 --system-server-first (additional arguments)
141+
```
142+
143+

sessions/sessions_ex1.c

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include "mpi.h"
5+
6+
static MPI_Session lib_shandle = MPI_SESSION_NULL;
7+
static MPI_Comm lib_comm = MPI_COMM_NULL;
8+
9+
int library_foo_init(void)
10+
{
11+
int rc, flag;
12+
int ret = 0;
13+
const char pset_name[] = "mpi://WORLD";
14+
const char mt_key[] = "thread_level";
15+
const char mt_value[] = "MPI_THREAD_MULTIPLE";
16+
char out_value[100]; /* large enough */
17+
MPI_Group wgroup = MPI_GROUP_NULL;
18+
MPI_Info sinfo = MPI_INFO_NULL;
19+
MPI_Info tinfo = MPI_INFO_NULL;
20+
21+
MPI_Info_create(&sinfo);
22+
MPI_Info_set(sinfo, mt_key, mt_value);
23+
rc = MPI_Session_init(sinfo, MPI_ERRORS_RETURN,
24+
&lib_shandle);
25+
if (rc != MPI_SUCCESS) {
26+
ret = -1;
27+
goto fn_exit;
28+
}
29+
30+
/*
31+
* check we got thread support level foo library needs
32+
*/
33+
rc = MPI_Session_get_info(lib_shandle, &tinfo);
34+
if (rc != MPI_SUCCESS) {
35+
ret = -1;
36+
goto fn_exit;
37+
}
38+
39+
MPI_Info_get(tinfo, mt_key, sizeof(out_value),
40+
out_value, &flag);
41+
if (flag != 1) {
42+
printf("Could not find key %s\n", mt_key);
43+
ret = -1;
44+
goto fn_exit;
45+
}
46+
47+
if (strcmp(out_value, mt_value)) {
48+
printf("Did not get thread multiple support, got %s\n",
49+
out_value);
50+
ret = -1;
51+
goto fn_exit;
52+
}
53+
54+
/*
55+
* create a group from the WORLD process set
56+
*/
57+
rc = MPI_Group_from_session_pset(lib_shandle,
58+
pset_name,
59+
&wgroup);
60+
if (rc != MPI_SUCCESS) {
61+
ret = -1;
62+
goto fn_exit;
63+
}
64+
65+
/*
66+
* get a communicator
67+
*/
68+
rc = MPI_Comm_create_from_group(wgroup,
69+
"mpi.forum.mpi-v4_0.example-ex10_8",
70+
MPI_INFO_NULL,
71+
MPI_ERRORS_RETURN,
72+
&lib_comm);
73+
if (rc != MPI_SUCCESS) {
74+
ret = -1;
75+
goto fn_exit;
76+
}
77+
78+
/*
79+
* free group, library doesn't need it.
80+
*/
81+
82+
fn_exit:
83+
MPI_Group_free(&wgroup);
84+
85+
if (sinfo != MPI_INFO_NULL) {
86+
MPI_Info_free(&sinfo);
87+
}
88+
89+
if (tinfo != MPI_INFO_NULL) {
90+
MPI_Info_free(&tinfo);
91+
}
92+
93+
if (ret != 0) {
94+
MPI_Session_finalize(&lib_shandle);
95+
}
96+
97+
return ret;
98+
}

sessions/sessions_ex2.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include "mpi.h"
5+
6+
int main(int argc, char *argv[])
7+
{
8+
int i, n_psets, psetlen, rc, ret;
9+
int valuelen;
10+
int flag = 0;
11+
char *pset_name = NULL;
12+
char *info_val = NULL;
13+
MPI_Session shandle = MPI_SESSION_NULL;
14+
MPI_Info sinfo = MPI_INFO_NULL;
15+
MPI_Group pgroup = MPI_GROUP_NULL;
16+
17+
if (argc < 2) {
18+
fprintf(stderr, "A process set name fragment is required\n");
19+
return -1;
20+
}
21+
22+
rc = MPI_Session_init(MPI_INFO_NULL, MPI_ERRORS_RETURN, &shandle);
23+
if (rc != MPI_SUCCESS) {
24+
fprintf(stderr, "Could not initialize session, bailing out\n");
25+
return -1;
26+
}
27+
28+
MPI_Session_get_num_psets(shandle, MPI_INFO_NULL, &n_psets);
29+
30+
for (i=0, pset_name=NULL; i<n_psets; i++) {
31+
psetlen = 0;
32+
MPI_Session_get_nth_pset(shandle, MPI_INFO_NULL, i,
33+
&psetlen, NULL);
34+
pset_name = (char *)malloc(sizeof(char) * psetlen);
35+
MPI_Session_get_nth_pset(shandle, MPI_INFO_NULL, i,
36+
&psetlen, pset_name);
37+
if (strstr(pset_name, argv[1]) != NULL) break;
38+
39+
free(pset_name);
40+
pset_name = NULL;
41+
}
42+
43+
/*
44+
* get instance of an info object for this Session
45+
*/
46+
47+
MPI_Session_get_pset_info(shandle, pset_name, &sinfo);
48+
MPI_Info_get_valuelen(sinfo, "size", &valuelen, &flag);
49+
info_val = (char *)malloc(valuelen+1);
50+
MPI_Info_get(sinfo, "size", valuelen, info_val, &flag);
51+
free(info_val);
52+
53+
/*
54+
* create a group from the process set
55+
*/
56+
57+
rc = MPI_Group_from_session_pset(shandle, pset_name,
58+
&pgroup);
59+
ret = (rc == MPI_SUCCESS) ? 0 : -1;
60+
61+
free(pset_name);
62+
MPI_Group_free(&pgroup);
63+
MPI_Info_free(&sinfo);
64+
MPI_Session_finalize(&shandle);
65+
66+
fprintf(stderr, "Test completed ret = %d\n", ret);
67+
return ret;
68+
69+
}

0 commit comments

Comments
 (0)