Skip to content

Commit 2cde1ed

Browse files
committed
WIP for #205
1 parent 3d3a422 commit 2cde1ed

File tree

1 file changed

+43
-94
lines changed

1 file changed

+43
-94
lines changed

turbine/code/configure.ac

+43-94
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,17 @@ AC_SUBST(USE_LIBCUTILS_A)
217217

218218
# MPI defaults (may be overridden on special systems)
219219
USE_MACHINE=normal
220+
220221
# The "launcher" is used by job submission systems to launch jobs
221222
# Usually a path to mpiexec
222223
# Note: schedulers are handled by turbine/scripts/submit/*
223224
USE_LAUNCHER=0
225+
226+
# This is set my --with-mpi
227+
# Normally this is the prefix of an MPI build,
228+
# or /usr in an APT or Yum installation
224229
USE_MPI_DIR=0
230+
225231
USE_MPI_INCLUDE=0
226232
USE_MPI_LIB_DIR=0
227233
USE_MPI_LIB_NAME=
@@ -256,10 +262,6 @@ AC_ARG_WITH(mpi,
256262
fi
257263
fi
258264
USE_MPI_DIR=${withval}
259-
if [[ -d ${USE_MPI_DIR}/include ]]
260-
then
261-
USE_MPI_INCLUDE=${USE_MPI_DIR}/include
262-
fi
263265
MPI_LABEL_DIR="${USE_MPI_DIR}"
264266
AC_MSG_RESULT([Trying MPI directory: ${USE_MPI_DIR}])
265267
],
@@ -298,89 +300,20 @@ AC_ARG_ENABLE(mpi-checks,
298300
if [[ ${USE_MPI_DIR} == 0 ]] && [[ ${ENABLE_CUSTOM_MPI} == 0 ]]
299301
then
300302
program=$( which mpicc 2> /dev/null)
301-
if [[ ${?} == 0 ]]
303+
if (( ${?} == 0 ))
302304
then
303305
AC_MSG_RESULT([PATH contains: ${program}])
304-
TRY_MPI_DIR=$( cd $(dirname ${program})/.. ; /bin/pwd )
305-
if [[ -f ${TRY_MPI_DIR}/include/mpich/mpi.h ]]
306-
then
307-
USE_MPI_DIR=${TRY_MPI_DIR}
308-
USE_MPI_INCLUDE=${USE_MPI_DIR}/include/mpich
309-
elif [[ -f ${TRY_MPI_DIR}/include/mpi.h ]]
310-
then
311-
USE_MPI_DIR=${TRY_MPI_DIR}
312-
USE_MPI_INCLUDE=${USE_MPI_DIR}/include
313-
elif [[ -f ${TRY_MPI_DIR}/lib/x86_64-linux-gnu/mpich/include/mpi.h ]]
314-
then
315-
USE_MPI_DIR=${TRY_MPI_DIR}
316-
USE_MPI_INCLUDE=${USE_MPI_DIR}/lib/x86_64-linux-gnu/mpich/include
317-
fi
318-
AC_MSG_RESULT([Trying MPI directory: ${USE_MPI_DIR}])
319-
elif (( ! ENABLE_CUSTOM_MPI && ENABLE_MPI_CHECKS ))
320-
then
321-
AC_MSG_ERROR([Turbine requires --with-mpi or
322-
--enable-custom-mpi or
323-
or mpicc in PATH .])
324-
fi
306+
USE_MPI_DIR=$( cd $(dirname ${program})/.. ; /bin/pwd )
307+
AC_MSG_RESULT([Setting MPI_DIR to ${USE_MPI_DIR} ...])
325308
MPI_LABEL_DIR="${USE_MPI_DIR}"
326309
fi
327310

328-
# Set MPI_DIR with respect to a system MPICH (NEWER c. 2021)
329-
if [[ ${USE_MPI_DIR} == 0 ]] && [[ ${ENABLE_CUSTOM_MPI} == 0 ]]
311+
# At this point, USE_MPI_DIR must be set!
312+
if (( ! ENABLE_CUSTOM_MPI && ENABLE_MPI_CHECKS ))
330313
then
331-
if [[ -r /usr/lib/x86_64-linux-gnu/mpich/include/mpi.h ]]
332-
then
333-
# APT
334-
DIR=/usr/lib/x86_64-linux-gnu/mpich
335-
AC_MSG_RESULT([Using MPICH (APT) directory: ${DIR}])
336-
USE_MPI_DIR=${DIR}
337-
if [[ ${USE_LAUNCHER} == 0 ]]
338-
then
339-
USE_LAUNCHER=/usr/bin/mpiexec
340-
fi
341-
USE_MPI_INCLUDE=${USE_MPI_DIR}/include
342-
USE_MPI_LIB=/usr/lib/x86_64-linux-gnu
343-
elif [[ -r /usr/include/mpich-x86_64/mpi.h ]]
344-
then
345-
# Yum MPICH
346-
DIR=/usr/lib64/mpich
347-
AC_MSG_RESULT([Using MPICH (Yum) directory: ${DIR}])
348-
USE_MPI_DIR=${DIR}
349-
if [[ ${USE_LAUNCHER} == 0 ]]
350-
then
351-
USE_LAUNCHER=/usr/lib64/mpich/bin/mpiexec
352-
fi
353-
USE_MPI_INCLUDE=/usr/include/mpich-x86_64
354-
USE_MPI_LIB=${USE_MPI_DIR}/lib
355-
fi
356-
fi
357-
358-
# Try to set MPI_DIR with respect to a system OpenMPI
359-
if [[ ${USE_MPI_DIR} == 0 ]] && [[ ${ENABLE_CUSTOM_MPI} == 0 ]]
360-
then
361-
if [[ -r /usr/lib/x86_64-linux-gnu/openmpi/include/mpi.h ]]
362-
then
363-
AC_MSG_RESULT([Using OpenMPI (Debian) directory: ${OPENMPI}])
364-
USE_MPI_DIR=/usr/lib/x86_64-linux-gnu/openmpi
365-
if [[ $USE_LAUNCHER == 0 ]]
366-
then
367-
USE_LAUNCHER=/usr/bin/mpiexec
368-
fi
369-
USE_MPI_INCLUDE=${USE_MPI_DIR}/include
370-
USE_MPI_LIB=${USE_MPI_DIR}/lib
371-
elif [[ -r /usr/include/openmpi-x86_64/mpi.h ]]
372-
then
373-
# Yum OpenMPI
374-
DIR=/usr/lib64/openmpi
375-
AC_MSG_RESULT([Using OpenMPI (Yum) directory: ${DIR}])
376-
USE_MPI_DIR=${DIR}
377-
if [[ ${USE_LAUNCHER} == 0 ]]
378-
then
379-
USE_LAUNCHER=/usr/lib64/openmpi/bin/mpiexec
380-
fi
381-
USE_MPI_INCLUDE=/usr/include/openmpi-x86_64
382-
USE_MPI_LIB=${USE_MPI_DIR}/lib
383-
fi
314+
AC_MSG_ERROR([Turbine requires --with-mpi or
315+
--enable-custom-mpi or
316+
or mpicc in PATH .])
384317
fi
385318

386319
if [[ ${USE_LAUNCHER} == 0 ]]
@@ -397,26 +330,19 @@ if [[ ${USE_LAUNCHER} == 0 ]]
397330
then
398331
# Try to set launcher based on PATH
399332
program=$( which mpiexec 2> /dev/null )
400-
if [[ ${?} == 0 ]]
333+
if (( ${?} == 0 ))
401334
then
402335
AC_MSG_RESULT([Found ${program} in PATH.])
403336
USE_LAUNCHER=${program}
404-
else
405-
AC_MSG_WARN([mpiexec not found: no default Turbine launcher])
406337
fi
407338
fi
408339

409-
AC_MSG_RESULT([Using MPI launcher: ${USE_LAUNCHER}])
410-
411-
# Look for mpi.h at its APT location
412-
if [[ ! -f ${USE_MPI_INCLUDE}/mpi.h ]]
340+
# At this point, USE_LAUNCHER must be set!
341+
if [[ ${USE_LAUNCHER} == 0 ]] && [[ ${ENABLE_CUSTOM_MPI} == 0 ]]
413342
then
414-
if [[ -f ${USE_MPI_INCLUDE}/mpi/mpi.h ]]
415-
then
416-
# Obsolete location? 2020-01-04
417-
USE_MPI_INCLUDE=${USE_MPI_INCLUDE}/mpi
418-
fi
343+
AC_MSG_WARN([No MPI launcher (e.g., mpiexec) was found!])
419344
fi
345+
AC_MSG_RESULT([Using MPI launcher: ${USE_LAUNCHER}])
420346

421347
AC_ARG_WITH(mpi-include,
422348
AS_HELP_STRING([--with-mpi-include],
@@ -426,6 +352,27 @@ AC_ARG_WITH(mpi-include,
426352
],
427353
[])
428354

355+
MPI_INCLUDE_TRIES=(
356+
# Normal location for source build:
357+
${USE_MPI_DIR}/include
358+
# MPICH via APT:
359+
${USE_MPI_DIR}/lib/x86_64-linux-gnu/mpich/include
360+
# MPICH via Yum:
361+
${USE_MPI_DIR}/include/mpich-x86_64
362+
# OpenMPI via APT:
363+
${USE_MPI_DIR}/lib/x86_64-linux-gnu/openmpi/include
364+
# OpenMPI via Yum:
365+
${USE_MPI_DIR}/include/openmpi-x86_64
366+
)
367+
for TRY in ${MPI_INCLUDE_TRIES[@]}
368+
do
369+
if [[ ${USE_MPI_INCLUDE} != 0 ]]
370+
then
371+
break
372+
fi
373+
AC_CHECK_FILE($TRY/mpi.h, [USE_MPI_INCLUDE=$TRY])
374+
fi
375+
429376
AC_ARG_WITH(mpi-lib-dir,
430377
AS_HELP_STRING([--with-mpi-lib-dir],
431378
[directory containing MPI lib (usually libmpich)]),
@@ -459,13 +406,15 @@ AC_ARG_WITH(mpi-lib-extra,
459406
],
460407
[])
461408

409+
410+
462411
# Now check MPI settings
463412

464413
if (( ENABLE_MPI_CHECKS ))
465414
then
466415

467416
AC_CHECK_FILE(${USE_MPI_INCLUDE}/mpi.h,
468-
[],
417+
[AC_MSG_RESULT([Found ${USE_MPI_INCLUDE}/mpi.h])],
469418
[AC_MSG_ERROR([Could not find mpi.h in ${USE_MPI_INCLUDE}])])
470419

471420
MPI_LIB_FOUND=0

0 commit comments

Comments
 (0)