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

Allow BLAS/LAPACK to be specified directly, allow GraphBLAS JITpackage to be created when cross-compiling, documentation/README fixes #645

Merged
merged 15 commits into from
Dec 29, 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
6 changes: 2 additions & 4 deletions AMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ message ( STATUS "Building AMD version: v"
# define the project
#-------------------------------------------------------------------------------

project ( amd
project ( AMD
VERSION "${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -305,6 +305,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions BTF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ message ( STATUS "Building BTF version: v"
# define the project
#-------------------------------------------------------------------------------

project ( btf
project ( BTF
VERSION "${BTF_VERSION_MAJOR}.${BTF_VERSION_MINOR}.${BTF_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -239,6 +239,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions CAMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ message ( STATUS "Building CAMD version: v"
# define the project
#-------------------------------------------------------------------------------

project ( camd
project ( CAMD
VERSION "${CAMD_VERSION_MAJOR}.${CAMD_VERSION_MINOR}.${CAMD_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -285,6 +285,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions CCOLAMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ message ( STATUS "Building CCOLAMD version: v"
# define the project
#-------------------------------------------------------------------------------

project ( ccolamd
project ( CCOLAMD
VERSION "${CCOLAMD_VERSION_MAJOR}.${CCOLAMD_VERSION_MINOR}.${CCOLAMD_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -276,6 +276,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ message ( STATUS "Building CHOLMOD version: v"
# define the project
#-------------------------------------------------------------------------------

project ( cholmod
project ( CHOLMOD
VERSION "${CHOLMOD_VERSION_MAJOR}.${CHOLMOD_VERSION_MINOR}.${CHOLMOD_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -837,6 +837,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions COLAMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ message ( STATUS "Building COLAMD version: v"
# define the project
#-------------------------------------------------------------------------------

project ( colamd
project ( COLAMD
VERSION "${COLAMD_VERSION_MAJOR}.${COLAMD_VERSION_MINOR}.${COLAMD_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -276,6 +276,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
6 changes: 2 additions & 4 deletions CXSparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ message ( STATUS "Building CXSparse version: v"
# define the project
#-------------------------------------------------------------------------------

project ( cxsparse
project ( CXSparse
VERSION "${CXSPARSE_VERSION_MAJOR}.${CXSPARSE_VERSION_MINOR}.${CXSPARSE_VERSION_SUB}"
LANGUAGES C )

Expand Down Expand Up @@ -394,6 +394,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( SuiteSparseReport )
endif ( )
include ( SuiteSparseReport )
9 changes: 3 additions & 6 deletions GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ cmake_minimum_required ( VERSION 3.20 ) # GraphBLAS can be built stand-alone
# define the project
#-------------------------------------------------------------------------------

project ( graphblas
LANGUAGES C )
project ( GraphBLAS LANGUAGES C )

#-------------------------------------------------------------------------------
# SuiteSparse policies
Expand Down Expand Up @@ -265,7 +264,7 @@ if ( GRAPHBLAS_USE_JIT )
endif ( )
# GLOB does not include files that do not yet exist, so prepend
# the GB_JITpackage.c file here:
list ( PREPEND GRAPHBLAS_SOURCES "JITpackage/GB_JITpackage.c" )
list ( PREPEND GRAPHBLAS_SOURCES $<TARGET_PROPERTY:GB_JITpackage,GENERATED_FILE> )
else ( )
if ( GRAPHBLAS_COMPACT )
# no JIT, do not compile the FactoryKernels
Expand Down Expand Up @@ -732,6 +731,4 @@ endif ( )
# report status
#-------------------------------------------------------------------------------

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include ( GraphBLASReport )
endif ( )
include ( GraphBLASReport )
2 changes: 2 additions & 0 deletions GraphBLAS/JITpackage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore the constructed GB_JITpackage.c file
GB_JITpackage.c
117 changes: 93 additions & 24 deletions GraphBLAS/JITpackage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,98 @@

cmake_minimum_required ( VERSION 3.20 ) # GraphBLAS can be built stand-alone
project ( jitpackage LANGUAGES C )
add_executable ( grb_jitpackage "Source/grb_jitpackage.c" )
target_include_directories ( grb_jitpackage PRIVATE ../zstd/zstd_subset
../zstd )
if ( NOT WIN32 )
target_link_libraries ( grb_jitpackage PRIVATE m )

set ( GRAPHBLAS_CROSS_TOOLCHAIN_FLAGS_NATIVE "" CACHE STRING
"list of configuration flags used for building native generator binaries when cross-compiling" )

if ( CMAKE_CROSSCOMPILING )

cmake_path ( GET PROJECT_BINARY_DIR FILENAME _subdir )
if ( ${_subdir} STREQUAL "native" )
message ( FATAL_ERROR "Native toolchain not configured correctly" )
endif ( )

include ( ExternalProject )

# Try to call CMake on this file with a native toolchain
ExternalProject_Add ( jitpackage_generator_native
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${PROJECT_BINARY_DIR}/native
CMAKE_ARGS ${GRAPHBLAS_CROSS_TOOLCHAIN_FLAGS_NATIVE}
INSTALL_COMMAND "" )

# The following package won't be found on the first run (before the native
# grb_jitpackage has been built). But it should be found after the above
# external project has built it.
find_package ( GrBJITPackageGenerator
PATHS ${PROJECT_BINARY_DIR}/native NO_DEFAULT_PATH )

if ( NOT TARGET grb_jitpackage )
# target to rerun cmake after jitpackage_generator_native was built
# FIXME: This likely won't work with the Ninja generator or other
# generators that lock their own files. But it should work
# with a "* Makefiles" generator (which is the default on
# most platforms apart from Windows).
add_custom_target ( Reconfigure
${CMAKE_COMMAND} -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
DEPENDS jitpackage_generator_native )
endif ( )

else ( )

# Native build rules for the generator
add_executable ( grb_jitpackage "Source/grb_jitpackage.c" )
target_include_directories ( grb_jitpackage PRIVATE
../zstd/zstd_subset ../zstd )
if ( NOT WIN32 )
target_link_libraries ( grb_jitpackage PRIVATE m )
endif ( )

# Generate an import target to be able to run the native executable when
# cross-compiling.
export ( TARGETS grb_jitpackage FILE
"${CMAKE_BINARY_DIR}/GrBJITPackageGeneratorConfig.cmake")

endif ( )

if ( TARGET grb_jitpackage )
# This target might not exist on the first configuration run when
# cross-compiling. But is should exist for native builds and on the second
# configuration run when cross-compiling.

file ( GLOB GRB_SOURCE_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"../Include/GraphBLAS.h"
"../Source/Template/*.[ch]"
"../Source/JitKernels/*.[ch]"
"../CUDA/Template/*h"
"../CUDA/JitKernels/*h"
"../Source/Shared/*.h" )

add_custom_command ( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/GB_JITpackage.c
COMMAND $<TARGET_FILE:grb_jitpackage>
ARGS ${GRB_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${GRB_SOURCE_FILES}
COMMENT "Generating compressed sources for JIT compiler..." )

# target to make sure the file exists when building libgraphblas
add_custom_target ( GB_JITpackage
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GB_JITpackage.c )
set_target_properties ( GB_JITpackage PROPERTIES
GENERATED_FILE ${CMAKE_CURRENT_SOURCE_DIR}/GB_JITpackage.c )

else ( )

# dummy target when cross-compiling before the (native) grb_jitpackage
# has been built
add_custom_target ( GB_JITpackage )
set_target_properties ( GB_JITpackage PROPERTIES
GENERATED_FILE "" )

if ( CMAKE_CROSSCOMPILING )
# configure again after the native grb_jitpackage has been built
add_dependencies ( GB_JITpackage Reconfigure )
endif ( )
endif ( )

file ( GLOB GRB_SOURCE_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"../Include/GraphBLAS.h"
"../Source/Template/*.[ch]"
"../Source/JitKernels/*.[ch]"
"../CUDA/Template/*h"
"../CUDA/JitKernels/*h"
"../Source/Shared/*.h" )

add_custom_command ( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/GB_JITpackage.c
COMMAND $<TARGET_FILE:grb_jitpackage>
ARGS ${GRB_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${GRB_SOURCE_FILES}
COMMENT "Generating compressed sources for JIT compiler..."
)

add_custom_target ( GB_JITpackage
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GB_JITpackage.c )
Loading