Skip to content

Commit

Permalink
GraphBLAS bug fix (GB_add_phase0), and latest CUDA draft kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Mar 21, 2024
1 parent c6ac90b commit 931ed09
Show file tree
Hide file tree
Showing 188 changed files with 4,311 additions and 17,662 deletions.
7 changes: 2 additions & 5 deletions GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@ configure_file ( "Config/README.md.in"
"${PROJECT_SOURCE_DIR}/README.md"
NEWLINE_STYLE LF )

# for CUDA
configure_file ( "CUDA/Config/GB_cuda_common_jitFactory.hpp.in"
"${PROJECT_SOURCE_DIR}/CUDA/GB_cuda_common_jitFactory.hpp"
NEWLINE_STYLE LF )

#-------------------------------------------------------------------------------
# include directories for both graphblas and the demos
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -465,6 +460,7 @@ if ( GRAPHBLAS_HAS_OPENMP )
target_link_libraries ( GraphBLAS_static PRIVATE OpenMP::OpenMP_C )
endif ( )
message ( STATUS "CMAKE OpenMP C flags: ${OpenMP_C_FLAGS}" )
set ( GB_OPENMP_C_FLAGS "${OpenMP_C_FLAGS}" )
else ( )
message ( WARNING
"WARNING: OpenMP was not found (or was disabled with "
Expand All @@ -485,6 +481,7 @@ else ( )
"The C compiler does not support thread-local-storage; "
"GxB_Context_engage will return GrB_NOT_IMPLEMENTED." )
endif ( )
set ( GB_OPENMP_C_FLAGS "" )
endif ( )

if ( SUITESPARSE_HAS_CUDA AND GRAPHBLAS_USE_CUDA )
Expand Down
2 changes: 0 additions & 2 deletions GraphBLAS/CUDA/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*.o
*.a
*.so
jitFactory
stringify
rmm_log.txt

# Do not ignore this file
Expand Down
133 changes: 7 additions & 126 deletions GraphBLAS/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# GraphBLAS/CUDA/CMakeLists.txt: cmake script for GraphBLAS/CUDA
#-------------------------------------------------------------------------------

# SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2023, All Rights Reserved.
# SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2024, All Rights Reserved.

# Some files in this folder are (c) NVIDIA or (c) Google. Please refer
# to their individual licenses (Apache, BSD, or others).
Expand All @@ -12,11 +12,6 @@

cmake_minimum_required ( VERSION 3.20 ) # GraphBLAS can be built stand-alone

# CMake build for generating googletest c++ files that can be compiled and
# executed in parallel. Build can be customized to speed up development by
# allowing the targeting of specific specific parameters. The output of this
# build is an executable that can be used to run the gtests.

project ( GRAPHBLAS_CUDA
VERSION "${GraphBLAS_VERSION_MAJOR}.${GraphBLAS_VERSION_MINOR}.${GraphBLAS_VERSION_SUB}"
LANGUAGES CXX CUDA )
Expand All @@ -29,7 +24,6 @@ set ( CMAKE_CUDA_FLAGS "-cudart=static -lineinfo " )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17 -fPIC " )

add_compile_definitions ( GBNCPUFEAT )
add_compile_definitions ( GBCUDA_CPLUSPLUS )

message ( STATUS "C++ flags for CUDA: ${CMAKE_CXX_FLAGS}" )

Expand Down Expand Up @@ -160,126 +154,13 @@ if ( NOT MSVC )
endif ( )

#-------------------------------------------------------------------------------
# test suite for the CUDA kernels
# report
#-------------------------------------------------------------------------------

if ( 0 )

# 1. Execute enumify/stringify/jitify logic to compile ptx kernels and
# compile/link w/ relevant *.cu files.

# TODO: Need to do this piece in cmake

# 2. Generate test .cu files named "{semiring_operation}_test_instances.hpp"
set ( CUDA_TEST_SUITES
AxB_dot3
# reduce_to_scalar
)

#
set ( CUDA_TEST_MONOIDS PLUS MIN MAX) # TIMES ANY )
set ( CUDA_TEST_BINOPS TIMES PLUS MIN MAX DIV ) #MINUS RDIV RMINUS FIRST SECOND PAIR )
set ( CUDA_TEST_SEMIRINGS PLUS_TIMES MIN_PLUS MAX_PLUS )
set ( CUDA_TEST_DATATYPES int32_t int64_t uint32_t uint64_t float double )
set ( CUDA_TEST_KERNELS vsvs) # mp vsvs dndn spdn vssp )
set ( CUDA_TEST_FORMATS sparse dense sparse_dense reduce )

# TODO: Update testGen.py to accept the above CUDA_TEST_* params as arguments

# Note: I don't believe there's a way to do this particular piece in parallel but
# once all the files are written, we should be able to compile them in parallel

# Separate individual kernels from larger "overview" test (e.g. 2-level testing structure)
# We want to test all the *_cuda versions

# TODO: make this a shorter test
set(CUDA_TEST_CPP_FILES "")
if ( FALSE ) # TODO: use a cmake option
foreach(var ${CUDA_TEST_SUITES})
foreach(semiring ${CUDA_TEST_SEMIRINGS})
foreach(kernel ${CUDA_TEST_KERNELS})
foreach(format ${CUDA_TEST_FORMATS})
# TODO: Have Python script also build separate cudaTest.cpp (named something
# like AxB_dot3_cuda_tests.cpp) for each suite. This way we should be able to
# easily ignore them from the build
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${var}_${semiring}_${format}_test_instances.hpp
${CMAKE_CURRENT_BINARY_DIR}/${var}_${semiring}_${format}_cuda_tests.cpp
# DEPENDS
# jitFactory.hpp
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/test/testGen_cmake.py "\"${CMAKE_CURRENT_SOURCE_DIR}\"" "\"${var}\"" "\"${CUDA_TEST_MONOIDS}\""
"\"${CUDA_TEST_BINOPS}\"" "\"${semiring}\"" "\"${CUDA_TEST_DATATYPES}\""
"\"${kernel}\""
)
# Construct final list of files to compile (in parallel)
list(APPEND CUDA_TEST_CPP_FILES ${CMAKE_CURRENT_BINARY_DIR}/${var}_${semiring}_${format}_cuda_tests.cpp)
endforeach()
endforeach()
endforeach()
endforeach()
endif ( )

include(FetchContent)
FetchContent_Declare(
googletest
# Specify the commit you depend on and update it regularly.
URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

#FetchContent_MakeAvailable(googletest EC)


#file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external_includes)
#execute_process(
# COMMAND git clone "https://github.com/google/googletest.git" googletest
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external_includes)
#
#include_directories(${CMAKE_CURRENT_BINARY_DIR}/external_includes/googletest/googletest/include)

#add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external_includes/googletest/googletest/)

# 3. Compile/link individual {test_suite_name}_cuda_tests.cpp files into a gtest executable
set(GRAPHBLAS_CUDA_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/test)
message ( STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES} ")
message ( STATUS "CMAKE_CUDA_COMPILER: ${CMAKE_CUDA_COMPILER} ")
message ( STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS} ")
message ( STATUS "CMAKE_CUDA_FLAGS_RELEASE: ${CMAKE_CUDA_FLAGS_RELEASE} ")
message ( STATUS "CMAKE_CUDA_FLAGS_DEBUG: ${CMAKE_CUDA_FLAGS_DEBUG} ")

message(STATUS "CUDA tests files: " "${CUDA_TEST_CPP_FILES}")

add_executable(graphblascuda_test ${CUDA_TEST_CPP_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/test/run_tests.cpp)

set_target_properties(graphblascuda_test PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(graphblascuda_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(graphblascuda_test PROPERTIES CUDA_ARCHITECTURES "52;75;80" )

include(GoogleTest)

if ( ENABLE_SHARED_LIBS )
target_link_libraries ( graphblascuda_test PUBLIC GraphBLAS )
else ( )
target_link_libraries ( graphblascuda_test PUBLIC GraphBLAS_static )
endif ( )

target_link_libraries ( graphblascuda_test
PUBLIC
GraphBLAS_CUDA
RMM_wrap
CUDA::cudart_static
CUDA::nvrtc
${ADDITIONAL_DEPS}
PRIVATE
gtest_main )

target_include_directories ( graphblascuda_test
PUBLIC
rmm_wrap
${ADDITIONAL_INCLUDES}
${CUDAToolkit_INCLUDE_DIRS}
${GRAPHBLAS_CUDA_INCLUDES} )

endif ( )
82 changes: 0 additions & 82 deletions GraphBLAS/CUDA/Config/GB_cuda_common_jitFactory.hpp.in

This file was deleted.

2 changes: 1 addition & 1 deletion GraphBLAS/CUDA/Config/GraphBLAS_CUDA.pc.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GraphBLAS_CUDA, Copyright (c) 2017-2023, Timothy A. Davis.
# GraphBLAS_CUDA, Copyright (c) 2017-2024, FIXME
# All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion GraphBLAS/CUDA/Config/GraphBLAS_CUDAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# The following copyright and license applies to just this file only, not to
# the library itself:
# GraphBLASConfig.cmake, Copyright (c) 2023, Timothy A. Davis. All Rights Reserved.
# GraphBLASConfig.cmake, Copyright (c) 2023-2024, FIXME
# SPDX-License-Identifier: BSD-3-clause

#-------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 931ed09

Please sign in to comment.