acx_mpi_defects.m4 7.15 KB
Newer Older
1
2
3
4
5
6
7
8
dnl acx_mpi_defects.m4 --- check whether MPI has one or more of
dnl                        several known defects
dnl
dnl Copyright  (C)  2014  Thomas Jahns <jahns@dkrz.de>
dnl
dnl Keywords: configure configure.ac autoconf MPI mpirun mpiexec
dnl Author: Thomas Jahns <jahns@dkrz.de>
dnl Maintainer: Thomas Jahns <jahns@dkrz.de>
Thomas Jahns's avatar
Thomas Jahns committed
9
dnl URL: https://www.dkrz.de/redmine/projects/scales-ppm
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are  permitted provided that the following conditions are
dnl met:
dnl
dnl Redistributions of source code must retain the above copyright notice,
dnl this list of conditions and the following disclaimer.
dnl
dnl Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the DKRZ GmbH nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl
39
dnl ACX_MPI_DEFECTS([TEST-SOURCE-DIR=$srcdir/config/checksrc],
40
dnl                 [ACTION-IF-CHECK-SUCCEEDS],
41
42
dnl                 [ACTION-IF-CHECK-FAILED=AC_MSG_FAILURE],
dnl                 [LIST-OF-TEST-GLOBS=[*]])
43
44
45
46
47
48
49
50
51
52
53
54
55
dnl
dnl Requires MPI_LAUNCH program. Also CC/FC must be setup to
dnl build MPI programs.
dnl Builds and runs simple programs from TEST-SOURCE-DIR, each of which
dnl should represent a test for a known defect that affects the library
dnl code.
dnl Each test is built according to it's file suffix as either Fortran
dnl or C MPI program.
dnl Within ACTION-IF-CHECK-SUCCEEDS and ACTION-IF-CHECK-FAILED,
dnl the following variables are set to test-specific values:
dnl acx_subtestname = base file name of the test
dnl acx_mpi_check_src = path to check source file
dnl acx_suffix = file suffix of source file
56
57
58
59
dnl
dnl Each test source may contain zero or more of the following stanzas
dnl acx_mpirun_num_tasks = N
dnl   specify number of tasks N (positive integer) to run this test with
60
61
dnl TODO: extend for F77 and C++
AC_DEFUN([ACX_MPI_DEFECTS],
62
63
64
65
66
67
68
69
70
71
72
  [AC_ARG_ENABLE([cross-mpi-defect-checks],
     AS_HELP_STRING([--enable-cross-mpi-defect-checks],
       [Run MPI defect tests even in cross-compilation mode. This is]dnl
[ typically useful in a setup where the mpi-starter (see MPI_LAUNCH)]dnl
[ executes programs on another system than the one running configure]dnl
[ which matches the host specification.]dnl
[ @<:@default=no@:>@]),
     [AS_IF([test x"$enable_cross_mpi_defect_checks" != xno],
        [enable_cross_mpi_defect_checks=yes])],
     [enable_cross_mpi_defect_checks=no])
   AS_IF([test x"$MPI_LAUNCH" = xtrue],
73
     [AC_MSG_NOTICE([Skipping tests for known MPI defects: MPI launcher unavailable])],
74
75
76
77
     [test $cross_compiling = yes -a $enable_cross_mpi_defect_checks = no],
     [AC_MSG_NOTICE([Skipping tests for known MPI defects in cross-]dnl
[compilation mode, consider enabling them via ]dnl
[--enable-cross-mpi-defect-checks, if possible])],
78
79
     [AC_MSG_CHECKING([MPI for known defects])
      AC_MSG_RESULT([])
80
81
82
83
84
85
86
87
88
m4_ifval([$4],
  [m4_pushdef([acx_test_pat],
     m4_dquote(m4_foreach([acx_temp],[$4],
       ["]m4_dquote(m4_default([$1],[$srcdir/config/checksrc]))[/"]acx_temp)))],
  [m4_pushdef([acx_test_pat],
     ["]m4_dquote(m4_default([$1],[$srcdir/config/checksrc]))[/"*])])dnl
      AS_FOR([acx_mpi_check_src_],[acx_mpi_check_src],acx_test_pat,[
	AS_IF([test ! -r "]acx_mpi_check_src_[" \
            && test x"]acx_mpi_check_src_[" = x]m4_bpatsubst(m4_dquote(m4_defn([acx_test_pat])),[[*?]],[\\\&]),
Thomas Jahns's avatar
Thomas Jahns committed
89
90
91
92
93
94
95
96
97
98
99
100
	  [break])
	acx_suffix=`echo "acx_mpi_check_src_" | sed 's/^.*\.\(@<:@^.@:>@*\)$/\1/'`
	acx_subtestname=`echo "acx_mpi_check_src_" | sed 's/^.*\/\(@<:@^\/@:>@*\)\.@<:@^.@:>@*/\1/'`
	AS_CASE([$acx_suffix],
	  [c],
	  [cat confdefs.h "acx_mpi_check_src_" >conftest."$acx_suffix"
	   AC_LANG_PUSH([C])],
	  [f90|F90],[cat "acx_mpi_check_src_" >conftest."$acx_suffix"
	   AC_LANG_PUSH([Fortran])],
	  [AC_MSG_FAILURE([Unexpected language in MPI check: ${acx_subtestname}.${acx_suffix}])])
	AC_MSG_CHECKING([$acx_subtestname])
	acx_mpirun_num_tasks=`sed -n '/acx_mpirun_num_tasks *= *\(@<:@0-9@:>@*\)/{
101
102
103
104
s/.*acx_mpirun_num_tasks *= *\(@<:@0-9@:>@*\).*/\1/
p
q
}
Thomas Jahns's avatar
Thomas Jahns committed
105
106
107
108
' "acx_mpi_check_src_"`
	AS_IF([test `expr "$acx_mpirun_num_tasks" : "@<:@0-9@:>@@<:@0-9@:>@*$"` -gt 0 \
	       && test "$acx_mpirun_num_tasks" -gt 0],,
	  [acx_mpirun_num_tasks=1])
Thomas Jahns's avatar
Thomas Jahns committed
109
110
111
112
113
114
115
116
117
        acx_mpirun_expected_exitcode=`sed -n '/acx_mpirun_expected_exitcode *= *\(@<:@0-9@:>@*\)/{
s/.*acx_mpirun_expected_exitcode *= *\(@<:@0-9@:>@*\).*/\1/
p
q
}
' "acx_mpi_check_src_"`
	AS_IF([test `expr "$acx_mpirun_expected_exitcode" : "@<:@0-9@:>@@<:@0-9@:>@*$"` -gt 0 \
	       && test "$acx_mpirun_expected_exitcode" -gt 0],,
	  [acx_mpirun_expected_exitcode=0])
Thomas Jahns's avatar
Thomas Jahns committed
118
119
	AC_LINK_IFELSE(,
	  [acx_mpirun_num_tasks="$MPI_LAUNCH -n $acx_mpirun_num_tasks ./conftest$EXEEXT"
Thomas Jahns's avatar
Thomas Jahns committed
120
121
           AS_IF([expr "$ac_link" : '.*/libtool --mode=link' >/dev/null],
             [acx_mpirun_test=`echo "$ac_link" | sed -e 's@\(.*/libtool --mode=\)link.*@\1@'`"execute $acx_mpirun_test"])
Thomas Jahns's avatar
Thomas Jahns committed
122
	   _AC_RUN_LOG_LIMIT([LIBC_FATAL_STDERR_=1 $acx_mpirun_num_tasks >&2],[echo "running $acx_mpirun_num_tasks"])
Thomas Jahns's avatar
Thomas Jahns committed
123
	   AS_IF([test $ac_status -eq $acx_mpirun_expected_exitcode],
Thomas Jahns's avatar
Thomas Jahns committed
124
125
	     [acx_mpi_defects_result=okay; acx_mpi_defects_fail=no]m4_ifval([$2],[
	      $2]),
126
127
	     [acx_mpi_defects_result=error ; acx_mpi_defects_fail=yes])],
	  [acx_mpi_defects_result=error ; acx_mpi_defects_fail=yes])
Thomas Jahns's avatar
Thomas Jahns committed
128
        AC_MSG_RESULT([$acx_mpi_defects_result])
Thomas Jahns's avatar
Thomas Jahns committed
129
130
	AS_CASE([$acx_suffix],
	  [f90|F90],[AC_LANG_POP([Fortran])],
131
132
133
	  [c],[AC_LANG_POP([C])])
        AS_IF([test x"$acx_mpi_defects_fail" = xyes],
          [m4_default([$3],[AC_MSG_FAILURE([chosen MPI has known error $acx_subtestname])])])])
134
m4_popdef([acx_test_pat])dnl
135
136
137
138
139
      ASX_VAR_UNSET([acx_mpirun_num_tasks])
      ASX_VAR_UNSET([acx_mpi_check_src])
      ASX_VAR_UNSET([acx_suffix])
      ASX_VAR_UNSET([acx_subtestname])
     ])])
140
141
142
dnl dump text documentation of defect test to stderr
dnl ACX_MPI_DEFECTS_DOCUMENT([TEST-DOC-DIR=config/checkdoc])
AC_DEFUN([ACX_MPI_DEFECTS_DOCUMENT],
143
144
  [AS_IF([test -r "$srcdir/m4_default([$1],[config/checkdoc])/${acx_subtestname}.txt"],
             [cat "$srcdir/m4_default([$1],[config/checkdoc])/${acx_subtestname}.txt" >&2])])
145
146
147
dnl
dnl Local Variables:
dnl mode: autoconf
Thomas Jahns's avatar
Thomas Jahns committed
148
dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
149
150
dnl license-default: "bsd"
dnl End: