1# -*- shell-script ; indent-tabs-mode:nil -*- 2# 3# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4# University Research and Technology 5# Corporation. All rights reserved. 6# Copyright (c) 2004-2005 The University of Tennessee and The University 7# of Tennessee Research Foundation. All rights 8# reserved. 9# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10# University of Stuttgart. All rights reserved. 11# Copyright (c) 2004-2005 The Regents of the University of California. 12# All rights reserved. 13# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. 14# Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights 15# reserved. 16# Copyright (c) 2014-2019 Intel, Inc. All rights reserved. 17# Copyright (c) 2014-2018 Research Organization for Information Science 18# and Technology (RIST). All rights reserved. 19# Copyright (c) 2016-2021 IBM Corporation. All rights reserved. 20# $COPYRIGHT$ 21# 22# Additional copyrights may follow 23# 24# $HEADER$ 25# 26 27# define an internal function for checking the existence 28# and validity of a PMI library 29# 30# OPAL_CHECK_PMI_LIB(installdir, libdir, pmi, function, [action-if-slurm], [action-if-valid], [action-if-not-valid]) 31# -------------------------------------------------------- 32AC_DEFUN([OPAL_CHECK_PMI_LIB], 33[ 34 # save flags 35 opal_check_$3_save_CPPFLAGS=$CPPFLAGS 36 opal_check_$3_save_LDFLAGS=$LDFLAGS 37 opal_check_$3_save_LIBS=$LIBS 38 opal_check_$3_hdr_happy= 39 opal_check_$3_mycppflags= 40 41 # check for the header 42 AS_IF([test -n "$1"], 43 [AC_MSG_CHECKING([for $3.h in $1]) 44 AS_IF([test -f $1/$3.h && test -r $1/$3.h], 45 [AC_MSG_RESULT([found]) 46 opal_check_$3_mycppflags="-I$1"], 47 [AC_MSG_RESULT([not found]) 48 AC_MSG_CHECKING([for $3.h in $1/include]) 49 AS_IF([test -f $1/include/$3.h && test -r $1/include/$3.h], 50 [AC_MSG_RESULT([found]) 51 opal_check_$3_mycppflags="-I$1/include"], 52 [AC_MSG_RESULT([not found]) 53 AC_MSG_CHECKING([for $3.h in $1/include/slurm]) 54 AS_IF([test -f $1/include/slurm/$3.h && test -r $1/include/slurm/$3.h], 55 [AC_MSG_RESULT([found]) 56 opal_check_$3_mycppflags="-I$1/include/slurm" 57 $5], 58 [AC_MSG_RESULT([not found]) 59 opal_check_$3_hdr_happy=no])])])], 60 [AC_MSG_CHECKING([for $3.h in /usr/include]) 61 AS_IF([test -f /usr/include/$3.h && test -r /usr/include/$3.h], 62 [AC_MSG_RESULT([found])], 63 [AC_MSG_RESULT([not found]) 64 AC_MSG_CHECKING([for $3.h in /usr/include/slurm]) 65 AS_IF([test -f /usr/include/slurm/$3.h && test -r /usr/include/slurm/$3.h], 66 [AC_MSG_RESULT([found]) 67 opal_check_$3_mycppflags="-I/usr/include/slurm" 68 $5], 69 [AC_MSG_RESULT([not found]) 70 opal_check_$3_hdr_happy=no])])]) 71 72 AS_IF([test "$opal_check_$3_hdr_happy" != "no"], 73 [CPPFLAGS="$CPPFLAGS $opal_check_$3_mycppflags" 74 AC_CHECK_HEADER([$3.h], 75 [opal_check_$3_hdr_happy=yes 76 $3_CPPFLAGS="$opal_check_$3_mycppflags"], 77 [opal_check_$3_hdr_happy=no])]) 78 79 # check for library and function 80 opal_check_$3_lib_happy= 81 LIBS="$LIBS -l$3" 82 83 # check for the library in the given location in case 84 # an exact path was given 85 AS_IF([test -z "$1" && test -z "$2"], 86 [AC_CHECK_LIB([$3], [$4], 87 [opal_check_$3_lib_happy=yes], 88 [opal_check_$3_lib_happy=no])], 89 [AS_IF([test -n "$2"], 90 [AC_MSG_CHECKING([for lib$3 in $2]) 91 files=`ls $2/lib$3.* 2> /dev/null | wc -l` 92 AS_IF([test "$files" -gt "0"], 93 [AC_MSG_RESULT([found]) 94 LDFLAGS="$LDFLAGS -L$2" 95 AC_CHECK_LIB([$3], [$4], 96 [opal_check_$3_lib_happy=yes 97 $3_LDFLAGS=-L$2 98 $3_rpath=$2], 99 [opal_check_$3_lib_happy=no])], 100 [opal_check_$3_lib_happy=no 101 AC_MSG_RESULT([not found])])], 102 [AC_MSG_CHECKING([for lib$3 in $1/lib]) 103 files=`ls $1/lib/lib$3.* 2> /dev/null | wc -l` 104 AS_IF([test "$files" -gt "0"], 105 [AC_MSG_RESULT([found]) 106 LDFLAGS="$LDFLAGS -L$1/lib" 107 AC_CHECK_LIB([$3], [$4], 108 [opal_check_$3_lib_happy=yes 109 $3_LDFLAGS=-L$1/lib 110 $3_rpath=$1/lib], 111 [opal_check_$3_lib_happy=no])], 112 [# check for presence of lib64 directory - if found, see if the 113 # desired library is present and matches our build requirements 114 AC_MSG_CHECKING([for lib$3 in $1/lib64]) 115 files=`ls $1/lib64/lib$3.* 2> /dev/null | wc -l` 116 AS_IF([test "$files" -gt "0"], 117 [AC_MSG_RESULT([found]) 118 LDFLAGS="$LDFLAGS -L$1/lib64" 119 AC_CHECK_LIB([$3], [$4], 120 [opal_check_$3_lib_happy=yes 121 $3_LDFLAGS=-L$1/lib64 122 $3_rpath=$1/lib64], 123 [opal_check_$3_lib_happy=no])], 124 [opal_check_$3_lib_happy=no 125 AC_MSG_RESULT([not found])])])])]) 126 127 # restore flags 128 CPPFLAGS=$opal_check_$3_save_CPPFLAGS 129 LDFLAGS=$opal_check_$3_save_LDFLAGS 130 LIBS=$opal_check_$3_save_LIBS 131 132 AS_IF([test "$opal_check_$3_hdr_happy" = "yes" && test "$opal_check_$3_lib_happy" = "yes"], 133 [$6], [$7]) 134 135]) 136 137# OPAL_CHECK_PMI() 138# -------------------------------------------------------- 139AC_DEFUN([OPAL_CHECK_PMI],[ 140 OPAL_VAR_SCOPE_PUSH([check_pmi_install_dir check_pmi_lib_dir default_pmi_libloc slurm_pmi_found]) 141 142 AC_ARG_WITH([pmi], 143 [AC_HELP_STRING([--with-pmi(=DIR)], 144 [Build PMI support, optionally adding DIR to the search path (default: no)])], 145 [], with_pmi=no) 146 147 AC_ARG_WITH([pmi-libdir], 148 [AC_HELP_STRING([--with-pmi-libdir=DIR], 149 [Look for libpmi or libpmi2 in the given directory DIR, DIR/lib or DIR/lib64])]) 150 151 check_pmi_install_dir= 152 check_pmi_lib_dir= 153 default_pmi_libloc= 154 slurm_pmi_found= 155 opal_enable_pmix=no 156 157 AC_MSG_CHECKING([if user requested PMI support]) 158 AS_IF([test "$with_pmi" = "no"], 159 [AC_MSG_RESULT([no]) 160 $3], 161 [AC_MSG_RESULT([yes]) 162 # cannot use OPAL_CHECK_PACKAGE as its backend header 163 # support appends "include" to the path, which won't 164 # work with slurm :-( 165 AS_IF([test -n "$with_pmi" && test "$with_pmi" != "yes"], 166 [check_pmi_install_dir=$with_pmi]) 167 AS_IF([test -n "$with_pmi_libdir"], 168 [check_pmi_lib_dir=$with_pmi_libdir]) 169 170 # check for pmi-1 lib */ 171 slurm_pmi_found=no 172 OPAL_CHECK_PMI_LIB([$check_pmi_install_dir], 173 [$check_pmi_lib_dir], 174 [pmi], [PMI_Init], 175 [slurm_pmi_found=yes], 176 [opal_enable_pmi1=yes 177 opal_pmi1_LIBS="-lpmi" 178 AC_SUBST(opal_pmi1_LIBS)], 179 [opal_enable_pmi1=no]) 180 181 AS_IF([test "$opal_enable_pmi1" = "yes"], 182 [AS_IF([test "$slurm_pmi_found" = "yes"], 183 [opal_pmi1_CPPFLAGS="$pmi_CPPFLAGS" 184 AC_SUBST(opal_pmi1_CPPFLAGS)]) 185 AS_IF([test "$slurm_pmi_found" = "yes"], 186 [opal_pmi1_LDFLAGS="$pmi_LDFLAGS" 187 AC_SUBST(opal_pmi1_LDFLAGS) 188 opal_pmi1_rpath="$pmi_rpath" 189 AC_SUBST(opal_pmi1_rpath)])]) 190 191 # check for pmi2 lib */ 192 slurm_pmi_found=no 193 OPAL_CHECK_PMI_LIB([$check_pmi_install_dir], 194 [$check_pmi_lib_dir], 195 [pmi2], [PMI2_Init], 196 [slurm_pmi_found=yes], 197 [opal_enable_pmi2=yes 198 opal_pmi2_LIBS="-lpmi2" 199 AC_SUBST(opal_pmi2_LIBS)], 200 [opal_enable_pmi2=no]) 201 202 AS_IF([test "$opal_enable_pmi2" = "yes"], 203 [AS_IF([test "$slurm_pmi_found" = "yes"], 204 [opal_pmi2_CPPFLAGS="$pmi2_CPPFLAGS" 205 AC_SUBST(opal_pmi2_CPPFLAGS)]) 206 AS_IF([test "$slurm_pmi_found" = "yes"], 207 [opal_pmi2_LDFLAGS="$pmi2_LDFLAGS" 208 AC_SUBST(opal_pmi2_LDFLAGS) 209 opal_pmi2_rpath="$pmi2_rpath" 210 AC_SUBST(opal_pmi2_rpath)])]) 211 212 # check for pmix lib installed by slurm */ 213 slurm_pmix_found=no 214 OPAL_CHECK_PMIX_LIB([$check_pmi_install_dir], 215 [$check_pmi_lib_dir], 216 [opal_enable_pmix=yes], 217 [opal_enable_pmix=no]) 218 219 # since support was explicitly requested, then we should error out 220 # if we didn't find the required support 221 AC_MSG_CHECKING([can PMI support be built]) 222 AS_IF([test "$opal_enable_pmi1" != "yes" && test "$opal_enable_pmi2" != "yes" && test "$opal_enable_pmix" != "yes"], 223 [AC_MSG_RESULT([no]) 224 AC_MSG_WARN([PMI support requested (via --with-pmi) but neither pmi.h,]) 225 AC_MSG_WARN([pmi2.h or pmix.h were found under locations:]) 226 AC_MSG_WARN([ $check_pmi_install_dir]) 227 AC_MSG_WARN([ $check_pmi_install_dir/slurm]) 228 AC_MSG_WARN([Specified path: $with_pmi]) 229 AC_MSG_WARN([OR neither libpmi, libpmi2, or libpmix were found under:]) 230 AC_MSG_WARN([ $check_pmi_lib_dir/lib]) 231 AC_MSG_WARN([ $check_pmi_lib_dir/lib64]) 232 AC_MSG_WARN([Specified path: $with_pmi_libdir]) 233 AC_MSG_ERROR([Aborting])], 234 [AC_MSG_RESULT([yes])]) 235 ]) 236 237 OPAL_VAR_SCOPE_POP 238]) 239 240# define an internal function for checking the existence 241# and validity of an external PMIx library 242# 243# OPAL_CHECK_PMIX_LIB(installdir, libdir, [action-if-valid], [action-if-not-valid]) 244AC_DEFUN([OPAL_CHECK_PMIX_LIB],[ 245 246 OPAL_VAR_SCOPE_PUSH([opal_external_pmix_save_CPPFLAGS opal_external_pmix_save_LDFLAGS opal_external_pmix_save_LIBS]) 247 opal_external_pmix_happy=no 248 249 # Make sure we have the headers and libs in the correct location 250 AC_MSG_CHECKING([for pmix.h in $1]) 251 files=`ls $1/pmix.h 2> /dev/null | wc -l` 252 AS_IF([test "$files" -gt 0], 253 [AC_MSG_RESULT([found]) 254 opal_external_pmix_header_happy=yes], 255 [AC_MSG_RESULT([not found]) 256 AC_MSG_CHECKING([for pmix.h in $1/include]) 257 files=`ls $1/include/pmix.h 2> /dev/null | wc -l` 258 AS_IF([test "$files" -gt 0], 259 [AC_MSG_RESULT([found]) 260 opal_external_pmix_header_happy=yes], 261 [AC_MSG_RESULT([not found]) 262 opal_external_pmix_header_happy=no])]) 263 264 AS_IF([test "$opal_external_pmix_header_happy" = "yes"], 265 [AS_IF([test -n "$2"], 266 [AC_MSG_CHECKING([libpmix.* in $2]) 267 files=`ls $2/libpmix.* 2> /dev/null | wc -l` 268 AS_IF([test "$files" -gt 0], 269 [AC_MSG_RESULT([found]) 270 pmix_ext_install_libdir=$2], 271 [AC_MSG_RESULT([not found]) 272 AC_MSG_CHECKING([libpmix.* in $2/lib64]) 273 files=`ls $2/lib64/libpmix.* 2> /dev/null | wc -l` 274 AS_IF([test "$files" -gt 0], 275 [AC_MSG_RESULT([found]) 276 pmix_ext_install_libdir=$2/lib64], 277 [AC_MSG_RESULT([not found]) 278 AC_MSG_CHECKING([libpmix.* in $2/lib]) 279 files=`ls $2/lib/libpmix.* 2> /dev/null | wc -l` 280 AS_IF([test "$files" -gt 0], 281 [AC_MSG_RESULT([found]) 282 pmix_ext_install_libdir=$2/lib], 283 [AC_MSG_RESULT([not found]) 284 AC_MSG_ERROR([Cannot continue])])])])], 285 [# check for presence of lib64 directory - if found, see if the 286 # desired library is present and matches our build requirements 287 AC_MSG_CHECKING([libpmix.* in $1/lib64]) 288 files=`ls $1/lib64/libpmix.* 2> /dev/null | wc -l` 289 AS_IF([test "$files" -gt 0], 290 [AC_MSG_RESULT([found]) 291 pmix_ext_install_libdir=$1/lib64], 292 [AC_MSG_RESULT([not found]) 293 AC_MSG_CHECKING([libpmix.* in $1/lib]) 294 files=`ls $1/lib/libpmix.* 2> /dev/null | wc -l` 295 AS_IF([test "$files" -gt 0], 296 [AC_MSG_RESULT([found]) 297 pmix_ext_install_libdir=$1/lib], 298 [AC_MSG_RESULT([not found]) 299 AC_MSG_ERROR([Cannot continue])])])]) 300 301 # check the version 302 opal_external_pmix_save_CPPFLAGS=$CPPFLAGS 303 opal_external_pmix_save_LDFLAGS=$LDFLAGS 304 opal_external_pmix_save_LIBS=$LIBS 305 306 # if the pmix_version.h file does not exist, then 307 # this must be from a pre-1.1.5 version OMPI does 308 # NOT support anything older than v1.2.5 309 AC_MSG_CHECKING([PMIx version]) 310 CPPFLAGS="-I$1/include $CPPFLAGS" 311 AS_IF([test "x`ls $1/include/pmix_version.h 2> /dev/null`" = "x"], 312 [AC_MSG_RESULT([version file not found - assuming v1.1.4]) 313 opal_external_pmix_version_found=1 314 opal_external_pmix_happy=no 315 opal_external_pmix_version=internal], 316 [AC_MSG_RESULT([version file found]) 317 opal_external_pmix_version_found=0]) 318 319 # if it does exist, then we need to parse it to find 320 # the actual release series 321 AS_IF([test "$opal_external_pmix_version_found" = "0"], 322 [AC_MSG_CHECKING([version 4x]) 323 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ 324 #include <pmix_version.h> 325 #if (PMIX_VERSION_MAJOR < 4L) 326 #error "not version 4 or above" 327 #endif 328 ], [])], 329 [AC_MSG_RESULT([found]) 330 opal_external_pmix_version=4x 331 opal_external_pmix_version_major=4 332 opal_external_pmix_version_found=1 333 opal_external_pmix_happy=yes], 334 [AC_MSG_RESULT([not found])])]) 335 336 AS_IF([test "$opal_external_pmix_version_found" = "0"], 337 [AC_MSG_CHECKING([version 3x or above]) 338 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ 339 #include <pmix_version.h> 340 #if (PMIX_VERSION_MAJOR != 3L) 341 #error "not version 3" 342 #endif 343 ], [])], 344 [AC_MSG_RESULT([found]) 345 opal_external_pmix_version=3x 346 opal_external_pmix_version_major=3 347 opal_external_pmix_version_found=1 348 opal_external_pmix_happy=yes], 349 [AC_MSG_RESULT([not found])])]) 350 351 AS_IF([test "$opal_external_pmix_version_found" = "0"], 352 [AC_MSG_CHECKING([version 2x]) 353 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ 354 #include <pmix_version.h> 355 #if (PMIX_VERSION_MAJOR != 2L) 356 #error "not version 2" 357 #endif 358 ], [])], 359 [AC_MSG_RESULT([found]) 360 opal_external_pmix_version=2x 361 opal_external_pmix_version_major=2 362 opal_external_pmix_version_found=1 363 opal_external_pmix_happy=yes], 364 [AC_MSG_RESULT([not found])])]) 365 366 AS_IF([test "$opal_external_pmix_version_found" = "0"], 367 [AC_MSG_CHECKING([version 1x]) 368 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ 369 #include <pmix_version.h> 370 #if (PMIX_VERSION_MAJOR != 1L && PMIX_VERSION_MINOR != 2L) 371 #error "not version 1.2.x" 372 #endif 373 ], [])], 374 [AC_MSG_RESULT([found]) 375 opal_external_pmix_version=1x 376 opal_external_pmix_version_major=1 377 opal_external_pmix_version_found=1 378 opal_external_have_pmix1=1 379 opal_external_pmix_happy=yes], 380 [AC_MSG_RESULT([not found])])]) 381 382 AS_IF([test "x$opal_external_pmix_version" = "x"], 383 [AC_MSG_WARN([External PMIx support detected, but version]) 384 AC_MSG_WARN([information of the external lib could not]) 385 AC_MSG_WARN([be detected]) 386 opal_external_pmix_happy=no]) 387 388 CPPFLAGS=$opal_external_pmix_save_CPPFLAGS 389 LDFLAGS=$opal_external_pmix_save_LDFLAGS 390 LIBS=$opal_external_pmix_save_LIBS 391 ]) 392 AS_IF([test "$opal_external_pmix_happy" = "yes"], 393 [$3], [$4]) 394 395 OPAL_VAR_SCOPE_POP 396]) 397 398 399AC_DEFUN([OPAL_CHECK_PMIX],[ 400 401 AC_ARG_WITH([pmix], 402 [AC_HELP_STRING([--with-pmix(=DIR)], 403 [Build PMIx support. DIR can take one of three values: "internal", "external", or a valid directory name. "internal" (or no DIR value) forces Open MPI to use its internal copy of PMIx. "external" forces Open MPI to use an external installation of PMIx. Supplying a valid directory name also forces Open MPI to use an external installation of PMIx, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries. Note that Open MPI does not support --without-pmix.])]) 404 405 AC_ARG_WITH([pmix-libdir], 406 [AC_HELP_STRING([--with-pmix-libdir=DIR], 407 [Look for libpmix the given directory DIR, DIR/lib or DIR/lib64])]) 408 409 AS_IF([test "$with_pmix" = "no"], 410 [AC_MSG_WARN([Open MPI requires PMIx support. It can be built]) 411 AC_MSG_WARN([with either its own internal copy of PMIx, or with]) 412 AC_MSG_WARN([an external copy that you supply.]) 413 AC_MSG_ERROR([Cannot continue])]) 414 415 opal_external_have_pmix1=0 416 AS_IF([test "$opal_enable_pmix" = "no"], 417 [AC_MSG_CHECKING([if user requested internal PMIx support($with_pmix)]) 418 opal_external_pmix_happy=no 419 pmix_ext_install_libdir= 420 pmix_ext_install_dir= 421 422 AS_IF([test "$with_pmix" = "internal"], 423 [AC_MSG_RESULT([yes]) 424 opal_external_pmix_happy=no 425 opal_external_pmix_version=internal 426 opal_enable_pmix=yes], 427 428 [AC_MSG_RESULT([no]) 429 # check for external pmix lib */ 430 AS_IF([test -z "$with_pmix" || test "$with_pmix" = "yes" || test "$with_pmix" = "external"], 431 [pmix_ext_install_dir=/usr], 432 [pmix_ext_install_dir=$with_pmix]) 433 AS_IF([test -n "$with_pmix_libdir"], 434 [pmix_ext_install_libdir=$with_pmix_libdir]) 435 OPAL_CHECK_PMIX_LIB([$pmix_ext_install_dir], 436 [$pmix_ext_install_libdir], 437 [opal_external_pmix_happy=yes 438 opal_enable_pmix=yes], 439 [opal_external_pmix_happy=no])]) 440 441 # Final check - if they explicitly pointed us at an external 442 # installation that wasn't acceptable, then error out 443 AS_IF([test -n "$with_pmix" && test "$with_pmix" != "yes" && test "$with_pmix" != "external" && test "$with_pmix" != "internal" && test "$opal_external_pmix_happy" = "no"], 444 [AC_MSG_WARN([External PMIx support requested, but either the version]) 445 AC_MSG_WARN([of the external lib was not supported or the required]) 446 AC_MSG_WARN([header/library files were not found]) 447 AC_MSG_ERROR([Cannot continue])]) 448 449 # Final check - if they didn't point us explicitly at an external version 450 # but we found one anyway, use the internal version if it is higher 451 AS_IF([test "$opal_external_pmix_version" != "internal" && (test -z "$with_pmix" || test "$with_pmix" = "yes")], 452 [AS_IF([test "$opal_external_pmix_version" != "3x"], 453 [AC_MSG_WARN([discovered external PMIx version is less than internal version 3.x]) 454 AC_MSG_WARN([using internal PMIx]) 455 opal_external_pmix_version=internal 456 opal_external_pmix_happy=no])]) 457 ]) 458 459 AS_IF([test "$opal_enable_pmix" = "yes"], 460 [AC_MSG_CHECKING([PMIx version to be used]) 461 AS_IF([test "$opal_external_pmix_happy" = "yes"], 462 [AC_MSG_RESULT([external($opal_external_pmix_version)]) 463 AS_IF([test "$pmix_ext_install_dir" != "/usr"], 464 [opal_external_pmix_CPPFLAGS="-I$pmix_ext_install_dir/include" 465 opal_external_pmix_LDFLAGS=-L$pmix_ext_install_libdir]) 466 opal_external_pmix_LIBS=-lpmix], 467 [AC_MSG_RESULT([internal])])]) 468 469 AC_DEFINE_UNQUOTED([OPAL_PMIX_V1],[$opal_external_have_pmix1], 470 [Whether the external PMIx library is v1]) 471 472 AS_IF([test "$opal_external_pmix_happy" = "yes"], 473 [AS_IF([test "$opal_external_pmix_version" = "1x"], 474 [OPAL_SUMMARY_ADD([[Miscellaneous]],[[PMIx support]], [opal_pmix], [External (1.2.5) WARNING - DYNAMIC OPS NOT SUPPORTED])], 475 [OPAL_SUMMARY_ADD([[Miscellaneous]],[[PMIx support]], [opal_pmix], [External ($opal_external_pmix_version)])])], 476 [OPAL_SUMMARY_ADD([[Miscellaneous]], [[PMIx support]], [opal_pmix], [Internal])]) 477]) 478