Skip to content

Commit

Permalink
suitesparse-cholmod: proper CUDA support
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed May 6, 2024
1 parent dc0850c commit e4d7ea5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Reproduces the CUDA dependencies added by https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v7.7.0/CHOLMOD/GPU/CMakeLists.txt

find_dependency(CUDAToolkit REQUIRED)

target_link_libraries(SuiteSparse::CHOLMOD INTERFACE CUDA::nvrtc CUDA::cudart_static CUDA::cublas)
target_compile_definitions(SuiteSparse::CHOLMOD INTERFACE "CHOLMOD_HAS_CUDA")
13 changes: 11 additions & 2 deletions recipes/suitesparse-cholmod/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ class SuiteSparseCholmodConan(ConanFile):
"cuda": False,
}
options_description = {
"gpl": "Enable GPL-licensed modules",
"gpl": "Enable GPL-licensed modules: MatrixOps, Modify, Supernodal and CUDA",
"cuda": "Enable CUDA acceleration",
}

def export_sources(self):
copy(self, "cholmod-conan-cuda-support.cmake", self.recipe_folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand Down Expand Up @@ -66,7 +69,7 @@ def requirements(self):

def validate(self):
if self.options.cuda and not self.options.gpl:
raise ConanInvalidConfiguration("CUDA acceleration requires GPL-licensed modules")
raise ConanInvalidConfiguration("CUDA acceleration requires GPL-licensed modules. Set suitesparse-cholmod/*:gpl=True.")

def build_requirements(self):
self.tool_requires("cmake/[>=3.22 <4]")
Expand Down Expand Up @@ -104,6 +107,8 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.pdb", self.package_folder, recursive=True)
if self.options.cuda:
copy(self, "cholmod-conan-cuda-support.cmake", self.export_sources_folder, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "CHOLMOD")
Expand All @@ -112,6 +117,10 @@ def package_info(self):
self.cpp_info.set_property("cmake_target_aliases", ["SuiteSparse::CHOLMOD_static"])
self.cpp_info.set_property("pkg_config_name", "CHOLMOD")

if self.options.cuda:
self.cpp_info.builddirs.append(os.path.join("lib", "cmake"))
self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "cholmod-conan-cuda-support.cmake")])

self.cpp_info.libs = ["cholmod"]
self.cpp_info.includedirs.append(os.path.join("include", "suitesparse"))

Expand Down

0 comments on commit e4d7ea5

Please sign in to comment.