Autotools changes

This commit is contained in:
Alejandro Gallo 2022-07-05 12:45:26 +02:00
parent 5765ae0dfb
commit 565fb1dcc8
6 changed files with 80 additions and 6 deletions

View File

@ -16,3 +16,7 @@ else
test_main_LDADD += @LIBCTF_LD_LIBRARY_PATH@/libctf.a
endif
if WITH_CUDA
test_main_CXXFLAGS = $(CUDA_CXXFLAGS)
test_main_LDADD += $(CUDA_LDFLAGS)
endif

View File

@ -26,7 +26,6 @@ AC_ARG_ENABLE([docs],
[Enable building docs])],
[build_docs=YES], [build_docs=NO])
dnl LIBGC library options
AC_ARG_WITH(libctf-prefix,
AS_HELP_STRING([--with-libctf-prefix=path],
@ -50,6 +49,15 @@ AC_ARG_WITH(dgemm,
[with_dgemm=NO],
[with_dgemm=YES])
AC_ARG_ENABLE([cuda],
[AS_HELP_STRING([--enable-cuda],
[Build with cuda])],
[WITH_CUDA=yes],
[WITH_CUDA=no])
AC_ARG_VAR([NVCC], [Path to the nvidia cuda compiler.])
AC_ARG_VAR([CUDA_LDFLAGS], [LDFLAGS to find libraries -lcuda and -lcudart.])
AC_ARG_VAR([CUDA_CXXFLAGS], [CXXFLAGS to find the CUDA headers])
dnl -----------------------------------------------------------------------
@ -124,6 +132,21 @@ else
[AC_MSG_ERROR([no ctf.hpp])])
fi
dnl CUDA NVIDIA -----------------------------------------------------------
AM_CONDITIONAL([WITH_CUDA], [test x${WITH_CUDA} = xyes])
if test x${WITH_CUDA} = xyes; then
AC_MSG_RESULT([
CUDA SUPPORT IS ENABLED
-----------------------
])
AC_CHECK_PROGS([NVCC], [nvcc])
AC_SUBST([CUDA_LDFLAGS])
AC_DEFINE([HAVE_CUDA],1,[Wether we are using CUDA])
# TODO: make sure to find cuda and cudart
# AC_SEARCH_LIBS([cudaMalloc], [cuda cudart], [FOUND_CUDA=yes])
fi
dnl -----------------------------------------------------------------------
dnl Docs
if test x${build_docs} = xYES; then

19
cuda.nix Normal file
View File

@ -0,0 +1,19 @@
{pkgs}:
{
shellHook = ''
export NVCC=${pkgs.cudatoolkit}/bin/nvcc
export CUDA_ROOT_PATH=${pkgs.cudatoolkit}
export CUDA_CXXFLAGS="-I${pkgs.openmpi.out}/include -I$CUDA_ROOT_PATH/include"
# cudart
export CUDA_LIB_PATH=${pkgs.cudatoolkit.lib}
export CUDA_OUT_PATH=${pkgs.cudatoolkit.out}
# in here is libcuda
export CUDA_X11LIB="${pkgs.linuxPackages.nvidia_x11}/lib"
export CUDA_LDFLAGS="-L$CUDA_X11LIB -L$CUDA_ROOT_PATH/lib -L$CUDA_LIB_PATH/lib -lcuda -lcudart"
'';
}

View File

@ -1,4 +1,9 @@
{ compiler ? "gcc", pkgs ? import <nixpkgs> {} , with-mkl ? false, docs ? true }:
{ compiler ? "gcc"
, pkgs ? import <nixpkgs> {}
, with-mkl ? false
, cuda ? false
, docs ? true
}:
let
@ -8,10 +13,13 @@ let
openblas = import ./etc/nix/openblas.nix { inherit pkgs; };
cuda-pkg = if cuda then (import ./cuda.nix { inherit pkgs; }) else {};
in
pkgs.mkShell rec {
compiler-pkg
= if compiler == "gcc11" then pkgs.gcc11
else if compiler == "gcc10" then pkgs.gcc10
@ -50,7 +58,7 @@ pkgs.mkShell rec {
= with pkgs; [
coreutils
git
git vim
openmpi
llvmPackages.openmp
@ -74,7 +82,7 @@ pkgs.mkShell rec {
LD = "${compiler-pkg}/bin/ld";
shellHook
= #(if with-mkl then mkl.shellHook else openblas.shellHook)
=
''
export OMPI_CXX=${CXX}
export OMPI_CC=${CC}
@ -82,6 +90,7 @@ pkgs.mkShell rec {
CC=${CC}
LD=${LD}
''
+ (if cuda then cuda-pkg.shellHook else "")
;
}

View File

@ -1,9 +1,23 @@
AUTOMAKE_OPTIONS = subdir-objects
include $(top_srcdir)/atrip.mk
AM_CXXFLAGS = $(CTF_CPPFLAGS)
AM_CXXFLAGS = $(CTF_CPPFLAGS) -fmax-errors=1
lib_LIBRARIES = libatrip.a
libatrip_a_CPPFLAGS = -I$(top_srcdir)/include/
libatrip_a_SOURCES = ./atrip/Atrip.cxx
libatrip_a_SOURCES = ./atrip/Atrip.cxx \
./atrip/Blas.cxx \
./atrip/Complex.cxx
if WITH_CUDA
libatrip_a_CPPFLAGS += $(CUDA_CXXFLAGS)
libatrip_a_DEPENDENCIES = ./atrip/Equations.o
libatrip_a_LIBADD = ./atrip/Equations.o
./atrip/Equations.o: ./atrip/Equations.cxx
$(NVCC) -c -I../ $(CPPFLAGS) $(libatrip_a_CPPFLAGS) $< -o $@
else
libatrip_a_SOURCES += ./atrip/Equations.cxx
endif

View File

@ -15,3 +15,8 @@ main_LDADD += $(CTF_BUILD_PATH)/lib/libctf.a
else
main_LDADD += @LIBCTF_LD_LIBRARY_PATH@/libctf.a
endif
if WITH_CUDA
main_CXXFLAGS = $(CUDA_CXXFLAGS)
main_LDADD += $(CUDA_LDFLAGS)
endif