Skip to content

Commit

Permalink
Merge the nvidia compiler flag changes
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF committed Nov 15, 2023
1 parent de3df57 commit 2832c55
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
38 changes: 38 additions & 0 deletions config/cmake/HDFCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ if (CMAKE_C_COMPILER_ID STREQUAL "NVHPC" )
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Mbounds -g")
endif ()

# With at least NVHPC 23.5 - 23.9, compiling with -O2 or higher and -DNDEBUG
# appears to have issues that manifest in the tests as incorrect metadata
# checksums being read or memory being corrupted. Compiling without -DNDEBUG
# does not appear to have these issues, but is not ideal due to compiling in
# asserts and other library debug code. Compiling with -O1 also does not appear
# to have these issues, so set maximum optimization level to -O1 for now until
# it can be determined whether these issues are compiler-specific or issues
# in the library.
set (cmake_c_flags_minsizerel_edited "${CMAKE_C_FLAGS_MINSIZEREL}")
string (REPLACE "-O2" "" cmake_c_flags_minsizerel_edited "${cmake_c_flags_minsizerel_edited}")
string (REPLACE "-O3" "" cmake_c_flags_minsizerel_edited "${cmake_c_flags_minsizerel_edited}")
string (REPLACE "-O4" "" cmake_c_flags_minsizerel_edited "${cmake_c_flags_minsizerel_edited}")
string (REPLACE "-Ofast" "" cmake_c_flags_minsizerel_edited "${cmake_c_flags_minsizerel_edited}")
string (REPLACE "-fast" "" cmake_c_flags_minsizerel_edited "${cmake_c_flags_minsizerel_edited}")
string (STRIP "${cmake_c_flags_minsizerel_edited}" cmake_c_flags_minsizerel_edited)
string (PREPEND cmake_c_flags_minsizerel_edited "-O1 ")
set (CMAKE_C_FLAGS_MINSIZEREL "${cmake_c_flags_minsizerel_edited}")

set (cmake_c_flags_release_edited "${CMAKE_C_FLAGS_RELEASE}")
string (REPLACE "-O2" "" cmake_c_flags_release_edited "${cmake_c_flags_release_edited}")
string (REPLACE "-O3" "" cmake_c_flags_release_edited "${cmake_c_flags_release_edited}")
string (REPLACE "-O4" "" cmake_c_flags_release_edited "${cmake_c_flags_release_edited}")
string (REPLACE "-Ofast" "" cmake_c_flags_release_edited "${cmake_c_flags_release_edited}")
string (REPLACE "-fast" "" cmake_c_flags_release_edited "${cmake_c_flags_release_edited}")
string (STRIP "${cmake_c_flags_release_edited}" cmake_c_flags_release_edited)
string (PREPEND cmake_c_flags_release_edited "-O1 ")
set (CMAKE_C_FLAGS_RELEASE "${cmake_c_flags_release_edited}")

set (cmake_c_flags_relwithdebinfo_edited "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string (REPLACE "-O2" "" cmake_c_flags_relwithdebinfo_edited "${cmake_c_flags_relwithdebinfo_edited}")
string (REPLACE "-O3" "" cmake_c_flags_relwithdebinfo_edited "${cmake_c_flags_relwithdebinfo_edited}")
string (REPLACE "-O4" "" cmake_c_flags_relwithdebinfo_edited "${cmake_c_flags_relwithdebinfo_edited}")
string (REPLACE "-Ofast" "" cmake_c_flags_relwithdebinfo_edited "${cmake_c_flags_relwithdebinfo_edited}")
string (REPLACE "-fast" "" cmake_c_flags_relwithdebinfo_edited "${cmake_c_flags_relwithdebinfo_edited}")
string (STRIP "${cmake_c_flags_relwithdebinfo_edited}" cmake_c_flags_relwithdebinfo_edited)
string (PREPEND cmake_c_flags_relwithdebinfo_edited "-O1 ")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${cmake_c_flags_relwithdebinfo_edited}")
endif ()

if (CMAKE_COMPILER_IS_GNUCC)
Expand Down
30 changes: 24 additions & 6 deletions config/linux-gnulibc1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ fi
# Figure out Clang C compiler flags
. $srcdir/config/clang-flags

# Figure out NVHPC C compiler flags
. $srcdir/config/nvidia-flags

# Use default Fortran 90 compiler according to what C compiler is used.
if test "X-" = "X-$FC"; then
case $CC_BASENAME in
Expand All @@ -58,6 +61,10 @@ if test "X-" = "X-$FC"; then
FC=pgf90
FC_BASENAME=pgf90
;;
nvc*)
FC=nvfortran
FC_BASENAME=nvfortran
;;
icx*)
FC=ifx
FC_BASENAME=ifx
Expand All @@ -79,7 +86,7 @@ if test "X-" = "X-$FC"; then
else
case $FC in
# The PGI and Intel compilers are automatically detected below
ifc*|ifort*|pgf90*)
ifc*|ifort*|pgf90*|nvfortran*)
;;

*f95*)
Expand Down Expand Up @@ -135,6 +142,9 @@ fi
# Figure out Clang FC compiler flags
. $srcdir/config/clang-fflags

# Figure out NVHPC FC compiler flags
. $srcdir/config/nvidia-fflags

case $FC_BASENAME in
#
# Absoft compiler
Expand Down Expand Up @@ -173,10 +183,7 @@ case $FC_BASENAME in
nagfor)

F9XSUFFIXFLAG=""
# NOTE: The default is -ieee=stop, which will cause problems
# when the H5T module performs floating-point type
# introspection
AM_FCFLAGS="$AM_FCFLAGS -ieee=full"
AM_FCFLAGS="$AM_FCFLAGS"
FSEARCH_DIRS=""

# Production
Expand Down Expand Up @@ -226,6 +233,9 @@ fi
# Figure out Clang CXX compiler flags
. $srcdir/config/clang-cxxflags

# Figure out NVHPC CXX compiler flags
. $srcdir/config/nvidia-cxxflags

# compiler version strings

# check if the compiler_version_info is already set
Expand All @@ -248,7 +258,11 @@ case $CC in
sed 's/\"/\\\"/g' |\
sed 's/^\([a-z]* \)/ built with \1/1'`
cc_version_info=`echo $cc_version_info`
;;
;;

*nvc*)
cc_version_info=`$CC $CFLAGS $H5_CFLAGS -V 2>&1 | grep 'nvc'`
;;

*icx*)
cc_version_info=`$CC $CCFLAGS $H5_CCFLAGS -V 2>&1 | grep 'Version' |\
Expand Down Expand Up @@ -322,6 +336,10 @@ case $FC in
fc_version_info=`$FC $FCFLAGS $H5_FCFLAGS -V 2>&1 | grep 'pgf90'`
;;

*nvfortran*)
fc_version_info=`$FC $FCFLAGS $H5_FCFLAGS -V 2>&1 | grep 'nvfortran'`
;;

*nagfor*|*nagftn*)
RM='rm -f'
tmpfile=/tmp/cmpver.$$
Expand Down
6 changes: 4 additions & 2 deletions config/nvidia-flags
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ if test "X-nvc" = "X-$cc_vendor" -o "X-nvcc" = "X-$cc_vendor"; then
##############

# NDEBUG is handled explicitly by the configure script
PROD_CFLAGS="-fast"
#PROD_CFLAGS="-fast"
PROD_CFLAGS="" # -fast implies -O2 and -O2+ currently has test failures.

#########
# Debug #
Expand Down Expand Up @@ -106,7 +107,8 @@ if test "X-nvc" = "X-$cc_vendor" -o "X-nvcc" = "X-$cc_vendor"; then
################

HIGH_OPT_CFLAGS="-O1" # -O2+ currently has test failures.
DEBUG_OPT_CFLAGS="-gopt -O2"
#DEBUG_OPT_CFLAGS="-gopt -O2"
DEBUG_OPT_CFLAGS="-gopt -O1" # -O2+ currently has test failures.
NO_OPT_CFLAGS="-O0"

#################
Expand Down

0 comments on commit 2832c55

Please sign in to comment.