Skip to content

Commit 1c45ea3

Browse files
authored
envmgmt: error class/code/string test (#35)
* envmgmt: error class/code/string test Tests for MPI_Remove_error_{class,code,string} added in MPI 4.1 Notes: - autotooling to dynamically check for MPI_Remove_error_* fns Note: auto-tooling is mostly copy/paste from Jeff's status test - if symbols not found, skips. However, if we detect we have a new enough MPI >= 4.1, we will print msg that these should exist. * update autogen.sh and fix test output typos * Update environ-mgmt/README.md, fix typos * envmgmt: add fortran test to check remove_error_* * envmgmt: update configure.ac to prefer mpifort * add pthreads stress-test for MPI_Remove_error_* * add missing mpi_init_thread * update readme and avoid warning --------- Signed-off-by: Thomas Naughton <[email protected]>
1 parent 338c54c commit 1c45ea3

11 files changed

+990
-0
lines changed

environ-mgmt/Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
3+
# Copyright (c) 2025 UT-Battelle, LLC. All rights reserved
4+
#
5+
# $COPYRIGHT$
6+
#
7+
8+
SUBDIRS = src

environ-mgmt/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Environ Management Tests
2+
------------------------
3+
4+
Tests for items in the "MPI Environmental Management" chapter.
5+
6+
These are being created in the ompi-tests-public repository
7+
to ensure they are easy to access.
8+
9+
Using autotools to detect if we have the MPI-4.1 remove error code
10+
functionality, otherwise skips.
11+
12+
Usage
13+
-----
14+
- Ensure MPI `mpicc` in `PATH`
15+
- Run autogen/configure/make to build test
16+
17+
```
18+
cd environ-mgmt/
19+
./autogen.sh && ./configure && make
20+
```
21+
22+
- Run test(s)
23+
24+
```
25+
mpirun -np 1 ./src/test_add_del_err_codes
26+
mpirun -np 1 ./src/test_add_del_err_codes_pthreads
27+
```
28+
29+
- (Fortran) Build/Run
30+
```
31+
./autogen.sh && ./configure FC=mpifort && make
32+
mpirun -np 1 ./src/test_add_err_codes_usempi
33+
mpirun -np 1 ./src/test_add_err_codes_usempif08
34+
```
35+
36+
Tests
37+
-----
38+
39+
### test_add_del_err_codes
40+
Basic C test for `MPI_Add_error_class/code/string` and `MPI_Remove_error_class/code/string` functionality.
41+
42+
### test_add_del_err_codes_pthreads
43+
Multi-threaded stress test using pthreads to verify thread-safety of error code management APIs. Creates 10 concurrent threads that each add and remove error classes, codes, and strings with random sleep intervals to stress concurrent operations. Requires `MPI_THREAD_MULTIPLE` and pthread support.
44+
45+
### test_add_err_codes_usempi
46+
Fortran test using `use mpi` interface.
47+
48+
### test_add_err_codes_usempif08
49+
Fortran test using `use mpi_f08` interface.
50+
51+
Example Output
52+
--------------
53+
54+
- On MPI 3.x
55+
```
56+
laptop:$ mpirun -np 1 ./src/test_add_del_err_codes
57+
TEST: Success creating error class/code/string (last=92, newlast=94)
58+
==== Adds done ====
59+
==== Remove estring ====
60+
Warning: MPI_Remove_error_xxx code/class/string NOT available!
61+
==== Remove ecode ====
62+
Warning: MPI_Remove_error_xxx code/class/string NOT available!
63+
==== Remove eclass ====
64+
Warning: MPI_Remove_error_xxx code/class/string NOT available!
65+
DONE: Success
66+
laptop$ echo $?
67+
0
68+
laptop$
69+
```
70+
71+
- On MPI 4.1 or later
72+
```
73+
laptop:$ mpirun -np 1 ./src/test_add_del_err_codes
74+
TEST: Success creating error class/code/string (last=92, newlast=94)
75+
==== Adds done ====
76+
==== Remove estring ====
77+
==== Remove ecode ====
78+
TEST: Success reomved error code (oldlast=94, newlast=93)
79+
==== Remove eclass ====
80+
TEST: Success reomved error class (oldlast=93, newlast=92)
81+
DONE: Success
82+
laptop$ echo $?
83+
0
84+
laptop$
85+
```
86+

environ-mgmt/autogen.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
autoreconf --install
4+

environ-mgmt/config/.gitkeep

Whitespace-only changes.

environ-mgmt/configure.ac

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2012-2020 Cisco Systems, Inc. All rights reserved.
4+
# Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
5+
#
6+
# $COPYRIGHT$
7+
#
8+
9+
dnl
10+
dnl Init autoconf
11+
dnl
12+
13+
AC_PREREQ([2.67])
14+
AC_INIT([mpi-environmgmt-test], [1.0], [http://www.open-mpi.org])
15+
AC_CONFIG_AUX_DIR([config])
16+
AC_CONFIG_MACRO_DIR([config])
17+
AC_CONFIG_SRCDIR([.])
18+
19+
echo "Configuring Environmental Management test"
20+
21+
AM_INIT_AUTOMAKE([1.11 foreign -Wall -Werror])
22+
23+
# If Automake supports silent rules, enable them.
24+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25+
26+
AH_TOP([/* -*- c -*-
27+
*
28+
* Environmental Management test suite configuation header file.
29+
* See the top-level LICENSE file for license and copyright
30+
* information.
31+
*/
32+
33+
#ifndef MPI_ENVIRONMGMT_TEST_CONFIG_H
34+
#define MPI_ENVIRONMGMT_TEST_CONFIG_H
35+
])
36+
AH_BOTTOM([#endif /* MPI_ENVIRONMGMT_TEST_CONFIG_H */])
37+
38+
dnl
39+
dnl Make automake clean emacs ~ files for "make clean"
40+
dnl
41+
42+
CLEANFILES="*~"
43+
AC_SUBST(CLEANFILES)
44+
45+
dnl
46+
dnl Get various programs
47+
dnl Bias towards mpicc/mpic++/mpif77
48+
dnl C compiler
49+
dnl
50+
51+
if test "$CC" != ""; then
52+
BASE="`basename $CC`"
53+
else
54+
BASE=
55+
fi
56+
if test "$BASE" = "" -o "$BASE" = "." -o "$BASE" = "cc" -o \
57+
"$BASE" = "gcc" -o "$BASE" = "xlc" -o "$BASE" = "pgcc" -o \
58+
"$BASE" = "icc"; then
59+
AC_CHECK_PROG(HAVE_MPICC, mpicc, yes, no)
60+
if test "$HAVE_MPICC" = "yes"; then
61+
CC=mpicc
62+
export CC
63+
fi
64+
fi
65+
66+
CFLAGS_save=$CFLAGS
67+
AC_PROG_CC
68+
CFLAGS=$CFLAGS_save
69+
70+
dnl
71+
dnl Fortran compiler - prefer mpifort if available
72+
dnl
73+
74+
if test "$FC" = ""; then
75+
AC_CHECK_PROG(HAVE_MPIFORT, mpifort, yes, no)
76+
if test "$HAVE_MPIFORT" = "yes"; then
77+
FC=mpifort
78+
export FC
79+
fi
80+
fi
81+
82+
FFLAGS_save=$FFLAGS
83+
AC_PROG_FC
84+
FFLAGS=$FFLAGS_save
85+
86+
87+
dnl
88+
dnl Because these are meant to be used for debugging, after all
89+
dnl
90+
91+
if test -z "$CFLAGS"; then
92+
CFLAGS="-g"
93+
fi
94+
95+
dnl
96+
dnl Ensure that we can compile and link a C MPI program
97+
dnl
98+
99+
AC_LANG_PUSH([C])
100+
AC_CHECK_HEADERS(mpi.h)
101+
102+
AC_MSG_CHECKING([if linking MPI program works])
103+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>
104+
]],
105+
[[MPI_Comm a = MPI_COMM_WORLD]])],
106+
[AC_MSG_RESULT([yes])],
107+
[AC_MSG_RESULT([no])
108+
AC_MSG_WARN([Simple MPI program fails to link])
109+
AC_MSG_ERROR([Cannot continue])
110+
])
111+
112+
AC_CHECK_LIB([mpi], [MPI_Add_error_code],
113+
[AC_DEFINE([HAVE_MPI_ADD_ERROR_CODE], [1], [Define if have MPI_Add_error_code])],
114+
[AC_MSG_WARN([MPI_Add_error_code not found; disable related features])])
115+
116+
117+
AC_CHECK_LIB([mpi], [MPI_Remove_error_code],
118+
[AC_DEFINE([HAVE_MPI_REMOVE_ERROR_CODE], [1], [Define if have MPI_Remove_error_code])],
119+
[AC_MSG_WARN([MPI_Remove_error_code not found; disable related features])])
120+
121+
AC_CHECK_LIB([mpi], [MPI_Remove_error_class],
122+
[AC_DEFINE([HAVE_MPI_REMOVE_ERROR_CLASS], [1], [Define if have MPI_Remove_error_class])],
123+
[AC_MSG_WARN([MPI_Remove_error_class not found; disable related features])])
124+
125+
AC_CHECK_LIB([mpi], [MPI_Remove_error_string],
126+
[AC_DEFINE([HAVE_MPI_REMOVE_ERROR_STRING], [1], [Define if have MPI_Remove_error_string])],
127+
[AC_MSG_WARN([MPI_Remove_error_string not found; disable related features])])
128+
129+
AC_SUBST([MPI_LIBS])
130+
131+
dnl
132+
dnl Check for pthreads support
133+
dnl
134+
135+
AC_SEARCH_LIBS([pthread_create], [pthread], [have_pthread=yes], [have_pthread=no])
136+
if test "$have_pthread" = "yes"; then
137+
AC_DEFINE([HAVE_PTHREAD], [1], [Define if have pthreads])
138+
fi
139+
140+
AC_LANG_POP([C])
141+
142+
dnl
143+
dnl Party on
144+
dnl
145+
146+
AC_CONFIG_HEADERS([config.h])
147+
AC_CONFIG_FILES([
148+
Makefile
149+
src/Makefile
150+
])
151+
AC_OUTPUT

environ-mgmt/src/Makefile.am

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
3+
# Copyright (c) 2025 UT-Battelle, LLC. All rights reserved
4+
#
5+
#
6+
# $COPYRIGHT$
7+
#
8+
9+
noinst_PROGRAMS = test_add_del_err_codes \
10+
test_add_del_err_codes_pthreads \
11+
test_add_err_codes_usempi \
12+
test_add_del_err_codes_usempi \
13+
test_add_del_err_codes_usempif08
14+
15+
test_add_del_err_codes_SOURCES = \
16+
test_add_del_err_codes.c
17+
18+
test_add_del_err_codes_pthreads_SOURCES = \
19+
test_add_del_err_codes_pthreads.c
20+
21+
test_add_err_codes_usempi_SOURCES = \
22+
test_add_err_codes_usempi.f90
23+
24+
test_add_del_err_codes_usempi_SOURCES = \
25+
test_add_del_err_codes_usempi.f90
26+
27+
test_add_del_err_codes_usempif08_SOURCES = \
28+
test_add_del_err_codes_usempif08.f90
29+
30+

0 commit comments

Comments
 (0)