Skip to content

Commit

Permalink
conanfile.py: set default CUDA architecture to native
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Aug 11, 2023
1 parent f5a2581 commit 2e1fe71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cmake/cuda_architecture_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ function(init_cmake_cuda_architectures)
get_available_cuda_architectures(ALL_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "")
foreach(arch ${ALL_ARCHITECTURES})
list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}-real")
# Skip deprecated 3.x architectures
if (arch GREATER_EQUAL 50)
list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}-real")
endif()
endforeach()
list(GET ALL_ARCHITECTURES -1 latest)
list(APPEND CMAKE_CUDA_ARCHITECTURES "${latest}-virtual")
Expand Down
25 changes: 20 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@ class CupochConan(ConanFile):
default_options = {
"shared": False,
"fPIC": True,
"cuda_architectures": None,
"cuda_architectures": "native",
"use_rmm": True,
}
default_options.update({module: True for module in MODULES})

options_description = {
"shared": "Build shared libraries, static otherwise.",
"fPIC": "Enable position-independent code.",
"cuda_architectures": (
"Sets the CUDA architectures to generate device code for via CMAKE_CUDA_ARCHITECTURES. "
"Generates code for all architectures if set to None."
),
"use_rmm": "Use RAPIDS Memory Manager for memory management.",
}

exports = ["third_party/conan-recipes/*"]
exports_sources = [
"cmake/*",
Expand Down Expand Up @@ -144,6 +154,8 @@ def requirements(self):
self.requires("imgui/1.89.7")

def build_requirements(self):
# For native/all/all-major CUDA architectures support
self.tool_requires("cmake/[>=3.24]")
self.test_requires("gtest/1.13.0")

def layout(self):
Expand Down Expand Up @@ -193,9 +205,10 @@ def build(self):
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "configure_cuda.cmake",
dst=self.package_path / "lib" / "cmake",
src=self.source_path / "cmake")
for cmake_module in ["configure_cuda.cmake", "cuda_architecture_macros.cmake"]:
copy(self, cmake_module,
dst=self.package_path / "lib" / "cmake",
src=self.source_path / "cmake")
copy(self, "LICENSE",
dst=self.package_path / "licenses",
src=self.source_path)
Expand Down Expand Up @@ -264,4 +277,6 @@ def package_info(self):
utility.defines.append("NOMINMAX")

# Export CUDA dependencies and flags
self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "configure_cuda.cmake")])
cmake_dir = Path("lib", "cmake")
self.cpp_info.builddirs.append(cmake_dir)
self.cpp_info.set_property("cmake_build_modules", [cmake_dir / "configure_cuda.cmake"])

0 comments on commit 2e1fe71

Please sign in to comment.