Skip to content

Commit cb178ff

Browse files
committed
test/mpi: Add local only sessions init test
Add a test to verify the local only behavior of MPI_Session_init. To do so, we launch an extra process via mpiexec that will never call MPI_Session_init.
1 parent a483a0b commit cb178ff

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

test/mpi/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,7 @@
15301530
/session/session_psets
15311531
/session/session_self
15321532
/session/session_bsend
1533+
/session/session_local_only
15331534
/spawn/concurrent_spawns
15341535
/spawn/disconnect
15351536
/spawn/disconnect2

test/mpi/session/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ noinst_PROGRAMS = \
1616
session_re_init \
1717
session_psets \
1818
session_self \
19-
session_bsend
19+
session_bsend \
20+
session_local_only
2021

2122
session_mult_init_SOURCES = session.c
2223
session_mult_init_CPPFLAGS = -DMULT_INIT $(AM_CPPFLAGS)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) by Argonne National Laboratory
3+
* See COPYRIGHT in top-level directory
4+
*/
5+
6+
#include "mpi.h"
7+
#include "stdio.h"
8+
9+
/*
10+
static char MTEST_Descrip[] = "Test MPI Sessions local-only behavior.
11+
No communication is performed. Intended to run with a minimum of 2 MPI
12+
processes and at least 1 non-MPI process. This verifies the local,
13+
non-collective nature of MPI Sessions initialization and group
14+
construction APIs. Example launch command:
15+
16+
mpiexec -n 2 ./session_local_only : -n 1 true
17+
18+
The world group size will be 3, but only 2 processes will initialize
19+
and make MPI calls. An correct implementation should not hang.
20+
*/
21+
22+
int main(int argc, char *argv[])
23+
{
24+
MPI_Session session;
25+
MPI_Group group;
26+
int rank, size;
27+
28+
MPI_Session_init(MPI_INFO_NULL, MPI_ERRORS_RETURN, &session);
29+
30+
MPI_Group_from_session_pset(session, "mpi://world", &group);
31+
MPI_Group_rank(group, &rank);
32+
MPI_Group_size(group, &size);
33+
if (size < 3) {
34+
/* no communicator so directly call errhandler */
35+
MPI_Session_call_errhandler(session, 1);
36+
}
37+
38+
MPI_Group_free(&group);
39+
MPI_Session_finalize(&session);
40+
if (rank == 0) {
41+
printf("No Errors\n");
42+
}
43+
44+
return 0;
45+
}

test/mpi/session/testlist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ session_re_init 4
55
session_psets 1
66
session_self 1
77
session_bsend 2
8+
# args to session_local_only append ": -n 1 true" to mpiexec
9+
session_local_only 2 timeLimit=10 arg=: arg=-n arg=1 arg=true

0 commit comments

Comments
 (0)