1dnl
2dnl Copyright (c) 2013-2014 Intel, Inc.  All rights reserved.
3dnl Copyright (c) 2015      Research Organization for Information Science
4dnl                         and Technology (RIST). All rights reserved.
5dnl $COPYRIGHT$
6dnl
7dnl Additional copyrights may follow
8dnl
9dnl $HEADER$
10dnl
11
12#
13# --with-ft=TYPE
14#  TYPE:
15#    - LAM (synonym for 'cr' currently)
16#    - cr
17#  /* General FT sections */
18#  #if OPAL_ENABLE_FT == 0 /* FT Disabled globaly */
19#  #if OPAL_ENABLE_FT == 1 /* FT Enabled globaly */
20#  /* CR Specific sections */
21#  #if OPAL_ENABLE_FT_CR == 0 /* FT Ckpt/Restart Disabled */
22#  #if OPAL_ENABLE_FT_CR == 1 /* FT Ckpt/Restart Enabled */
23#
24
25# This macro is necessary to get the title to be displayed first.  :-)
26AC_DEFUN([OPAL_SETUP_FT_BANNER],[
27    opal_show_subtitle "Fault tolerance"
28])
29
30AC_DEFUN([OPAL_SETUP_FT_OPTIONS],[
31    AC_REQUIRE([OPAL_SETUP_FT_BANNER])
32    # define a variable that tells us that these options were enabled
33    opal_setup_ft_options="yes"
34    AC_ARG_WITH(ft,
35                [AC_HELP_STRING([--with-ft=TYPE],
36                [Specify the type of fault tolerance to enable. Options: LAM (LAM/MPI-like), cr (Checkpoint/Restart), (default: disabled)])],
37                [opal_want_ft=1],
38                [opal_want_ft=0])
39
40    #
41    # Checkpoint/restart enabled debugging
42    #
43    AC_ARG_ENABLE([crdebug],
44                  [AC_HELP_STRING([--enable-crdebug],
45                  [enable checkpoint/restart debugging functionality (default: disabled)])])
46
47    #
48    # Fault Tolerance Thread
49    #
50    # --enable-ft-thread
51    #  #if OPAL_ENABLE_FT_THREAD == 0 /* Disabled */
52    #  #if OPAL_ENABLE_FT_THREAD == 1 /* Enabled  */
53    #
54    AC_ARG_ENABLE([ft_thread],
55                  [AC_HELP_STRING([--disable-ft-thread],
56                  [Disable fault tolerance thread running inside all processes. Requires OPAL thread support (default: enabled)])],
57                  [enable_ft_thread="$enableval"],
58                  [enable_ft_thread="undef"])
59
60])
61
62AC_DEFUN([OPAL_SETUP_FT],[
63    if test "$opal_setup_ft_options" = "yes"; then
64        AC_MSG_CHECKING([if want fault tolerance])
65    fi
66    if test "x$with_ft" != "x" || test "$opal_want_ft" = "1"; then
67        opal_want_ft=1
68        opal_want_ft_cr=0
69        opal_want_ft_type=none
70
71        as_save_IFS=$IFS
72        IFS=","
73        for opt in $with_ft; do
74            IFS=$as_save_IFS
75
76            # Default value
77            if test "$opt" = "" || test "$opt" = "yes"; then
78                opal_want_ft_cr=1
79            elif test "$opt" = "LAM"; then
80                opal_want_ft_cr=1
81            elif test "$opt" = "lam"; then
82                opal_want_ft_cr=1
83            elif test "$opt" = "CR"; then
84                opal_want_ft_cr=1
85            elif test "$opt" = "cr"; then
86                opal_want_ft_cr=1
87            else
88                AC_MSG_RESULT([Unrecognized FT TYPE: $opt])
89                AC_MSG_ERROR([Cannot continue])
90            fi
91        done
92        if test "$opal_want_ft_cr" = 1; then
93            opal_want_ft_type="cr"
94        fi
95
96        AC_MSG_RESULT([Enabled $opal_want_ft_type (Specified $with_ft)])
97        AC_MSG_WARN([**************************************************])
98        AC_MSG_WARN([*** Fault Tolerance Integration into Open MPI is *])
99        AC_MSG_WARN([*** a research quality implementation, and care  *])
100        AC_MSG_WARN([*** should be used when choosing to enable it.   *])
101        AC_MSG_WARN([**************************************************])
102    else
103        opal_want_ft=0
104        opal_want_ft_cr=0
105        if test "$opal_setup_ft_options" = "yes"; then
106            AC_MSG_RESULT([Disabled fault tolerance])
107        fi
108    fi
109    AC_DEFINE_UNQUOTED([OPAL_ENABLE_FT], [$opal_want_ft],
110                       [Enable fault tolerance general components and logic])
111    AC_DEFINE_UNQUOTED([OPAL_ENABLE_FT_CR], [$opal_want_ft_cr],
112                       [Enable fault tolerance checkpoint/restart components and logic])
113    AM_CONDITIONAL(WANT_FT, test "$opal_want_ft" = "1")
114    AM_CONDITIONAL(WANT_FT_CR,  test "$opal_want_ft_cr" = "1")
115
116    if test "$opal_setup_ft_options" = "yes"; then
117        AC_MSG_CHECKING([if want checkpoint/restart enabled debugging option])
118    fi
119    if test "$opal_want_ft" = "0"; then
120        opal_want_prd=0
121        if test "$opal_setup_ft_options" = "yes"; then
122            AC_MSG_RESULT([Disabled (fault tolerance disabled --without-ft)])
123        fi
124    elif test "$enable_crdebug" = "yes"; then
125        opal_want_prd=1
126        AC_MSG_RESULT([Enabled])
127    else
128        opal_want_prd=0
129        if test "$opal_setup_ft_options" = "yes"; then
130            AC_MSG_RESULT([Disabled])
131        fi
132    fi
133    AC_DEFINE_UNQUOTED([OPAL_ENABLE_CRDEBUG], [$opal_want_prd],
134                       [Whether we want checkpoint/restart enabled debugging functionality or not])
135
136    if test "$opal_setup_ft_options" = "yes"; then
137        AC_MSG_CHECKING([if want fault tolerance thread])
138    fi
139    # if they do not want FT support, then they do not want this thread either
140    if test "$opal_want_ft" = "0"; then
141        opal_want_ft_thread=0
142        if test "$opal_setup_ft_options" = "yes"; then
143            AC_MSG_RESULT([Disabled (fault tolerance disabled --without-ft)])
144        fi
145    # if --disable-ft-thread
146    elif test "$enable_ft_thread" = "no"; then
147        opal_want_ft_thread=0
148        AC_MSG_RESULT([Disabled])
149    # if default, and no progress or MPI threads
150    elif test "$enable_ft_thread" = "undef" && test "$enable_opal_multi_threads" = "no" ; then
151        opal_want_ft_thread=0
152        AC_MSG_RESULT([Disabled (OPAL Thread Support Disabled)])
153    # if default, and MPI threads enabled for C/R only
154    elif test "$opal_want_ft_cr" = 1; then
155        # Default: Enable
156        # Make sure we have OPAL Threads enabled
157        if test "$enable_opal_multi_threads" = "no"; then
158            AC_MSG_RESULT([Must enable OPAL basic thread support to use this option])
159            AC_MSG_ERROR([Cannot continue])
160        else
161            AC_MSG_RESULT([yes])
162            opal_want_ft_thread=1
163            AC_MSG_WARN([**************************************************])
164            AC_MSG_WARN([*** Fault Tolerance with a thread in Open MPI    *])
165            AC_MSG_WARN([*** is an experimental, research quality option. *])
166            AC_MSG_WARN([*** It requires OPAL thread support and care     *])
167            AC_MSG_WARN([*** should be used when enabling these options.  *])
168            AC_MSG_WARN([**************************************************])
169        fi
170    # Otherwise disabled
171    else
172        opal_want_ft_thread=0
173        AC_MSG_RESULT([Disabled (Non-C/R Fault Tolerance enabled)])
174    fi
175    AC_DEFINE_UNQUOTED([OPAL_ENABLE_FT_THREAD], [$opal_want_ft_thread],
176                       [Enable fault tolerance thread in Open PAL])
177    AM_CONDITIONAL(WANT_FT_THREAD, test "$opal_want_ft_thread" = "1")
178])
179