Skip to content
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
64 changes: 0 additions & 64 deletions .github/vcpkg-overlays/libaec/portfile.cmake

This file was deleted.

7 changes: 0 additions & 7 deletions .github/vcpkg-overlays/libaec/usage

This file was deleted.

17 changes: 0 additions & 17 deletions .github/vcpkg-overlays/libaec/vcpkg.json

This file was deleted.

6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ jobs:
if: ${{ matrix.os == 'windows-latest' && steps.vcpkg-installed-cache.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
# The libaec overlay sources that port from GitHub instead of
# gitlab.dkrz.de, whose archive endpoint returns 429 to everyone.
# See .github/vcpkg-overlays/libaec/portfile.cmake.
./vcpkg/vcpkg install --triplet x64-windows `
--overlay-ports="${{ github.workspace }}/.github/vcpkg-overlays"
./vcpkg/vcpkg install --triplet x64-windows

- name: 🏗️ Compile (Windows)
if: ${{ matrix.os == 'windows-latest' }}
Expand Down
27 changes: 16 additions & 11 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ jobs:
if: ${{ matrix.os == 'windows-latest' && steps.vcpkg-installed-cache.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
# The libaec overlay sources that port from GitHub instead of
# gitlab.dkrz.de, whose archive endpoint returns 429 to everyone.
# See .github/vcpkg-overlays/libaec/portfile.cmake.
./vcpkg/vcpkg install --triplet x64-windows `
--overlay-ports="${{ github.workspace }}/.github/vcpkg-overlays"
./vcpkg/vcpkg install --triplet x64-windows

- name: 🐍 Build and check Python Module (Windows)
if: ${{ matrix.os == 'windows-latest' }}
Expand Down Expand Up @@ -157,21 +153,30 @@ jobs:
env:
CIBW_SKIP: ${{ matrix.skip }}
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/viennatools/vienna-builder:cuda-python
# The CUDA libraries are far too large to vendor (libcusparse alone is
# >160 MB, over the PyPI file limit), so they are left unbundled.
# That is safe here only because _core.so does not link them: they are
# needed solely by libViennaLS_GPU.so, which ViennaLS dlopen()s on
# demand and does without when it cannot be loaded. Keep it that way —
# linking CUDA into _core.so is what broke the 5.8.3 wheel.
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >-
auditwheel repair
--exclude libcuda.so.1
--exclude libcudart.so.12
--exclude libcusparse.so.12
--exclude libnvJitLink.so.12
-w {dest_dir} {wheel}
CIBW_TEST_COMMAND: >-
python -c "import viennals;
print(viennals.__file__);
print(viennals.d2);
print(viennals.d3)"
# VIENNALS_USE_GPU is deliberately OFF for wheels: it puts hard
# DT_NEEDED entries for libcudart/libcusparse on _core.so, and those
# are far too large to vendor (libcusparse alone is >160 MB, over the
# PyPI file limit). The wheel would then fail to import on any machine
# without a CUDA toolkit. GPU users build from source with
# -DVIENNALS_USE_GPU=ON.
CIBW_CONFIG_SETTINGS: >-
cmake.define.VIENNALS_PACKAGE_PYTHON=ON
cmake.define.VIENNALS_IS_CI=ON
cmake.define.VIENNALS_VTK_RENDERING=ON
cmake.define.VIENNALS_USE_GPU=ON
cmake.define.VIENNACORE_LINK_CUDA_DRIVER=OFF
cmake.define.USE_IPO=OFF

- name: 🏗️ Build Wheels (Other)
Expand Down
46 changes: 31 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaLS
LANGUAGES CXX
VERSION 5.8.4)
VERSION 5.8.5)

# --------------------------------------------------------------------------------------------------------
# Library options
Expand Down Expand Up @@ -158,9 +158,16 @@ if(VIENNALS_USE_GPU)
"[ViennaLS] cuSPARSE not found in CUDA ${CUDAToolkit_VERSION}; disabling GPU BiCGSTAB solver."
)
else()
# Compile the CUDA kernels into a small static library so that consuming
# .cpp files (compiled by g++) never see __global__ / <<< >>> syntax.
add_library(ViennaLS_GPU STATIC ${PROJECT_SOURCE_DIR}/gpu/lsOxidationBiCGSTABKernels.cu)
# Compile the CUDA kernels into a SHARED library so that consuming .cpp
# files (compiled by g++) never see __global__ / <<< >>> syntax, and — just
# as importantly — so that this is the *only* binary linking CUDA.
#
# It is deliberately not linked into ViennaLS. ViennaLS opens it lazily with
# dlopen() at first use (see lsOxidationBiCGSTABInterface.hpp). Linking it
# would put DT_NEEDED entries for libcudart/libcusparse onto every consumer,
# and the dynamic loader would then refuse to load ViennaLS at all on a
# machine with no CUDA runtime — which is what broke the 5.8.3 PyPI wheel.
add_library(ViennaLS_GPU SHARED ${PROJECT_SOURCE_DIR}/gpu/lsOxidationBiCGSTABKernels.cu)

target_compile_definitions(ViennaLS_GPU PRIVATE VIENNALS_GPU_BICGSTAB=1)

Expand All @@ -170,28 +177,37 @@ if(VIENNALS_USE_GPU)
set_target_properties(ViennaLS_GPU PROPERTIES CUDA_SEPARABLE_COMPILATION OFF
POSITION_INDEPENDENT_CODE ON)

target_link_libraries(ViennaLS_GPU PUBLIC CUDA::cudart CUDA::cusparse)
target_link_libraries(ViennaLS_GPU PRIVATE CUDA::cudart CUDA::cusparse)

if(UNIX AND NOT APPLE)
# A locally built library has to find the CUDA runtime, which often lives
# outside the default loader search path (e.g. /usr/local/cuda/lib64).
# Wheel builds skip this: auditwheel rewrites RPATHs, and a build-machine
# path baked into a redistributable wheel would be meaningless anyway.
if(UNIX
AND NOT APPLE
AND NOT VIENNALS_PACKAGE_PYTHON)
set(_VIENNALS_CUDA_RPATHS)
foreach(_VIENNALS_CUDA_TARGET CUDA::cudart CUDA::cusparse)
get_target_property(_VIENNALS_CUDA_LIBRARY ${_VIENNALS_CUDA_TARGET} IMPORTED_LOCATION)
if(_VIENNALS_CUDA_LIBRARY)
get_filename_component(_VIENNALS_CUDA_LIBRARY_DIR "${_VIENNALS_CUDA_LIBRARY}" DIRECTORY)
target_link_options(ViennaLS_GPU INTERFACE
"$<BUILD_INTERFACE:LINKER:-rpath,${_VIENNALS_CUDA_LIBRARY_DIR}>")
list(APPEND _VIENNALS_CUDA_RPATHS "${_VIENNALS_CUDA_LIBRARY_DIR}")
endif()
endforeach()
list(REMOVE_DUPLICATES _VIENNALS_CUDA_RPATHS)
set_target_properties(ViennaLS_GPU PROPERTIES BUILD_RPATH "${_VIENNALS_CUDA_RPATHS}"
INSTALL_RPATH "${_VIENNALS_CUDA_RPATHS}")
endif()

# Expose the define and the GPU library to downstream targets.
# BUILD_INTERFACE limits the ViennaLS_GPU dependency to the build tree so it
# is never exported to the install tree (avoiding the "not in export set" error
# from packageProject when ViennaLS_GPU is a non-installed local target).
# Expose only the define to downstream targets — never the GPU library and
# never the CUDA include dirs. The dispatch layer needs nothing from the
# CUDA headers; it talks to ViennaLS_GPU through the plain C ABI in
# lsOxidationBiCGSTABAbi.hpp. Consumers do need the dl functions.
target_compile_definitions(${PROJECT_NAME} INTERFACE VIENNALS_GPU_BICGSTAB=1)
target_link_libraries(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:ViennaLS_GPU>)
target_include_directories(${PROJECT_NAME} INTERFACE ${CUDAToolkit_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} INTERFACE ${CMAKE_DL_LIBS})

message(STATUS "[ViennaLS] GPU BiCGSTAB solver enabled (CUDA ${CUDAToolkit_VERSION})")
message(STATUS "[ViennaLS] GPU BiCGSTAB solver enabled (CUDA ${CUDAToolkit_VERSION}, "
"loaded at runtime)")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum

* Installation with CPM
```cmake
CPMAddPackage("gh:viennatools/viennals@5.8.4")
CPMAddPackage("gh:viennatools/viennals@5.8.5")
```

* With a local installation
Expand Down
Loading