COMP: stricter handling of openmp vs no-openmp
- give precedence to ~openmp (-no-openmp) over +openmp (-openmp) in the general rules and in the Makefile. This makes it robuster when specifying +openmp in general, but ~openmp for specific build components. - disable openmp for OSspecific and Pstream components. Neither should contain any openmp code anyhow. Additionally, since OSspecific is generally built as a static object, it can become problematic (eg, with AMD ROCm) if the compiler generates information that openmp is required but then uses static linkage.
This commit is contained in:
parent
cd493897d3
commit
d086cc5a0e
@ -19,6 +19,7 @@ fi
|
|||||||
unset COMP_FLAGS LINK_FLAGS
|
unset COMP_FLAGS LINK_FLAGS
|
||||||
|
|
||||||
# Make object (non-shared by default)
|
# Make object (non-shared by default)
|
||||||
wmake $targetType
|
# Never want/need openmp, especially for static objects
|
||||||
|
wmake -no-openmp $targetType
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -14,6 +14,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Make object (non-shared by default)
|
# Make object (non-shared by default)
|
||||||
wmake $targetType
|
# Never want/need openmp, especially for static objects
|
||||||
|
wmake -no-openmp $targetType
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -3,9 +3,10 @@ cd "${0%/*}" || exit # Run from this directory
|
|||||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
|
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
# Never need/want openmp for MPI interfaces, or for static linkage
|
||||||
|
|
||||||
echo "wmake $targetType dummy (mpi=$WM_MPLIB)"
|
echo "wmake -no-openmp $targetType${targetType:+ }dummy (mpi=$WM_MPLIB)"
|
||||||
wmake $targetType dummy
|
wmake -no-openmp $targetType dummy
|
||||||
|
|
||||||
./Allwmake-mpi $targetType $*
|
./Allwmake-mpi $targetType $*
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ cd "${0%/*}" || exit # Run from this directory
|
|||||||
# Environment
|
# Environment
|
||||||
# - FOAM_MPI_LIBBIN (optional: defaults to FOAM_LIBBIN/FOAM_MPI)
|
# - FOAM_MPI_LIBBIN (optional: defaults to FOAM_LIBBIN/FOAM_MPI)
|
||||||
|
|
||||||
wmakeLibMpi mpi
|
# Never need/want openmp for MPI interfaces
|
||||||
|
wmakeLibMpi -no-openmp mpi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -15,7 +15,8 @@ if have_scotch
|
|||||||
then
|
then
|
||||||
if have_ptscotch
|
if have_ptscotch
|
||||||
then
|
then
|
||||||
wmakeLibMpi ptscotchDecomp "scotch=$SCOTCH_VERSION"
|
# Never need/want openmp for MPI interfaces
|
||||||
|
wmakeLibMpi -no-openmp ptscotchDecomp "scotch=$SCOTCH_VERSION"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2019-2022 OpenCFD Ltd.
|
# Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
# Embedded Control Parameters
|
# Embedded Control Parameters
|
||||||
#
|
#
|
||||||
# WM_COMPILE_CONTROL (+openmp)
|
# WM_COMPILE_CONTROL (+openmp | ~openmp)
|
||||||
# WM_COMPILE_CONTROL (~openfoam)
|
# WM_COMPILE_CONTROL (~openfoam)
|
||||||
# WM_OSTYPE (windows)
|
# WM_OSTYPE (windows)
|
||||||
#
|
#
|
||||||
@ -62,9 +62,13 @@ SYS_INC =
|
|||||||
SYS_LIBS =
|
SYS_LIBS =
|
||||||
|
|
||||||
# Add linkage for openmp into the system libraries
|
# Add linkage for openmp into the system libraries
|
||||||
|
# - if enabled (+openmp) and not disabled (~openmp).
|
||||||
|
# - disable has higher precedence
|
||||||
|
ifeq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
|
||||||
ifneq (,$(findstring +openmp,$(WM_COMPILE_CONTROL)))
|
ifneq (,$(findstring +openmp,$(WM_COMPILE_CONTROL)))
|
||||||
SYS_LIBS = $(LINK_OPENMP)
|
SYS_LIBS = $(LINK_OPENMP)
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# These are set by Make/options
|
# These are set by Make/options
|
||||||
EXE_INC =
|
EXE_INC =
|
||||||
|
@ -52,10 +52,14 @@ sinclude $(RULES)/general
|
|||||||
sinclude $(RULES)/c++
|
sinclude $(RULES)/c++
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Add compile flags for openmp
|
# Compile flags for openmp
|
||||||
|
# - if enabled (+openmp) and not disabled (~openmp).
|
||||||
|
# - disable has higher precedence
|
||||||
|
ifeq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
|
||||||
ifneq (,$(findstring +openmp,$(WM_COMPILE_CONTROL)))
|
ifneq (,$(findstring +openmp,$(WM_COMPILE_CONTROL)))
|
||||||
c++FLAGS += $(COMP_OPENMP)
|
c++FLAGS += $(COMP_OPENMP)
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
include $(GENERAL_RULES)/transform
|
include $(GENERAL_RULES)/transform
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#
|
#
|
||||||
# Parsed options (wmake)
|
# Parsed options (wmake)
|
||||||
# -debug | -debug-O[g0123]
|
# -debug | -debug-O[g0123]
|
||||||
|
# -openmp | -no-openmp
|
||||||
# -strict
|
# -strict
|
||||||
# -q | -queue
|
# -q | -queue
|
||||||
# -build-root=...
|
# -build-root=...
|
||||||
@ -88,7 +89,7 @@ USAGE
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
unset wmakeOpt_frontend wmakeOpt_nonRecursive
|
unset wmakeOpt_frontend wmakeOpt_nonRecursive
|
||||||
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
|
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict wmakeOpt_queue
|
||||||
|
|
||||||
for arg in "$@"
|
for arg in "$@"
|
||||||
do
|
do
|
||||||
@ -184,6 +185,11 @@ do
|
|||||||
continue # Argument handled, remove it
|
continue # Argument handled, remove it
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
-openmp | -no-openmp)
|
||||||
|
wmakeOpt_openmp="$arg"
|
||||||
|
continue # Argument handled, remove it
|
||||||
|
;;
|
||||||
|
|
||||||
-q | -queue)
|
-q | -queue)
|
||||||
wmakeOpt_queue="-queue"
|
wmakeOpt_queue="-queue"
|
||||||
continue # Argument handled, remove it
|
continue # Argument handled, remove it
|
||||||
@ -240,7 +246,7 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
unset wmakeOpt_frontend wmakeOpt_nonRecursive
|
unset wmakeOpt_frontend wmakeOpt_nonRecursive
|
||||||
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
|
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict wmakeOpt_queue
|
||||||
unset -f usage
|
unset -f usage
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2015-2016 OpenFOAM Foundation
|
# Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2018-2021 OpenCFD Ltd.
|
# Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -348,19 +348,43 @@ sameDependency()
|
|||||||
|
|
||||||
|
|
||||||
# Build a mpi-versioned library (targetType)
|
# Build a mpi-versioned library (targetType)
|
||||||
# - use sentinel file(s) to handle paraview version changes
|
# compile into MPI-qualified directory
|
||||||
# compile into qualified directory
|
|
||||||
# use sentinel file(s) to handle version changes
|
# use sentinel file(s) to handle version changes
|
||||||
# 1 - libName
|
# 1 - libName
|
||||||
# 2... build/configure information
|
# 2... build/configure information
|
||||||
#
|
#
|
||||||
# Global variables used:
|
# Global variables used:
|
||||||
# - WM_OPTIONS, WM_MPLIB, FOAM_MPI
|
# - WM_OPTIONS, WM_MPLIB, FOAM_MPI
|
||||||
|
# - targetType
|
||||||
#
|
#
|
||||||
# Requires that WM_MPLIB contain an "MPI" string
|
# Requires that WM_MPLIB contain an "MPI" string
|
||||||
|
#
|
||||||
|
# Has very simple option handling (bool options only!) that allow
|
||||||
|
# things like "wmakeLibMpi -debug -no-openmp" etc.
|
||||||
|
#
|
||||||
wmakeLibMpi()
|
wmakeLibMpi()
|
||||||
{
|
{
|
||||||
local libName="$1"
|
local libName
|
||||||
|
local wmakeCmd="wmake"
|
||||||
|
|
||||||
|
# Very simple option handling (bool options only!)
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
(- | --) # Stop option parsing
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
(-*) # Any bool option
|
||||||
|
wmakeCmd="$wmakeCmd $1"
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
break # Done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
libName="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
case "$WM_MPLIB" in (*MPI* | *mpi*)
|
case "$WM_MPLIB" in (*MPI* | *mpi*)
|
||||||
@ -374,8 +398,8 @@ wmakeLibMpi()
|
|||||||
sentinel=$(sameDependency "$libName" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@) || \
|
sentinel=$(sameDependency "$libName" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@) || \
|
||||||
wclean "$libName"
|
wclean "$libName"
|
||||||
|
|
||||||
echo "wmake $targetType $libName (mpi=$WM_MPLIB:$FOAM_MPI)"
|
echo "$wmakeCmd $targetType${targetType:+ }(mpi=$WM_MPLIB:$FOAM_MPI)"
|
||||||
wmake $targetType "$libName" && \
|
$wmakeCmd $targetType "$libName" && \
|
||||||
storeDependency "$sentinel" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@
|
storeDependency "$sentinel" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user