Skip to content

Commit

Permalink
cuDSS (#848)
Browse files Browse the repository at this point in the history
* Add cuDSS in preparation for sparse solvers
  • Loading branch information
cliffburdick authored Jan 30, 2025
1 parent e7d3129 commit cd73c01
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ option(MATX_MULTI_GPU "Multi-GPU support" OFF)
option(MATX_EN_VISUALIZATION "Enable visualization support" OFF)
#option(MATX_EN_CUTLASS OFF)
option(MATX_EN_CUTENSOR OFF)
option(MATX_EN_CUDSS OFF)
option(MATX_EN_FILEIO OFF)
option(MATX_EN_X86_FFTW OFF "Enable x86 FFTW support")
option(MATX_EN_NVPL OFF, "Enable NVIDIA Performance Libraries for optimized ARM CPU support")
Expand All @@ -78,6 +79,7 @@ option(MATX_EN_COVERAGE OFF "Enable code coverage reporting")

set(MATX_EN_PYBIND11 OFF CACHE BOOL "Enable pybind11 support")

set(cudss_DIR "" CACHE PATH "Directory where cuDSS is installed.")
set(cutensor_DIR "" CACHE PATH "Directory where cuTENSOR is installed.")
set(cutensornet_DIR "" CACHE PATH "Directory where cuTensorNet is installed.")
set(eigen_DIR "" CACHE PATH "Directory where Eigen is installed")
Expand Down Expand Up @@ -290,6 +292,13 @@ if (MATX_EN_CUTENSOR)
target_link_libraries(matx INTERFACE "-Wl,--disable-new-dtags")
endif()

if (MATX_EN_CUDSS)
set(cuDSS_VERSION 0.4.0.2)
include(cmake/FindcuDSS.cmake)
target_compile_definitions(matx INTERFACE MATX_EN_CUDSS)
target_link_libraries(matx INTERFACE cuDSS::cuDSS)
endif()

if (MATX_MULTI_GPU)
include(cmake/FindNvshmem.cmake)
find_package(Nvshmem REQUIRED)
Expand Down
134 changes: 134 additions & 0 deletions cmake/FindcuDSS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

#[=======================================================================[.rst:
FindcuDSS
--------
Find cuDSS
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target(s):
``cuDSS::cuDSS``
The cuDSS library, if found.
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``cuDSS_FOUND``
True if cuDSS is found.
``cuDSS_INCLUDE_DIRS``
The include directories needed to use cuDSS.
``cuDSS_LIBRARIES``
The libraries needed to usecuDSS.
``cuDSS_VERSION_STRING``
The version of the cuDSS library found. [OPTIONAL]
#]=======================================================================]

# Prefer using a Config module if it exists for this project
set(cuDSS_NO_CONFIG FALSE)
if(NOT cuDSS_NO_CONFIG)
find_package(cuDSS CONFIG QUIET HINTS ${cuDSS_DIR})
if(cuDSS_FOUND)
find_package_handle_standard_args(cuDSS DEFAULT_MSG cuDSS_CONFIG)
return()
endif()
endif()

find_path(cuDSS_INCLUDE_DIR NAMES cuDSS.h )

set(cuDSS_IS_HEADER_ONLY FALSE)
if(NOT cuDSS_LIBRARY AND NOT cuDSS_IS_HEADER_ONLY)
find_library(cuDSS_LIBRARY_RELEASE NAMES libcuDSS.so NAMES_PER_DIR )
find_library(cuDSS_LIBRARY_DEBUG NAMES libcuDSS.sod NAMES_PER_DIR )

include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
select_library_configurations(cuDSS)
unset(cuDSS_FOUND) #incorrectly set by select_library_configurations
endif()

include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)

if(cuDSS_IS_HEADER_ONLY)
find_package_handle_standard_args(cuDSS
REQUIRED_VARS cuDSS_INCLUDE_DIR
VERSION_VAR )
else()
find_package_handle_standard_args(cuDSS
REQUIRED_VARS cuDSS_LIBRARY cuDSS_INCLUDE_DIR
VERSION_VAR )
endif()

if(NOT cuDSS_FOUND)
set(cuDSS_FILENAME libcuDSS-linux-x86_64-${cuDSS_VERSION}-archive)

message(STATUS "cuDSS not found. Downloading library. By continuing this download you accept to the license terms of cuDSS")

CPMAddPackage(
NAME cuDSS
VERSION ${cuDSS_VERSION}
URL https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-x86_64/libcudss-linux-x86_64-${cuDSS_VERSION}_cuda12-archive.tar.xz
DOWNLOAD_ONLY YES
)

set(cuDSS_LIBRARY ${cuDSS_SOURCE_DIR}/lib/${CUDAToolkit_VERSION_MAJOR}/libcudss.so)
set(cuDSS_INCLUDE_DIR ${cuDSS_SOURCE_DIR}/include)


set(cuDSS_FOUND TRUE)
endif()

if(cuDSS_FOUND)
set(cuDSS_INCLUDE_DIRS ${cuDSS_INCLUDE_DIR})

if(NOT cuDSS_LIBRARIES)
set(cuDSS_LIBRARIES ${cuDSS_LIBRARY})
endif()

if(NOT TARGET cuDSS::cuDSS)
add_library(cuDSS::cuDSS UNKNOWN IMPORTED)
set_target_properties(cuDSS::cuDSS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${cuDSS_INCLUDE_DIRS}")

if(cuDSS_LIBRARY_RELEASE)
set_property(TARGET cuDSS::cuDSS APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(cuDSS::cuDSS PROPERTIES
IMPORTED_LOCATION_RELEASE "${cuDSS_LIBRARY_RELEASE}")
endif()

if(cuDSS_LIBRARY_DEBUG)
set_property(TARGET cuDSS::cuDSS APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(cuDSS::cuDSS PROPERTIES
IMPORTED_LOCATION_DEBUG "${cuDSS_LIBRARY_DEBUG}")
endif()

if(NOT cuDSS_LIBRARY_RELEASE AND NOT cuDSS_LIBRARY_DEBUG)
set_property(TARGET cuDSS::cuDSS APPEND PROPERTY
IMPORTED_LOCATION "${cuDSS_LIBRARY}")
endif()
endif()
endif()

unset(cuDSS_NO_CONFIG)
unset(cuDSS_IS_HEADER_ONLY)
1 change: 1 addition & 0 deletions docs_input/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Optional Third-party Dependencies
- `nvbench <https://github.com/NVIDIA/nvbench>`_ Commit 1a13a2e (Required to run benchmarks)
- `cutensor <https://developer.nvidia.com/cutensor>`_ 2.0.1.2+ (Required when using `einsum`)
- `cutensornet <https://docs.nvidia.com/cuda/cuquantum/cutensornet>`_ 24.03.0.4+ (Required when using `einsum`)
- `cuDSS <https://developer.nvidia.com/cudss>`_ 0.4.0.2+ (Required when using `solve` on sparse matrices)

Host (CPU) Support
------------------
Expand Down

0 comments on commit cd73c01

Please sign in to comment.