Skip to content

Commit

Permalink
config: update configure of cuda and ze
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhou authored and raffenet committed Feb 10, 2021
1 parent 67b1e07 commit 84ae624
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
21 changes: 11 additions & 10 deletions src/mpl/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -982,26 +982,27 @@ AC_SUBST(libmpl_so_versionflags)
#######################################################################
have_gpu="no"
# Check CUDA availability
PAC_SET_HEADER_LIB_PATH([cuda])
PAC_CHECK_HEADER_LIB([cuda_runtime_api.h],[cudart],[cudaStreamSynchronize],[have_cudart=yes],[have_cudart=no])
PAC_CHECK_HEADER_LIB([cuda.h],[cuda],[cuMemGetAddressRange],[have_cuda=yes],[have_cuda=no])
if test "X${have_cudart}" = "Xyes" -a \
"X${have_cuda}" = "Xyes" ; then
PAC_CHECK_HEADER_LIB_OPTIONAL([cuda],[cuda_runtime_api.h],[cudart],[cudaStreamSynchronize])
if test "$pac_have_cuda" = "yes" ; then
# also require -lcuda (in addition to -lcudart)
PAC_CHECK_HEADER_LIB([cuda.h],[cuda],[cuMemGetAddressRange], pac_have_cuda=yes, pac_have_cuda=no)
fi
if test "X${pac_have_cuda}" = "Xyes" ; then
PAC_LIBS_ADD(-lcuda)
AC_DEFINE([HAVE_CUDA],[1],[Define if CUDA is available])
have_gpu="yes"
fi
AM_CONDITIONAL([MPL_HAVE_CUDA],[test "X${have_cudart}" = "Xyes" -a "X${have_cuda}" = "Xyes"])
AM_CONDITIONAL([MPL_HAVE_CUDA],[test "X${pac_have_cuda}" = "Xyes"])

if test "$have_gpu" = "no" ; then
# Check Level Zero availability when no other GPU library is available
PAC_SET_HEADER_LIB_PATH([ze])
PAC_CHECK_HEADER_LIB([level_zero/ze_api.h],[ze_loader],[zeInit],[have_ze=yes],[have_ze=no])
if test "X${have_ze}" = "Xyes" ; then
PAC_CHECK_HEADER_LIB_OPTIONAL([ze],[level_zero/ze_api.h],[ze_loader],[zeInit])
if test "X${pac_have_ze}" = "Xyes" ; then
AC_DEFINE([HAVE_ZE],[1],[Define if ZE is available])
have_gpu="yes"
fi
fi
AM_CONDITIONAL([MPL_HAVE_ZE],[test "X${have_ze}" = "Xyes"])
AM_CONDITIONAL([MPL_HAVE_ZE],[test "X${pac_have_ze}" = "Xyes"])
#######################################################################
## END OF GPU CODE
#######################################################################
Expand Down
18 changes: 8 additions & 10 deletions test/mpi/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,14 @@ PAC_PUSH_FLAG([LDFLAGS])
PAC_PUSH_FLAG([LIBS])

# Check CUDA availability
PAC_SET_HEADER_LIB_PATH([cuda])
PAC_CHECK_HEADER_LIB([cuda_runtime_api.h],[cudart],[cudaStreamSynchronize],[have_cuda=yes],[have_cuda=no])
PAC_CHECK_HEADER_LIB_OPTIONAL([cuda],[cuda_runtime_api.h],[cudart],[cudaStreamSynchronize])
cuda_CPPFLAGS=""
cuda_LDFLAGS=""
cuda_LIBS=""
if test "X${have_cuda}" = "Xyes" ; then
if test "X${pac_have_cuda}" = "Xyes" ; then
AC_DEFINE([HAVE_CUDA],[1],[Define if CUDA is available])
have_gpu="yes"
if test -n "${with_cuda}" ; then
if test -n "${with_cuda}" -a "$with_cuda" != "no" ; then
cuda_CPPFLAGS="-I${with_cuda}/include"
if test -d ${with_cuda}/lib64 ; then
cuda_LDFLAGS="-L${with_cuda}/lib64 -L${with_cuda}/lib"
Expand All @@ -748,22 +747,21 @@ if test "X${have_cuda}" = "Xyes" ; then
cuda_LIBS="-lcudart"
fi
fi
AM_CONDITIONAL([HAVE_CUDA],[test "X${have_cuda}" = "Xyes"])
AM_CONDITIONAL([HAVE_CUDA],[test "X${pac_have_cuda}" = "Xyes"])
AC_SUBST([cuda_CPPFLAGS])
AC_SUBST([cuda_LDFLAGS])
AC_SUBST([cuda_LIBS])

if test "$have_gpu" = "no" ; then
# Check Level Zero availability when no other GPU library is available
PAC_SET_HEADER_LIB_PATH([ze])
PAC_CHECK_HEADER_LIB([level_zero/ze_api.h],[ze_loader],[zeInit],[have_ze=yes],[have_ze=no])
PAC_CHECK_HEADER_LIB_OPTIONAL([ze],[level_zero/ze_api.h],[ze_loader],[zeInit])
ze_CPPFLAGS=""
ze_LDFLAGS=""
ze_LIBS=""
if test "X${have_ze}" = "Xyes" ; then
if test "X${pac_have_ze}" = "Xyes" ; then
AC_DEFINE([HAVE_ZE],[1],[Define if ZE is available])
have_gpu="yes"
if test -n "${with_ze}" ; then
if test -n "${with_ze}" -a "$with_ze" != "no" ; then
ze_CPPFLAGS="-I${with_ze}/include"
if test -d ${with_ze}/lib64 ; then
ze_LDFLAGS="-L${with_ze}/lib64 -L${with_ze}/lib"
Expand All @@ -777,7 +775,7 @@ if test "$have_gpu" = "no" ; then
AC_SUBST([ze_LDFLAGS])
AC_SUBST([ze_LIBS])
fi
AM_CONDITIONAL([HAVE_ZE],[test "X${have_ze}" = "Xyes"])
AM_CONDITIONAL([HAVE_ZE],[test "X${pac_have_ze}" = "Xyes"])

PAC_POP_FLAG([CPPFLAGS])
PAC_POP_FLAG([LDFLAGS])
Expand Down

0 comments on commit 84ae624

Please sign in to comment.