Skip to content

Commit

Permalink
Update build framework (#58)
Browse files Browse the repository at this point in the history
* Remove config.h.in file from version control
* Remove autogen script
* Add with-hypre-dir option
* Update install instructions
* Check for srun or mpirun
* Improve checking for dependency libraries
  • Loading branch information
victorapm authored Apr 3, 2024
1 parent c2b537a commit 97d41ae
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 184 deletions.
131 changes: 0 additions & 131 deletions HYPREDRV_config.h.in

This file was deleted.

16 changes: 9 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ docs: doxygen-doc
@echo "Built user's manual documentation (Sphinx)"

check:
@command -v mpirun >/dev/null 2>&1 || { echo >&2 "mpirun not found!"; exit 1; }
@mpirun -np 1 ./hypredrive examples/ex1.yml > /dev/null 2>&1
@{ command -v mpirun >/dev/null 2>&1 && MPIRUN=mpirun && NPFLAG=-np; } || \
{ command -v srun >/dev/null 2>&1 && MPIRUN=srun && NPFLAG=-n; } || \
{ echo >&2 "Neither mpirun nor srun found!"; exit 1; }
@$(MPIRUN) $(NPFLAG) 1 ./hypredrive examples/ex1.yml > /dev/null 2>&1
@if test $$? -eq 0 ; then \
echo "Running with 1 MPI process... passed!"; \
echo "Running ex1 with 1 MPI process... passed!"; \
else \
echo "Running with 1 MPI process... failed!"; \
echo "Running ex1 with 1 MPI process... failed!"; \
exit 1; \
fi
@mpirun -np 4 ./hypredrive examples/ex2.yml > /dev/null 2>&1
@$(MPIRUN) $(NPFLAG) 4 ./hypredrive examples/ex2.yml > /dev/null 2>&1
@if test $$? -eq 0 ; then \
echo "Running with 4 MPI process... passed!"; \
echo "Running ex2 with 4 MPI processes... passed!"; \
else \
echo "Running with 4 MPI process... failed!"; \
echo "Running ex2 with 4 MPI processes... failed!"; \
exit 1; \
fi
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ High-level interface for solving linear systems with hypre, providing a user-fri
The instructions for building *hypredrive* are given below:

```
$ ./autogen.sh
$ ./configure --with-hypre-include=${HYPRE_INSTALL_DIR}/include \
--with-hypre-lib=${HYPRE_INSTALL_DIR}/lib
$ autoreconf -i
$ ./configure --with-hypre-dir=${HYPRE_INSTALL_DIR}
$ make all
$ make check
$ make install
```

Note:
1. The first step `./autogen.sh` must be executed only once after cloning this repository.
1. The first step must be executed only once after cloning this repository.
2. [hypre](https://github.com/hypre-space/hypre) needs to be installed at
`${HYPRE_INSTALL_DIR}`.
3. For GPU support, add `--with-cuda` for NVIDIA GPUs or `--with-hip` for AMD GPUs in the
`./configure` line.
3. For GPU support, add `--with-cuda` (NVIDIA GPUs) or `--with-hip` (AMD GPUs) to
`./configure`.
4. An installation prefix can be passed to `./configure` such as `--prefix=${INSTALL_PATH}`.
For more configure options, type `./configure -help`.

Expand Down
10 changes: 0 additions & 10 deletions autogen.sh

This file was deleted.

113 changes: 99 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
AC_PREREQ([2.69])
AC_INIT([hypredrive], [0.1], [[email protected]])
AC_INIT([hypredrive],
[0.1],
[https://github.com/hypre-space/hypredrive/issues],
[hypredrive],
[https://github.com/hypre-space/hypredrive])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])

dnl Include m4 macros
Expand Down Expand Up @@ -32,17 +36,29 @@ AM_PROG_CC_C_O()
AM_PROG_AR
LT_INIT([disable-shared])

dnl Specify hypre include directory
AC_ARG_WITH([hypre-include],
[AS_HELP_STRING([--with-hypre-include=DIR], [Required: Path to HYPRE include dir.])],
[CFLAGS+=" -I$withval"],
[AC_MSG_ERROR([--with-hypre-include=DIR is required. Please specify the path to the HYPRE include directory.])])
dnl Check for --with-hypre-dir first
AC_ARG_WITH([hypre-dir],
[AS_HELP_STRING([--with-hypre-dir=DIR], [Optional: Path to HYPRE directory. Specifies both include and library dirs.])],
[
CFLAGS+=" -I$withval/include"
LDFLAGS+=" -L$withval/lib -Wl,-rpath,$withval/lib"
])

dnl Specify hypre include directory only if hypre-dir is not specified
AS_IF([test -z "$with_hypre_dir"], [
AC_ARG_WITH([hypre-include],
[AS_HELP_STRING([--with-hypre-include=DIR], [Required if --with-hypre-dir is not specified: Path to HYPRE include dir.])],
[CFLAGS+=" -I$withval"],
[AC_MSG_ERROR([--with-hypre-include=DIR or --with-hypre-dir=DIR is required. Please specify the path to the HYPRE include directory.])])
])

dnl Specify hypre lib directory
AC_ARG_WITH([hypre-lib],
[AS_HELP_STRING([--with-hypre-lib=DIR], [Required: Path to HYPRE library dir.])],
[LDFLAGS+=" -L$withval -Wl,-rpath,${withval}"],
[AC_MSG_ERROR([--with-hypre-lib=DIR is required. Please specify the path to the HYPRE library directory.])])
dnl Specify hypre lib directory only if hypre-dir is not specified
AS_IF([test -z "$with_hypre_dir"], [
AC_ARG_WITH([hypre-lib],
[AS_HELP_STRING([--with-hypre-lib=DIR], [Required if --with-hypre-dir is not specified: Path to HYPRE library dir.])],
[LDFLAGS+=" -L$withval -Wl,-rpath,$withval"],
[AC_MSG_ERROR([--with-hypre-lib=DIR or --with-hypre-dir=DIR is required. Please specify the path to the HYPRE library directory.])])
])

dnl Check for CUDA support
AC_ARG_WITH([cuda],
Expand All @@ -56,13 +72,46 @@ AC_ARG_WITH([cuda-home],
[cuda_home="$withval"],
[cuda_home="$CUDA_HOME"])

dnl Verify CUDA_HOME is defined if CUDA support is enabled
dnl Verify CUDA support
AS_IF([test "x$with_cuda" = "xyes"], [
dnl Check for CUDA_HOME
AS_IF([test -z "$cuda_home"], [
AC_MSG_ERROR([CUDA home directory is not defined. Please define the CUDA_HOME environment variable or use --with-cuda-home=DIR.])
])
dnl Update LDFLAGS and LIBS
LDFLAGS+=" -L$cuda_home/lib64 -Wl,-rpath,$cuda_home/lib64"
LIBS+=" -lcudart -lcusparse -lcublas -lcurand -lcusolver -lstdc++"
dnl Check for libcudart
AC_CHECK_LIB([cudart],
[cudaMalloc],
[AC_MSG_NOTICE([libcudart found.])],
[AC_MSG_ERROR([libcudart not found. Please ensure CUDA is installed correctly.])])
dnl Check for libcudart
AC_CHECK_LIB([cusparse],
[cusparseCreate],
[AC_MSG_NOTICE([libcusparse found.])],
[AC_MSG_ERROR([libcusparse not found. Please ensure CUDA is installed correctly.])])
dnl Check for libcublas
AC_CHECK_LIB([cublas],
[cublasCreate],
[AC_MSG_NOTICE([libcublas found.])],
[AC_MSG_ERROR([libcublas not found. Please ensure CUDA is installed correctly.])])
dnl Check for libcusolver
AC_CHECK_LIB([cusolver],
[cusolverDnCreate],
[AC_MSG_NOTICE([libcusolver found.])],
[AC_MSG_ERROR([libcusolver not found. Please ensure CUDA is installed correctly.])])
dnl Check for libcurand
AC_CHECK_LIB([curand],
[curandCreateGenerator],
[AC_MSG_NOTICE([libcurand found.])],
[AC_MSG_ERROR([libcurand not found. Please ensure CUDA is installed correctly.])])
])

dnl Check for HIP support
Expand All @@ -79,25 +128,61 @@ AC_ARG_WITH([rocm-path],

dnl Verify ROCM_PATH is defined if HIP support is enabled
AS_IF([test "x$with_hip" = "xyes"], [
dnl Check for ROCM_PATH
AS_IF([test -z "$rocm_path"], [
AC_MSG_ERROR([ROCM home directory is not defined. Please define the ROCM_PATH environment variable or use --with-rocm-path=DIR.])
])
dnl Update LDFLAGS and LIBS
LDFLAGS+=" -L$rocm_path/lib -Wl,-rpath,$rocm_path/lib"
LIBS+=" -lamdhip64 -lrocsparse -lrocblas -lrocrand -lrocsolver -lstdc++"
dnl Check for libamdhip64
AC_CHECK_LIB([amdhip64],
[hipMalloc],
[AC_MSG_NOTICE([libamdhip64 found.])],
[AC_MSG_ERROR([libamdhip64 not found. Please ensure ROCm is installed correctly.])])
dnl Check for librocsparse
AC_CHECK_LIB([rocsparse],
[rocsparse_create_handle],
[AC_MSG_NOTICE([librocsparse found.])],
[AC_MSG_ERROR([librocsparse not found. Please ensure ROCm is installed correctly.])])
dnl Check for librocblas
AC_CHECK_LIB([rocblas],
[rocblas_create_handle],
[AC_MSG_NOTICE([librocblas found.])],
[AC_MSG_ERROR([librocblas not found. Please ensure ROCm is installed correctly.])])
dnl Check for librocrand
AC_CHECK_LIB([rocrand],
[rocrand_create_generator],
[AC_MSG_NOTICE([librocrand found.])],
[AC_MSG_ERROR([librocrand not found. Please ensure ROCm is installed correctly.])])
dnl Check for librocsolver
AC_CHECK_LIB([rocsolver],
[rocsolver_create_handle],
[AC_MSG_NOTICE([librocsolver found.])],
[AC_MSG_ERROR([librocsolver not found. Please ensure ROCm is installed correctly.])])
])

dnl Avoid using CUDA and HIP
AS_IF([test "x$with_cuda" = "xyes" -a "x$with_hip" = "xyes"], [
AC_MSG_ERROR([--with-cuda and --with-hip options are mutually exclusive. Please choose one.])
])

AC_CHECK_LIB([m], [sin],
[],
dnl Check for libm
AC_CHECK_LIB([m], [sin], [],
[AC_MSG_ERROR([libm (math library) not found or not usable])])

dnl Check for libHYPRE
AC_CHECK_LIB([HYPRE], [HYPRE_IJMatrixCreate], [],
[AC_MSG_ERROR([HYPRE library not found or not usable])])

dnl Check for HYPRE headers
AC_CHECK_HEADER([HYPRE_config.h], [],
[AC_MSG_ERROR([HYPRE headers not found or not usable. Please ensure the correct path is specified with --with-hypre-include and the headers are installed.])])

Expand Down
Loading

0 comments on commit 97d41ae

Please sign in to comment.