Skip to content

Commit

Permalink
configure: Cleanup CUDA configury
Browse files Browse the repository at this point in the history
The current approach to enabling CUDA support in the bandwidth
benchmarks with an environment variable that takes that path to an
include file is extremely fragile.  As a low-hanging fruit, this commit
brings the CUDA configuration closer to ROCm, but relying on a flag to
enable the feature and AC_SEARCH_LIBS to update lib flags, or on
--with-cuda allowing a user to provide a custom installation path.
Ideally, we should rely on dlopen()'ing the symbols we need from these
libraries so a single build of perftest can work on systems with and
without CUDA SDK, but that's to come later.

Signed-off-by: Raghu Raja <[email protected]>
  • Loading branch information
rajachan committed Jun 30, 2022
1 parent a36c040 commit ed1dd5a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
41 changes: 34 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)

AC_ARG_VAR(CUDA_H_PATH, help-string)
AC_ARG_VAR(RANLIB, ranlib tool)

AC_ARG_ENABLE([ibv_wr_api],
Expand Down Expand Up @@ -211,6 +210,40 @@ if [test $HAVE_EX = yes]; then
AC_DEFINE([HAVE_EX], [1], [Have EX support])
fi


# Legacy option to build with CUDA support, here for backwards compatibility.
if [test "$CUDA_H_PATH" ]; then
AC_MSG_WARN([You are using a deprecated method to build with CUDA support. Use the --with-cuda configure flag instead.])
AC_DEFINE([HAVE_CUDA], [1], [Enable CUDA feature])
AC_DEFINE_UNQUOTED([CUDA_PATH], "$CUDA_H_PATH" , [Enable CUDA feature])
LIBS=$LIBS" -lcuda"
fi

AC_ARG_ENABLE([cuda],
[AS_HELP_STRING([--enable-cuda],
[Enable CUDA benchmarks])
],
[],
[enable_cuda=no])

AC_ARG_WITH([cuda],
[AS_HELP_STRING([--with-cuda=@<:@CUDA installation path@:>@],
[Provide path to CUDA installation])
],
[AS_CASE([$with_cuda],
[yes|no], [],
[CPPFLAGS="-I$with_cuda/include $CPPFLAGS"
LDFLAGS="-L$with_cuda/lib64 -Wl,-rpath=$with_cuda/lib64 -L$with_cuda/lib -Wl,-rpath=$with_cuda/lib -lcuda -lcudart $LDFLAGS"])
])

AS_IF([test "x$enable_cuda" = xyes], [
AC_DEFINE([HAVE_CUDA], [1], [Enable CUDA benchmarks])
AC_CHECK_HEADERS([cuda.h], [],
[AC_MSG_ERROR([cannot include cuda.h])])
AC_SEARCH_LIBS([cuda], [cuMemAlloc], [],
[AC_MSG_ERROR([cannot link with -lcuda])])
])

AC_ARG_ENABLE([rocm],
[AS_HELP_STRING([--enable-rocm],
[Enable ROCm benchmarks])
Expand Down Expand Up @@ -247,12 +280,6 @@ if [test $HAVE_EX_ODP = yes] && [test $HAVE_EX = yes]; then
AC_DEFINE([HAVE_EX_ODP], [1], [Have Extended ODP support])
fi

if [test "$CUDA_H_PATH" ]; then
AC_DEFINE([HAVE_CUDA], [1], [Enable CUDA feature])
AC_DEFINE_UNQUOTED([CUDA_PATH], "$CUDA_H_PATH" , [Enable CUDA feature])
LIBS=$LIBS" -lcuda"
fi

AC_TRY_LINK([#include <infiniband/verbs.h>],
[struct ibv_qp_attr *attr; int x = attr->rate_limit;],[HAVE_PACKET_PACING=yes], [HAVE_PACKET_PACING=no])
AM_CONDITIONAL([HAVE_PACKET_PACING],[test "x$HAVE_PACKET_PACING" = "xyes"])
Expand Down
2 changes: 1 addition & 1 deletion src/perftest_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#endif

#ifdef HAVE_CUDA
#include CUDA_PATH
#include <cuda.h>
#endif

#ifdef HAVE_ROCM
Expand Down

0 comments on commit ed1dd5a

Please sign in to comment.