From 4e3718e96fb3808dbd2b6c64225bfe0e83e1fae6 Mon Sep 17 00:00:00 2001 From: Treece Burgess Date: Fri, 10 Jan 2025 22:21:59 +0000 Subject: [PATCH] Restructure configure and configure.in to avoid errors: cuda.h no such file and integer expression expected on Power 9 and Power 10. --- src/configure | 19 +++++++++++++++---- src/configure.in | 21 ++++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/configure b/src/configure index 9159ca8cc..469c5dda0 100755 --- a/src/configure +++ b/src/configure @@ -4818,11 +4818,22 @@ else CPU="x86" elif test "$family" = "ppc64" || test "$family" = "ppc64le"; then - cuda_version=`grep -r '#define CUDA_VERSION [0-9]' $PAPI_CUDA_ROOT/include/cuda.h | awk '{print $3}'` - if (test "$family" = "ppc64le" && test "$CC_COMMON_NAME" = "gcc" && test "$major" -ge 8 \ - && test "$major" -lt 9 && test "$cuda_version" -ge 10000 && test "$cuda_version" -lt 11000); then - NVPPC64LEFLAGS="-Xcompiler -mno-float128" + + if (test "$family" = "ppc64le" && test "$CC_COMMON_NAME" = "gcc"); then + # set cuda_version to be 0, such that we avoid "integer expression expected" + cuda_version=0 + if (test ! -z "$PAPI_CUDA_ROOT"); then + cuda_version=`grep -r '#define CUDA_VERSION [0-9]' $PAPI_CUDA_ROOT/include/cuda.h | awk '{print $3}'` + fi + # get gcc major number + gcc_major=`gcc -v 2>&1 | tail -n 1 | awk '{printf $3}' | sed 's/\([^.][^.]*\).*/\1/'` + # set variable if the gcc and cuda versions match conditions + if (test "$cuda_version" -ge 10000 && test "$cuda_version" -lt 11000 \ + && test "$gcc_major" -ge 8 && test "$gcc_major" -lt 9); then + NVPPC64LEFLAGS="-Xcompiler -mno-float128" + fi fi + CPU_info="`cat /proc/cpuinfo | grep cpu | cut -d: -f2 | cut -d' ' -f2 | sed '2,$d' | tr -d ","`" case "$CPU_info" in PPC970*) CPU="PPC970";; diff --git a/src/configure.in b/src/configure.in index 43197dd4d..e4e9768a5 100644 --- a/src/configure.in +++ b/src/configure.in @@ -491,11 +491,22 @@ AC_ARG_WITH(CPU, CPU="x86" elif test "$family" = "ppc64" || test "$family" = "ppc64le"; then - cuda_version=`grep -r '#define CUDA_VERSION [0-9]' $PAPI_CUDA_ROOT/include/cuda.h | awk '{print $3}'` - if (test "$family" = "ppc64le" && test "$CC_COMMON_NAME" = "gcc" && test "$major" -ge 8 \ - && test "$major" -lt 9 && test "$cuda_version" -ge 10000 && test "$cuda_version" -lt 11000); then - NVPPC64LEFLAGS="-Xcompiler -mno-float128" - fi + + if (test "$family" = "ppc64le" && test "$CC_COMMON_NAME" = "gcc"); then + # set cuda_version to be 0, such that we avoid "integer expression expected" + cuda_version=0 + if (test ! -z "$PAPI_CUDA_ROOT"); then + cuda_version=`grep -r '#define CUDA_VERSION [0-9]' $PAPI_CUDA_ROOT/include/cuda.h | awk '{print $3}'` + fi + # get gcc major number + gcc_major=`gcc -v 2>&1 | tail -n 1 | awk '{printf $3}' | sed 's/\([[^.]][[^.]]*\).*/\1/'` + # set variable if the gcc and cuda versions match conditions + if (test "$cuda_version" -ge 10000 && test "$cuda_version" -lt 11000 \ + && test "$gcc_major" -ge 8 && test "$gcc_major" -lt 9); then + NVPPC64LEFLAGS="-Xcompiler -mno-float128" + fi + fi + CPU_info="`cat /proc/cpuinfo | grep cpu | cut -d: -f2 | cut -d' ' -f2 | sed '2,$d' | tr -d ","`" case "$CPU_info" in PPC970*) CPU="PPC970";;