Skip to content
41 changes: 22 additions & 19 deletions C/cufinufft/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl"))
include(joinpath(YGGDRASIL_DIR, "platforms", "cuda.jl"))

# Build script for the CUDA part of FINUFFT

# Builds for all compatible CUDA platforms, but without microarchitecture expansion (not
# needed for CUDA cuda, and would produce a giant amount of artifacts)

name = "cufinufft"
version = v"2.4.1"
commit_hash = "e7144a5c08cbaf3e3b344a4fdd92bc3c7e468ff2" # v2.4.1
version = v"2.5.0"
commit_hash = "8b7ac66e617ea317cd42366ac27c536793131696"
preferred_gcc_version=v"11"

# Collection of sources required to complete build
Expand All @@ -24,8 +24,10 @@ sources = [
# Build script: cufinufft, all possible archs available for each CUDA version
# - CMake toolchain looks for compiler in CUDA_PATH/bin/nvcc
# and libs in CUDA_PATH/lib64, so create link.
# - Need higher version of CMake, so remove existing
script = raw"""
cd $WORKSPACE/srcdir/finufft*/
apk del cmake

export CUDA_PATH="$prefix/cuda"
ln -s $prefix/cuda/lib $prefix/cuda/lib64
Expand All @@ -47,25 +49,22 @@ cmake --install .
unlink $prefix/cuda/lib64
"""

# Build for all supported CUDA > v11
platforms = expand_cxxstring_abis(CUDA.supported_platforms(min_version=v"11.0"))
# Build for all supported CUDA >= v11.8. Only one v11.x should be sufficient.
platforms = expand_cxxstring_abis(CUDA.supported_platforms(min_version=v"11.8"))

# Cmake toolchain breaks on aarch64, so only x86_64 for now
filter!(p -> arch(p)=="x86_64", platforms)

# cuFINUFFT does not compile with CUDA 12.5, so exclude
filter!(p -> VersionNumber(p["cuda"]) != v"12.5", platforms)

# CUDA 13 doesn't seem to build (yet)
filter!(p -> VersionNumber(p["cuda"]) < v"13", platforms)

# The products that we will ensure are always built
products = [
LibraryProduct("libcufinufft", :libcufinufft)
]

# Dependencies that must be installed before this package can be built
# NVTX_jll is needed for nvToolsExt. (tested with v3.1.0+2)
dependencies = [Dependency("NVTX_jll")]
# CMake needs higher version than what is bundled
dependencies = [Dependency("NVTX_jll"),
HostBuildDependency(PackageSpec(; name="CMake_jll", version = v"3.24.3+0"))]

for platform in platforms
should_build_platform(triplet(platform)) || continue
Expand All @@ -75,14 +74,18 @@ for platform in platforms

# Build for all major archs supported by SDK
# See https://en.wikipedia.org/wiki/CUDA
# sm_90 works for CUDA v12.1 and up, due to use of atomic operaitons
# sm_52 required for alloca from CUDA v12.0 and up
if VersionNumber(platform["cuda"]) < v"12.0"
cuda_archs = "50;60;70;80"
elseif VersionNumber(platform["cuda"]) < v"12.1"
cuda_archs = "60;70;80"
else
cuda_ver = VersionNumber(platform["cuda"])
if cuda_ver >= v"13" # 13.0+
# Skip 110,121 to not run out of space
cuda_archs = "75;80;90;100;120"
elseif cuda_ver >= v"12.1" # 12.1-12.9
# sm_90 works for CUDA v12.1 and up, due to use of atomic operations
cuda_archs = "60;70;80;90"
elseif cuda_ver >= v"12.0" # 12.0
# sm_52 required for alloca from CUDA v12.0 and up
cuda_archs = "60;70;80"
else # < 12.0
cuda_archs = "50;60;70;80"
end
arch_line = "export CUDA_ARCHS=\"$cuda_archs\"\n"
platform_script = arch_line * script
Expand Down