Commit d4e31093 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: improved encapsulation of MPI (re)builds

- dependency handling relocated from cmakeFunctions to wmakeFunctions
  and reused for mpi-versioned builds. This allows more checks for
  configuration parameters and removes hard-code build path
  information.

CONFIG: remove spurious mplibHPMPI entries

CONFIG: remove ADIOS1 rules (antiquated)
parent f9956170
......@@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.csh/mpi
......@@ -80,7 +79,7 @@ case OPENMPI:
breaksw
case USERMPI:
# Use an arbitrary, user-specified mpi implementation
# Arbitrary, user-specified mpi implementation
setenv FOAM_MPI mpi-user
_foamEtc -config mpi-user # <- Adjustments (optional)
breaksw
......
......@@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/mpi
......@@ -91,7 +90,7 @@ OPENMPI)
;;
USERMPI)
# Use an arbitrary, user-specified mpi implementation
# Arbitrary, user-specified mpi implementation
export FOAM_MPI=mpi-user
_foamEtc -config mpi-user # <- Adjustments (optional)
;;
......
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
# Clean an mpi-versioned library
wcleanMpiLib()
{
case "$WM_MPLIB" in (*MPI*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
for libName
do
wclean $libName
done
)
;;
esac
}
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
wclean dummy
wcleanMpiLib mpi
wcleanLibMpi mpi
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
# Define how to create an mpi-versioned library of $targetType
# compile into qualified directory
# use sentinel file to handle version changes
wmakeMpiLib()
{
local objectsDir
for libName
do
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
objectsDir="$WM_PROJECT_DIR/build/$WM_OPTIONS/src/Pstream/$libName"
whichmpi="$objectsDir/using:$FOAM_MPI"
[ -e "$whichmpi" ] || wclean $libName
echo "wmake $targetType $libName (mpi=$WM_MPLIB)"
wmake $targetType $libName
mkdir -p "$objectsDir"
touch "$whichmpi"
)
done
}
echo "wmake $targetType dummy (mpi=$WM_MPLIB)"
wmake $targetType dummy
case "$WM_MPLIB" in
(*MPI*)
wmakeMpiLib mpi
;;
esac
wmakeLibMpi mpi
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
# Clean an mpi-versioned library
wcleanMpiLib()
{
case "$WM_MPLIB" in (*MPI*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
for libName
do
wclean $libName
done
)
;;
esac
}
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
wclean metisDecomp
wclean kahipDecomp
wclean scotchDecomp
wclean decompositionMethods
wclean decompose
wcleanMpiLib ptscotchDecomp
wcleanLibMpi ptscotchDecomp
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_kahip
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_metis
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_scotch
......@@ -10,34 +11,9 @@ cd "${0%/*}" || exit # Run from this directory
: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH} # Extra safety?
export FOAM_EXT_LIBBIN
# Define how to create an mpi-versioned library of $targetType
# compile into qualified directory
# use sentinel file(s) to handle version changes
wmakeMpiLib()
{
local decompName="$1"
local objectsDir
shift
for libName
do
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
objectsDir="$WM_PROJECT_DIR/build/$WM_OPTIONS/src/parallel/decompose/$libName"
whichmpi="$objectsDir/using:$FOAM_MPI"
whichdecomp="$objectsDir/using:$decompName"
[ -e "$whichmpi" ] && [ -e "$whichdecomp" ] || wclean $libName
echo "wmake $targetType $libName (mpi=$WM_MPLIB)"
wmake $targetType $libName
mkdir -p "$objectsDir"
touch "$whichdecomp" "$whichmpi"
)
done
}
wmake $targetType decompositionMethods
wmake $targetType decompose
if have_kahip
then
wmake $targetType kahipDecomp
......@@ -54,7 +30,7 @@ then
if have_ptscotch
then
wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp
wmakeLibMpi ptscotchDecomp "scotch=$SCOTCH_VERSION"
fi
fi
......
#-------------------------------*- makefile -*---------------------------------
# ADIOS includes/libraries
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
# Obtain compile/link flags via adios_config
ADIOS_INC := $(shell $(ADIOS1_ARCH_PATH)/bin/adios_config -c)
ADIOS_LIBS := $(shell $(ADIOS1_ARCH_PATH)/bin/adios_config -l)
#------------------------------------------------------------------------------
PFLAGS =
PINC = -isystem $(MPI_ARCH_PATH)/include -D_MPICC_H
PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_ia32 -lmpi
PFLAGS =
PINC = -isystem $(MPI_ARCH_PATH)/include -D_MPICC_H
PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_amd64 -lmpi
PFLAGS =
PINC = -isystem $(MPI_ARCH_PATH)/include -D_MPICC_H
PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_amd64 -lmpi
......@@ -37,76 +37,6 @@ export CXXFLAGS="$(wmake -show-cxxflags)"
#------------------------------------------------------------------------------
#
# Save build/configure parameter information (dependency) into sentinel file
#
# 1 - sentinelFile
# 2... build/configure parameters
#
storeDependency()
{
local sentinel="$1"
local depend
shift
if [ -n "$sentinel" ]
then
mkdir -p "$(dirname "$sentinel")"
echo '# Build/configure parameters' >| "$sentinel"
for depend
do
echo "-- $depend"
done >> "$sentinel"
fi
return 0
}
#
# Check sentinel file(s) to handle changed build/configure parameters
# such as paraview / vtk version changes
#
# 1 - sourceDir
# 2... build/configure parameters
#
sameDependency()
{
local sourceDir="$1"
shift
local depend objectsDir
local compare=0
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
local sentinel="$objectsDir/ThirdParty"
if [ -f "$sentinel" ]
then
# Create an .update version
storeDependency "${sentinel}.update" $@
cmp "${sentinel}" "${sentinel}.update" >/dev/null 2>&1
compare=$?
if [ "$compare" -ne 0 ]
then
echo "build/configure parameters changed between builds" 1>&2
fi
else
# No sentinel file: First time, or failed compilation?
if [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
compare=1
fi
fi
echo "$sentinel"
return "$compare"
}
# Resolve the location of cmake (if needed) and call with output
# suppressed according to WM_QUIET
......
......@@ -15,7 +15,10 @@
# wmakeFunctions
#
# Description
# Functions to check wmake environment and find .dep and .o files
# Support functions for wmake infrastructure.
# For example, check environment, find .dep and .o files, various
# wrappers when making libraries.
#
#------------------------------------------------------------------------------
# Ensure these variables are always defined
......@@ -30,10 +33,9 @@ then
fi
#------------------------------------------------------------------------------
# Check environment variables
#------------------------------------------------------------------------------
# Check environment variables
checkEnv()
{
local check failed
......@@ -53,11 +55,8 @@ checkEnv()
}
#------------------------------------------------------------------------------
# Search up directories tree for the Make sub-directory
#------------------------------------------------------------------------------
# Return the absolute path for a directory or a file's parent directory
# Return the absolute (physical) path for a directory or
# for a file's parent directory
# expandPath dirName
# expandPath fileName
#
......@@ -76,6 +75,7 @@ expandPath()
fi
}
# Find the target directory, which contains a Make/ directory
# search upwards in its parent directories, but stopping
# when it hits the project root, home, or the file-system root
......@@ -199,6 +199,139 @@ removeObjectDir()
}
# Save build/configure parameter information (dependency) into sentinel file
#
# 1 - sentinelFile
# 2... build/configure parameters
#
storeDependency()
{
local sentinel="$1"
local depend
shift
if [ -n "$sentinel" ]
then
mkdir -p "$(dirname "$sentinel")"
echo '# Build/configure parameters' >| "$sentinel"
for depend
do
echo "-- $depend"
done >> "$sentinel"
fi
return 0
}
# Check sentinel file(s) to handle changed build/configure parameters
# such as paraview / vtk version changes
#
# 1 - sourceDir
# 2... build/configure parameters
#
# The additional test for "CMakeCache.txt" helps for cmake projects and
# has no adverse affect for others
#
sameDependency()
{
local sourceDir="$1"
shift
local objectsDir
local compare=0
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
local sentinel="$objectsDir/ConfigParameters"
if [ -f "$sentinel" ]
then
# Create an .update version for comparison
storeDependency "${sentinel}.update" $@
cmp "${sentinel}" "${sentinel}.update" >/dev/null 2>&1
compare=$?
if [ "$compare" -ne 0 ]
then
echo "build/configure parameters changed between builds" 1>&2
## cat "${sentinel}.update" 1>&2
fi
else
# No sentinel file: First time, or failed compilation?
if [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
compare=1
fi
fi
echo "$sentinel"
return "$compare"
}
# Build a mpi-versioned library (targetType)
# - use sentinel file(s) to handle paraview version changes
# compile into qualified directory
# use sentinel file(s) to handle version changes
# 1 - libName
# 2... build/configure information
#
# Global variables used:
# - WM_OPTIONS, WM_MPLIB, FOAM_MPI
#
# Requires that WM_MPLIB contain an "MPI" string
wmakeLibMpi()
{
local libName="$1"
shift
case "$WM_MPLIB" in (*MPI* | *mpi*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
# Where generated files are stored
objectsDir="$(findObjectDir "$libName")" || exit 1 # Fatal
# Something changed
sentinel=$(sameDependency "$libName" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@) || \
wclean "$libName"
echo "wmake $targetType $libName (mpi=$WM_MPLIB)"
wmake $targetType "$libName" && \
storeDependency "$sentinel" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@
)
;;
esac
}
# Clean an mpi-versioned library
#
# Global variables used:
# - WM_OPTIONS, WM_MPLIB
#
# Requires that WM_MPLIB contain an "MPI" string
wcleanLibMpi()
{
case "$WM_MPLIB" in (*MPI* | *mpi*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
for libName
do
wclean "$libName"
done
)
;;
esac
}
#------------------------------------------------------------------------------
# depToSource depFile
#
# Output:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment