Skip to content

Commit 3f05f40

Browse files
authored
Merge pull request #3409 from roystgnr/nvidia_fixes
Error fixes for Nvidia compilers
2 parents bef5ea5 + eb82b2d commit 3f05f40

File tree

8 files changed

+303
-52
lines changed

8 files changed

+303
-52
lines changed

configure

Lines changed: 240 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,9 @@ PTHREAD_CFLAGS
809809
PTHREAD_LIBS
810810
PTHREAD_CC
811811
ax_pthread_config
812+
OPENMP_CXXFLAGS
812813
OPENMP_FFLAGS
813814
OPENMP_CFLAGS
814-
OPENMP_CXXFLAGS
815815
TPETRA_INCLUDES
816816
TPETRA_LIBS
817817
ML_INCLUDES
@@ -7243,6 +7243,20 @@ $as_echo "<<< C++ compiler is Cray C++ >>>" >&6; }
72437243

72447244
fi
72457245

7246+
fi
7247+
7248+
if test "x$compiler_brand_detected" = "xno"; then :
7249+
7250+
is_nvcc="`($CXX -V 2>&1) | grep 'NVIDIA'`"
7251+
if test "x$is_nvcc" != "x"; then :
7252+
7253+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is NVIDIA C++ >>>" >&5
7254+
$as_echo "<<< C++ compiler is NVIDIA C++ >>>" >&6; }
7255+
ACSM_GXX_VERSION=nvidia
7256+
compiler_brand_detected=yes
7257+
7258+
fi
7259+
72467260
fi
72477261

72487262
if test "x$compiler_brand_detected" = "xno"; then :
@@ -25167,6 +25181,26 @@ else
2516725181
$as_echo "Unknown Intel compiler" >&6; } ;;
2516825182
esac
2516925183
;; #(
25184+
nvidia) :
25185+
25186+
25187+
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG -O0 --display_error_number -g -pedantic -Wno-long-long -Wunused -Wuninitialized --diag_suppress=11,111,177,445,1676"
25188+
ACSM_CXXFLAGS_DEVEL="$ACSM_CXXFLAGS_DEVEL -O2 --display_error_number -g -pedantic -Wno-long-long -Wunused -Wuninitialized --diag_suppress=11,111,177,445,1676"
25189+
ACSM_CXXFLAGS_OPT="$ACSM_CXXFLAGS_OPT -O2 --display_error_number --diag_suppress=11,111,177,445,1676"
25190+
25191+
ACSM_NODEPRECATEDFLAG="-Wno-deprecated-declarations"
25192+
25193+
ACSM_CFLAGS_DBG="$ACSM_CFLAGS_DBG -O0 -g"
25194+
ACSM_CFLAGS_DEVEL="$ACSM_CFLAGS_DEVEL -O2 -g"
25195+
ACSM_CFLAGS_OPT="$ACSM_CFLAGS_OPT -O2"
25196+
25197+
if test "$enableexceptions" = no; then :
25198+
25199+
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG --no_exceptions"
25200+
ACSM_CXXFLAGS_OPT="$ACSM_CXXFLAGS_OPT --no_exceptions"
25201+
25202+
fi
25203+
;; #(
2517025204
portland_group) :
2517125205

2517225206
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG -g --no_using_std"
@@ -50856,6 +50890,13 @@ fi
5085650890

5085750891
if test "x$enableopenmp" = "xyes"; then :
5085850892

50893+
ac_ext=cpp
50894+
ac_cpp='$CXXCPP $CPPFLAGS'
50895+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
50896+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
50897+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
50898+
50899+
5085950900

5086050901
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenMP flag of C++ compiler" >&5
5086150902
$as_echo_n "checking for OpenMP flag of C++ compiler... " >&6; }
@@ -50926,30 +50967,210 @@ $as_echo "#define HAVE_OPENMP 1" >>confdefs.h
5092650967

5092750968
fi
5092850969

50929-
if test "x$OPENMP_CXXFLAGS" != "x"; then :
50970+
ac_ext=cpp
50971+
ac_cpp='$CXXCPP $CPPFLAGS'
50972+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
50973+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
50974+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
50975+
50976+
ac_ext=c
50977+
ac_cpp='$CPP $CPPFLAGS'
50978+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
50979+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
50980+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
50981+
5093050982

50931-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with OpenMP support >>>" >&5
50932-
$as_echo "<<< Configuring library with OpenMP support >>>" >&6; }
50933-
OPENMP_CFLAGS=$OPENMP_CXXFLAGS
50934-
OPENMP_FFLAGS=$OPENMP_CXXFLAGS
50935-
CXXFLAGS_OPT="$CXXFLAGS_OPT $OPENMP_CXXFLAGS"
50936-
CXXFLAGS_DBG="$CXXFLAGS_DBG $OPENMP_CXXFLAGS"
50937-
CXXFLAGS_DEVEL="$CXXFLAGS_DEVEL $OPENMP_CXXFLAGS"
50938-
CXXFLAGS_PROF="$CXXFLAGS_PROF $OPENMP_CXXFLAGS"
50939-
CXXFLAGS_OPROF="$CXXFLAGS_OPROF $OPENMP_CXXFLAGS"
50940-
CFLAGS_OPT="$CFLAGS_OPT $OPENMP_CFLAGS"
50941-
CFLAGS_DBG="$CFLAGS_DBG $OPENMP_CFLAGS"
50942-
CFLAGS_DEVEL="$CFLAGS_DEVEL $OPENMP_CFLAGS"
50943-
CFLAGS_PROF="$CFLAGS_PROF $OPENMP_CFLAGS"
50944-
CFLAGS_OPROF="$CFLAGS_OPROF $OPENMP_CFLAGS"
50945-
FFLAGS="$FFLAGS $OPENMP_FFLAGS"
5094650983

50984+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenMP flag of C compiler" >&5
50985+
$as_echo_n "checking for OpenMP flag of C compiler... " >&6; }
50986+
if ${ax_cv_c_openmp+:} false; then :
50987+
$as_echo_n "(cached) " >&6
50988+
else
50989+
saveCFLAGS=$CFLAGS
50990+
ax_cv_c_openmp=unknown
50991+
# Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI & PGI),
50992+
# -xopenmp (Sun), -omp (Tru64), -qsmp=omp (AIX), none
50993+
ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none"
50994+
50995+
if test "x$OPENMP_CFLAGS" != x; then
50996+
ax_openmp_flags="$OPENMP_CFLAGS $ax_openmp_flags"
50997+
fi
50998+
50999+
for ax_openmp_flag in $ax_openmp_flags; do
51000+
case $ax_openmp_flag in
51001+
none) CFLAGS=$saveC ;;
51002+
*) CFLAGS="$saveCFLAGS $ax_openmp_flag" ;;
51003+
esac
51004+
51005+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
51006+
/* end confdefs.h. */
51007+
51008+
#include <omp.h>
51009+
51010+
int
51011+
main ()
51012+
{
51013+
51014+
const int N = 100000;
51015+
int i, arr[N];
51016+
51017+
omp_set_num_threads(2);
51018+
51019+
#pragma omp parallel for
51020+
for (i = 0; i < N; i++)
51021+
{
51022+
arr[i] = i;
51023+
}
51024+
51025+
;
51026+
return 0;
51027+
}
51028+
_ACEOF
51029+
if ac_fn_c_try_link "$LINENO"; then :
51030+
ax_cv_c_openmp=$ax_openmp_flag; break
51031+
fi
51032+
rm -f core conftest.err conftest.$ac_objext \
51033+
conftest$ac_exeext conftest.$ac_ext
51034+
done
51035+
51036+
CFLAGS=$saveCFLAGS
51037+
51038+
fi
51039+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_openmp" >&5
51040+
$as_echo "$ax_cv_c_openmp" >&6; }
5094751041

51042+
if test "x$ax_cv_c_openmp" = "xunknown"; then
51043+
:
51044+
else
51045+
if test "x$ax_cv_c_openmp" != "xnone"; then
51046+
OPENMP_CFLAGS=$ax_cv_c_openmp
51047+
fi
51048+
51049+
$as_echo "#define HAVE_OPENMP 1" >>confdefs.h
51050+
51051+
fi
51052+
51053+
ac_ext=cpp
51054+
ac_cpp='$CXXCPP $CPPFLAGS'
51055+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
51056+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
51057+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
51058+
51059+
if test "x$enablefortran" = "xyes"; then :
51060+
51061+
ac_ext=f
51062+
ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
51063+
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
51064+
ac_compiler_gnu=$ac_cv_f77_compiler_gnu
51065+
51066+
51067+
51068+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenMP flag of Fortran 77 compiler" >&5
51069+
$as_echo_n "checking for OpenMP flag of Fortran 77 compiler... " >&6; }
51070+
if ${ax_cv_f77_openmp+:} false; then :
51071+
$as_echo_n "(cached) " >&6
51072+
else
51073+
saveFFLAGS=$FFLAGS
51074+
ax_cv_f77_openmp=unknown
51075+
# Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI & PGI),
51076+
# -xopenmp (Sun), -omp (Tru64), -qsmp=omp (AIX), none
51077+
ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none"
51078+
51079+
if test "x$OPENMP_FFLAGS" != x; then
51080+
ax_openmp_flags="$OPENMP_FFLAGS $ax_openmp_flags"
51081+
fi
51082+
51083+
for ax_openmp_flag in $ax_openmp_flags; do
51084+
case $ax_openmp_flag in
51085+
none) FFLAGS=$saveF ;;
51086+
*) FFLAGS="$saveFFLAGS $ax_openmp_flag" ;;
51087+
esac
51088+
51089+
cat > conftest.$ac_ext <<_ACEOF
51090+
program main
51091+
51092+
const int N = 100000;
51093+
int i, arr[N];
51094+
51095+
omp_set_num_threads(2);
51096+
51097+
#pragma omp parallel for
51098+
for (i = 0; i < N; i++)
51099+
{
51100+
arr[i] = i;
51101+
}
51102+
51103+
end
51104+
_ACEOF
51105+
if ac_fn_f77_try_link "$LINENO"; then :
51106+
ax_cv_f77_openmp=$ax_openmp_flag; break
51107+
fi
51108+
rm -f core conftest.err conftest.$ac_objext \
51109+
conftest$ac_exeext conftest.$ac_ext
51110+
done
51111+
51112+
FFLAGS=$saveFFLAGS
51113+
51114+
fi
51115+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_f77_openmp" >&5
51116+
$as_echo "$ax_cv_f77_openmp" >&6; }
51117+
51118+
if test "x$ax_cv_f77_openmp" = "xunknown"; then
51119+
:
51120+
else
51121+
if test "x$ax_cv_f77_openmp" != "xnone"; then
51122+
OPENMP_FFLAGS=$ax_cv_f77_openmp
51123+
fi
51124+
51125+
$as_echo "#define HAVE_OPENMP 1" >>confdefs.h
51126+
51127+
fi
51128+
51129+
ac_ext=cpp
51130+
ac_cpp='$CXXCPP $CPPFLAGS'
51131+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
51132+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
51133+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
51134+
51135+
51136+
fi
51137+
51138+
if test "x$OPENMP_CFLAGS" != "x"; then :
51139+
51140+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with C OpenMP support >>>" >&5
51141+
$as_echo "<<< Configuring library with C OpenMP support >>>" >&6; }
51142+
CFLAGS_OPT="$CFLAGS_OPT $OPENMP_CFLAGS"
51143+
CFLAGS_DBG="$CFLAGS_DBG $OPENMP_CFLAGS"
51144+
CFLAGS_DEVEL="$CFLAGS_DEVEL $OPENMP_CFLAGS"
51145+
CFLAGS_PROF="$CFLAGS_PROF $OPENMP_CFLAGS"
51146+
CFLAGS_OPROF="$CFLAGS_OPROF $OPENMP_CFLAGS"
51147+
51148+
51149+
fi
51150+
51151+
if test "x$OPENMP_FFLAGS" != "x"; then :
51152+
51153+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with Fortran OpenMP support >>>" >&5
51154+
$as_echo "<<< Configuring library with Fortran OpenMP support >>>" >&6; }
51155+
FFLAGS="$FFLAGS $OPENMP_FFLAGS"
51156+
51157+
51158+
fi
51159+
51160+
if test "x$OPENMP_CXXFLAGS" != "x"; then :
51161+
51162+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with OpenMP support >>>" >&5
51163+
$as_echo "<<< Configuring library with OpenMP support >>>" >&6; }
51164+
CXXFLAGS_OPT="$CXXFLAGS_OPT $OPENMP_CXXFLAGS"
51165+
CXXFLAGS_DBG="$CXXFLAGS_DBG $OPENMP_CXXFLAGS"
51166+
CXXFLAGS_DEVEL="$CXXFLAGS_DEVEL $OPENMP_CXXFLAGS"
51167+
CXXFLAGS_PROF="$CXXFLAGS_PROF $OPENMP_CXXFLAGS"
51168+
CXXFLAGS_OPROF="$CXXFLAGS_OPROF $OPENMP_CXXFLAGS"
5094851169

5094951170

5095051171
else
50951-
if test "x$requested_thread_model" = "xopenmp"; then :
50952-
as_fn_error $? "requested openmp threading model, but compiler does not support openmp." "$LINENO" 5
51172+
if test "x$requested_thread_model" = "xopenmp"; then :
51173+
as_fn_error $? "requested openmp threading model, but C++ compiler does not support openmp." "$LINENO" 5
5095351174
fi
5095451175
fi
5095551176
else

contrib/timpi

include/base/libmesh_augment_std_namespace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ LIBMESH_DEFINE_BOTH_MAX_MIN(libMesh::Real, double)
4646
LIBMESH_DEFINE_BOTH_MAX_MIN(libMesh::Real, float)
4747
#endif
4848

49-
// fix for std::abs() overload ambiguity
50-
#if defined(__PGI)
49+
// fix for std::abs() overload ambiguity with older PGI
50+
#if defined(__PGI) && !defined(__NVCOMPILER)
5151
inline double abs(double a)
5252
{ return ::fabs(a); }
5353
#endif

m4/autoconf-submodule

0 commit comments

Comments
 (0)