Skip to content

Commit

Permalink
First attempt to check for NVCC
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
  • Loading branch information
devreal committed Jul 8, 2024
1 parent b56ab0a commit 5fbc2d4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
74 changes: 74 additions & 0 deletions config/opal_check_nvcc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
dnl -*- autoconf -*-
dnl
dnl Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
dnl
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

dnl Setup Sphinx for building HTML docs and man pages
dnl
dnl 1 -> sanity file to check if pre-built docs are already available
dnl You probably want to pass something like
dnl "$srcdir/docs/_build/man/foo.1"
dnl
dnl 2 -> (OPTIONAL) URL to display in AC_MSG_WARN when docs will not be installed
dnl If $2 is empty, nothing will be displayed.
dnl Note: if $2 contains a #, be sure to double quote it
dnl (e.g., [[https://example.com/foo.html#some-anchor]])
dnl
dnl 3 -> (OPTIONAL) Filename of requirements.txt-like file containing
dnl the required Pip modules (to be displayed if rendering a
dnl simple RST project fails).
dnl
dnl This macro requires that OAC_PUSH_PREFIX was previously called.
dnl The pushed prefix may be used if this macro chooses to set {OAC
dnl prefix}_MAKEDIST_DISABLE. If set, it is a message indicating why
dnl "make dist" should be disabled, suitable for emitting via
dnl AC_MSG_WARN.
AC_DEFUN([OPAL_CHECK_NVCC],[
# This option is probably only helpful to developers: have
# configure fail if Sphinx is not found (i.e., if you don't have
# the ability to use Sphinx to build the HTML docs and man pages).
AC_ARG_ENABLE([nvcc],
[AS_HELP_STRING([--enable-nvcc],
[Force configure to fail if CUDA nvcc is not found (CUDA nvcc is used to build CUDA operator support).])])
AC_ARG_WITH([nvcc],
[AS_HELP_STRING([--with-nvcc=DIR],
[Path to the CUDA compiler])])
AC_ARG_WITH([nvcc_compute_arch],
[AS_HELP_STRING([--with-nvcc-compute-arch=ARCH],
[Compute architecture to use for CUDA (default: 52)])])
AS_IF([test -n "$with_nvcc"],
[OPAL_NVCC=$with_nvcc],
# no path specified, try to find nvcc
[AC_PATH_PROG([OPAL_NVCC], [nvcc], [])])
# If the user requested to disable sphinx, then pretend we didn't
# find it.
AS_IF([test "$enable_nvcc" = "no"],
[OPAL_NVCC=])
# default to CUDA compute architecture 52
AS_IF([test -n "$with_nvcc_compute_arch"],
[OPAL_NVCC_COMPUTE_ARCH=$with_nvcc_compute_arch],
[OPAL_NVCC_COMPUTE_ARCH=52])
# If --enable-sphinx was specified and we did not find Sphinx,
# abort. This is likely only useful to prevent "oops!" moments
# from developers.
AS_IF([test -z "$OPAL_NVCC" && test "$enable_nvcc" = "yes"],
[AC_MSG_WARN([A suitable CUDA compiler was not found, but --enable-nvcc was specified])
AC_MSG_ERROR([Cannot continue])])
OPAL_SUMMARY_ADD([Accelerators], [NVCC compiler], [], [$OPAL_NVCC (compute arch: $OPAL_NVCC_COMPUTE_ARCH)])
])
10 changes: 4 additions & 6 deletions ompi/mca/op/cuda/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ AM_CPPFLAGS = $(op_cuda_CPPFLAGS) $(op_cudart_CPPFLAGS)
dist_ompidata_DATA = help-ompi-mca-op-cuda.txt

sources = op_cuda_component.c op_cuda.h op_cuda_functions.c op_cuda_impl.h
#sources_extended = op_cuda_functions.cu
cu_sources = op_cuda_impl.cu

NVCC = nvcc -g
NVCCFLAGS= --std c++17 --gpu-architecture=compute_52
NVCCFLAGS = --std c++17 --gpu-architecture=compute_$(OPAL_NVCC_COMPUTE_ARCH)
# let the underlying compiler generate PIC code
PIC_FLAGS = -prefer-non-pic -Wc,-Xcompiler,-fPIC

.cu.l$(OBJEXT):
$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(NVCC) -prefer-non-pic $(NVCCFLAGS) -Wc,-Xcompiler,-fPIC,-g -c $<

# -o $($@.o:.lo)
$(LIBTOOLFLAGS) --mode=compile $(OPAL_NVCC) $(NVCCFLAGS) $(PIC_FLAGS) -c $<

# Open MPI components can be compiled two ways:
#
Expand Down
6 changes: 5 additions & 1 deletion ompi/mca/op/cuda/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ AC_DEFUN([MCA_ompi_op_cuda_CONFIG],[

OPAL_CHECK_CUDA([op_cuda])
OPAL_CHECK_CUDART([op_cudart])
OPAL_CHECK_NVCC([op_nvcc])

AS_IF([test "x$CUDA_SUPPORT" = "x1"],
AS_IF([test "x$CUDA_SUPPORT" = "x1" -a "x$CUDART_SUPPORT" = "x1" -a -n "$OPAL_NVCC"],
[$1],
[$2])

Expand All @@ -38,4 +39,7 @@ AC_DEFUN([MCA_ompi_op_cuda_CONFIG],[
AC_SUBST([op_cudart_LDFLAGS])
AC_SUBST([op_cudart_LIBS])

AC_SUBST([OPAL_NVCC])
AC_SUBST([OPAL_NVCC_COMPUTE_ARCH])

])dnl

0 comments on commit 5fbc2d4

Please sign in to comment.