Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build system updates #667

Merged
merged 4 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/build-arch-emu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
lapack-dev
valgrind
util-linux-misc
autoconf
automake
libtool

- name: get CPU information (emulated)
run: lscpu
Expand Down Expand Up @@ -170,7 +173,7 @@ jobs:
echo "::endgroup::"
done

- name: build example
- name: build example using CMake
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
Expand All @@ -193,3 +196,22 @@ jobs:
./my_cxx_demo_static
echo "::endgroup::"

- name: build example using autotools
run: |
cd ${GITHUB_WORKSPACE}/Example
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
autoreconf -fi
mkdir build-autotools
cd build-autotools
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \
../configure --enable-shared --disable-static
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
make all
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
printf "\033[1;35m C binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
printf "\033[1;35m C++ binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
echo "::endgroup::"
51 changes: 49 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ jobs:
echo "::endgroup::"
done

- name: build example
- name: build example using CMake
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
Expand All @@ -228,6 +228,31 @@ jobs:
./my_cxx_demo_static
echo "::endgroup::"

- name: build example using autotools
run: |
cd ${GITHUB_WORKSPACE}/Example
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
autoreconf -fi
mkdir build-autotools
cd build-autotools
if [ "${{ matrix.link }}" = static ]; then
_extra_config_flags="--enable-static --disable-shared"
else
_extra_config_flags="--enable-shared --disable-static"
fi
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \
../configure ${_extra_config_flags}
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
make all
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
printf "\033[1;35m C binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
printf "\033[1;35m C++ binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
echo "::endgroup::"

mingw:
# For available GitHub-hosted runners, see:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
Expand Down Expand Up @@ -372,7 +397,7 @@ jobs:
path: ${{ steps.ccache-prepare.outputs.ccachedir }}
key: ${{ steps.ccache-prepare.outputs.key }}

- name: build example
- name: build example using CMake
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
Expand All @@ -399,3 +424,25 @@ jobs:
PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \
./my_cxx_demo_static
echo "::endgroup::"

- name: build example using autotools
run: |
cd ${GITHUB_WORKSPACE}/Example
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
autoreconf -fi
mkdir build-autotools
cd build-autotools
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \
../configure --enable-shared --disable-static
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
make all
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
printf "\033[1;35m C binary\033[0m\n"
PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \
./my_demo
printf "\033[1;35m C++ binary\033[0m\n"
PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \
./my_cxx_demo
echo "::endgroup::"
27 changes: 26 additions & 1 deletion .github/workflows/root-cmakelists.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
cd ${GITHUB_WORKSPACE}/build
cmake --install .
- name: build example
- name: build example using CMake
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
Expand All @@ -211,6 +211,31 @@ jobs:
./my_cxx_demo_static
echo "::endgroup::"
- name: build example using autotools
run: |
cd ${GITHUB_WORKSPACE}/Example
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
autoreconf -fi
mkdir build-autotools
cd build-autotools
if [ "${{ matrix.link }}" = static ]; then
_extra_config_flags="--enable-static --disable-shared"
else
_extra_config_flags="--enable-shared --disable-static"
fi
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \
../configure ${_extra_config_flags}
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
make all
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
printf "\033[1;35m C binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
printf "\033[1;35m C++ binary\033[0m\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
echo "::endgroup::"
msvc:
# For available GitHub-hosted runners, see:
Expand Down
22 changes: 19 additions & 3 deletions CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,20 @@ if ( CHOLMOD_HAS_CUDA )
$<TARGET_PROPERTY:CUDA::cublas,INTERFACE_INCLUDE_DIRECTORIES> )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( CHOLMOD_static PRIVATE CUDA::nvrtc CUDA::cudart_static CUDA::cublas )
target_include_directories ( CHOLMOD_static INTERFACE
$<TARGET_PROPERTY:CUDA::cublas,INTERFACE_INCLUDE_DIRECTORIES> )
target_link_libraries ( CHOLMOD_static PRIVATE CUDA::nvrtc CUDA::cudart_static )
# FIXME: Ok to hardcode CUDA library names like this?
list ( APPEND CHOLMOD_STATIC_LIBS "-L${CUDAToolkit_LIBRARY_DIR};-lcuda;-lcudart_static" )
if ( TARGET CUDA::cublas_static )
target_link_libraries ( CHOLMOD_static PRIVATE CUDA::cublas_static )
target_include_directories ( CHOLMOD_static INTERFACE
$<TARGET_PROPERTY:CUDA::cublas_static,INTERFACE_INCLUDE_DIRECTORIES> )
list ( APPEND CHOLMOD_STATIC_LIBS "-lcublas_static;-lcublasLt_static;-lculibos" )
else ( )
target_link_libraries ( CHOLMOD_static PRIVATE CUDA::cublas )
target_include_directories ( CHOLMOD_static INTERFACE
$<TARGET_PROPERTY:CUDA::cublas,INTERFACE_INCLUDE_DIRECTORIES> )
list ( APPEND CHOLMOD_STATIC_LIBS "-lcublas" )
endif ( )
endif ( )

set ( old_CMAKE_EXTRA_INCLUDE_FILES CMAKE_EXTRA_INCLUDE_FILES )
Expand Down Expand Up @@ -628,6 +639,11 @@ if ( NOT MSVC )
set ( CHOLMOD_STATIC_LIBS_LIST ${CHOLMOD_STATIC_LIBS} )
set ( CHOLMOD_STATIC_LIBS "" )
foreach ( _lib ${CHOLMOD_STATIC_LIBS_LIST} )
if ( ${_lib} MATCHES "-[lL].*" )
# take -L or -l flags as is
set ( CHOLMOD_STATIC_LIBS "${CHOLMOD_STATIC_LIBS} ${_lib}" )
continue ()
endif ( )
string ( FIND ${_lib} "." _pos REVERSE )
if ( ${_pos} EQUAL "-1" )
set ( CHOLMOD_STATIC_LIBS "${CHOLMOD_STATIC_LIBS} -l${_lib}" )
Expand Down
2 changes: 0 additions & 2 deletions CHOLMOD/Config/CHOLMOD.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

# FIXME: Which flags do we need to statically link CUDA if needed?

Name: CHOLMOD
URL: https://github.com/DrTimothyAldenDavis/SuiteSparse
Description: Routines for factorizing sparse symmetric positive definite matrices in SuiteSparse
Expand Down
4 changes: 2 additions & 2 deletions Example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,15 @@ if ( BUILD_SHARED_LIBS )
add_executable ( my_demo "Demo/my_demo.c" )
target_link_libraries ( my_demo PUBLIC my )

add_executable ( my_cxx_demo "Demo/my_demo.c" )
add_executable ( my_cxx_demo "Demo/my_demo.cc" )
target_link_libraries ( my_cxx_demo PUBLIC my_cxx )
endif ( )

if ( BUILD_STATIC_LIBS )
add_executable ( my_demo_static "Demo/my_demo.c" )
target_link_libraries ( my_demo_static PUBLIC my_static )

add_executable ( my_cxx_demo_static "Demo/my_demo.c" )
add_executable ( my_cxx_demo_static "Demo/my_demo.cc" )
target_link_libraries ( my_cxx_demo_static PUBLIC my_cxx_static )
endif ( )

Expand Down
32 changes: 32 additions & 0 deletions Example/Demo/my_demo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//------------------------------------------------------------------------------
// SuiteSparse/Example/Demo/my_demo.c
//------------------------------------------------------------------------------

// Copyright (c) 2022-2023, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause

//------------------------------------------------------------------------------

// Example user program

#include <iostream>

#include "my.h"

int main (void)
{
std::cout << "My demo" << std::endl ;
int version [3] ;
char date [128] ;
my_version (version, date) ;
std::cout << "Date from #include 'my.h': " << MY_DATE << std::endl ;
std::cout << "Date from compiled library: " << date << std::endl ;
std::cout << "version from #include 'my.h.': " <<
MY_MAJOR_VERSION << '.' << MY_MINOR_VERSION << '.' << MY_PATCH_VERSION << std::endl ;
std::cout << "version from compiled library: " <<
version [0] << '.' << version [1] << '.' << version [2] << std::endl ;

int result = my_function ( ) ;
return (result) ;
}

69 changes: 69 additions & 0 deletions Example/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#-------------------------------------------------------------------------------
# SuiteSparse/Example/Makefile
#-------------------------------------------------------------------------------

# Example: Copyright (c) 2023, Timothy A. Davis, All Rights Reserved.
# SPDX-License-Identifier: BSD-3-Clause

#-------------------------------------------------------------------------------

# A simple Makefile for the MY library in SuiteSparse/Example, which relies on
# libtool.

# To compile with an alternate compiler:
#
# make CC=gcc CXX=g++
#
# To clean up the files:
#
# make clean

noinst_LTLIBRARIES = \
%reldir%/libmy.la \
%reldir%/libmy_cxx.la

%canon_reldir%_libmy_la_SOURCES = %reldir%/Source/my.c
%canon_reldir%_libmy_la_CPPFLAGS = -I../Include @SUITESPARSE_CFLAGS@
%canon_reldir%_libmy_la_LIBADD = @SUITESPARSE_LIBS@

%canon_reldir%_libmy_cxx_la_SOURCES = %reldir%/Source/my_cxx.cc
%canon_reldir%_libmy_cxx_la_CPPFLAGS = -I../Include @SUITESPARSE_CFLAGS@
%canon_reldir%_libmy_cxx_la_LIBADD = @SUITESPARSE_LIBS@

if AMCOND_HAVE_GRAPHBLAS
%canon_reldir%_libmy_la_CPPFLAGS += @GRAPHBLAS_CFLAGS@
%canon_reldir%_libmy_la_LIBADD += @GRAPHBLAS_LIBS@

%canon_reldir%_libmy_cxx_la_CPPFLAGS += @GRAPHBLAS_CFLAGS@
%canon_reldir%_libmy_cxx_la_LIBADD += @GRAPHBLAS_LIBS@
else
%canon_reldir%_libmy_la_CPPFLAGS += -DNO_GRAPHBLAS

%canon_reldir%_libmy_cxx_la_CPPFLAGS += -DNO_GRAPHBLAS
endif

if AMCOND_HAVE_LAGRAPH
%canon_reldir%_libmy_la_CPPFLAGS += @LAGRAPH_CFLAGS@
%canon_reldir%_libmy_la_LIBADD += @LAGRAPH_LIBS@

%canon_reldir%_libmy_cxx_la_CPPFLAGS += @LAGRAPH_CFLAGS@
%canon_reldir%_libmy_cxx_la_LIBADD += @LAGRAPH_LIBS@
else
%canon_reldir%_libmy_la_CPPFLAGS += -DNO_LAGRAPH

%canon_reldir%_libmy_cxx_la_CPPFLAGS += -DNO_LAGRAPH
endif

demo_PROGRAMS = \
%reldir%/my_demo \
%reldir%/my_cxx_demo

demodir = %canon_reldir%

%canon_reldir%_my_demo_SOURCES = %reldir%/Demo/my_demo.c
%canon_reldir%_my_demo_CPPFLAGS = -I../Include
%canon_reldir%_my_demo_LDADD = %reldir%/libmy.la

%canon_reldir%_my_cxx_demo_SOURCES = %reldir%/Demo/my_demo.cc
%canon_reldir%_my_cxx_demo_CPPFLAGS = -I../Include
%canon_reldir%_my_cxx_demo_LDADD = %reldir%/libmy_cxx.la
41 changes: 41 additions & 0 deletions Example/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# simple configure file for example project in SuiteSparse

# initialize
AC_INIT([example], [1.6.0])

AM_INIT_AUTOMAKE([foreign subdir-objects])

LT_INIT

# check for working compilers
AC_PROG_CC
AC_PROG_CXX

# find pkg-config executable
PKG_PROG_PKG_CONFIG()

if test "$enable_static" = yes; then
PKG_CONFIG="$PKG_CONFIG --static"
fi

# find installed SuiteSparse libraries
PKG_CHECK_MODULES([SUITESPARSE], [SuiteSparse_config AMD BTF CAMD CCOLAMD CHOLMOD COLAMD CXSparse KLU KLU_CHOLMOD LDL SuiteSparse_Mongoose ParU RBio SPEX SPQR UMFPACK])

PKG_CHECK_MODULES([GRAPHBLAS], [GraphBLAS], [use_graphblas=yes], [use_graphblas=no])
AM_CONDITIONAL([AMCOND_HAVE_GRAPHBLAS], [test $use_graphblas = yes])

PKG_CHECK_MODULES([LAGRAPH], [LAGraph], [use_lagraph=yes], [use_lagraph=no])
AM_CONDITIONAL([AMCOND_HAVE_LAGRAPH], [test $use_lagraph = yes])

# Check if linker flags are needed for function fmax.
# Adds -lm to LIBS if needed.
AC_CHECK_FUNC(fmax, [], AC_CHECK_LIB(m, fmax))

# Check for C++ STL.
# If found, this will add -lstdc++ to LIBS.
# FIXME: This is a workaround to allow linking CUDA libraries to a C binary.
AC_CHECK_LIB(stdc++, __gxx_personality_v0)

# create Makefile.in from Makefile.am
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
12 changes: 10 additions & 2 deletions SPQR/GPUQREngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,17 @@ if ( BUILD_STATIC_LIBS )
CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
CUDA_RUNTIME_LIBRARY Static )
target_link_libraries ( GPUQREngine_static PRIVATE
CUDA::nvrtc CUDA::cudart_static CUDA::cublas )
target_link_libraries ( GPUQREngine_static PRIVATE CUDA::nvrtc CUDA::cudart_static )
target_compile_definitions ( GPUQREngine_static PRIVATE "SPQR_HAS_CUDA" )
# FIXME: Ok to hardcode CUDA library names like this?
set ( GPUQRENGINE_STATIC_LIBS "-L${CUDAToolkit_LIBRARY_DIR} -lcuda -lcudart_static" )
if ( TARGET CUDA::cublas_static )
target_link_libraries ( GPUQREngine_static PRIVATE CUDA::cublas_static )
set ( GPUQRENGINE_STATIC_LIBS "${GPUQRENGINE_STATIC_LIBS} -lcublas_static -lcublasLt_static -lculibos" )
else ( )
target_link_libraries ( GPUQREngine_static PRIVATE CUDA::cublas )
set ( GPUQRENGINE_STATIC_LIBS "${GPUQRENGINE_STATIC_LIBS} -lcublas" )
endif ( )

target_include_directories ( GPUQREngine_static
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>
Expand Down
3 changes: 1 addition & 2 deletions SPQR/GPUQREngine/Config/GPUQREngine.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

# FIXME: Which flags do we need to statically link CUDA

Name: GPUQREngine
URL: https://github.com/DrTimothyAldenDavis/SuiteSparse
Description: GPU-accelerated QR factorization engine supporting SuiteSparseQR in SuiteSparse
Version: @SPQR_VERSION_MAJOR@.@SPQR_VERSION_MINOR@.@SPQR_VERSION_SUB@
Libs: -L${libdir} -l@SUITESPARSE_LIB_BASE_NAME@
Libs.private: @GPUQRENGINE_STATIC_LIBS@
Cflags: -I${includedir}
Loading