Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(add cuda-12080) #329

Merged
merged 1 commit into from
Feb 14, 2025
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
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ documentation = "https://docs.rs/cudarc"
repository = "https://github.com/coreylowman/cudarc"
readme = "README.md"

keywords = [
"cuda",
"nvidia",
"gpu",
"nvrtc",
"cublas",
]
keywords = ["cuda", "nvidia", "gpu", "nvrtc", "cublas"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package.metadata.docs.rs]
features = ["cuda-12060", "f16", "cudnn"]
features = ["cuda-12080", "f16", "cudnn"]

[features]
default = ["std", "cublas", "cublaslt", "curand", "driver", "runtime", "nvrtc"]
Expand All @@ -39,6 +33,7 @@ cuda-12030 = []
cuda-12040 = []
cuda-12050 = []
cuda-12060 = []
cuda-12080 = []

dynamic-linking = []

Expand All @@ -56,7 +51,12 @@ no-std = ["no-std-compat/std", "dep:spin"]
f16 = ["dep:half"]

[dependencies]
spin = { version = "0.9.8", optional = true, features = ["rwlock"], default-features = false }
no-std-compat = { version = "0.4.1", optional = true, features = [ "alloc" ] }
half = { version = "2.4.1", optional = true, default-features = false, features = ["num-traits", "rand_distr"] }
spin = { version = "0.9.8", optional = true, features = [
"rwlock",
], default-features = false }
no-std-compat = { version = "0.4.1", optional = true, features = ["alloc"] }
half = { version = "2.4.1", optional = true, default-features = false, features = [
"num-traits",
"rand_distr",
] }
libloading = "0.8.5"
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ fn main() {
println!("cargo:rerun-if-env-changed=CUDA_PATH");
println!("cargo:rerun-if-env-changed=CUDA_TOOLKIT_ROOT_DIR");

let (major, minor): (usize, usize) = if cfg!(feature = "cuda-12060") {
let (major, minor): (usize, usize) = if cfg!(feature = "cuda-12080") {
(12, 8)
} else if cfg!(feature = "cuda-12060") {
(12, 6)
} else if cfg!(feature = "cuda-12050") {
(12, 5)
Expand All @@ -32,7 +34,7 @@ fn main() {
(11, 4)
} else {
#[cfg(not(feature = "cuda-version-from-build-system"))]
panic!("Must specify one of the following features: [cuda-version-from-build-system, cuda-12060, cuda-12050, cuda-12040, cuda-12030, cuda-12020, cuda-12010, cuda-12000, cuda-11080, cuda-11070, cuda-11060, cuda-11050, cuda-11040]");
panic!("Must specify one of the following features: [cuda-version-from-build-system, cuda-12080, cuda-12060, cuda-12050, cuda-12040, cuda-12030, cuda-12020, cuda-12010, cuda-12000, cuda-11080, cuda-11070, cuda-11060, cuda-11050, cuda-11040]");

#[cfg(feature = "cuda-version-from-build-system")]
{
Expand Down Expand Up @@ -70,6 +72,7 @@ fn cuda_version_from_build_system() -> (usize, usize) {
let version_number = release_section.split(' ').nth(1).unwrap();

match version_number {
"12.8" => (12, 8),
"12.6" => (12, 6),
"12.5" => (12, 5),
"12.4" => (12, 4),
Expand Down
13 changes: 11 additions & 2 deletions run-bindgen.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
if [ -z "${CUDA_ROOT}" ]; then
CUDA_DIR=$CUDA_ROOT
elif [ -d "/opt/cuda" ]; then
CUDA_DIR="/opt/cuda"
else
CUDA_DIR="/usr/local/cuda"
fi

export CUDA_INCLUDES="${CUDA_DIR}/include"

declare -a modules=("cublas" "cublaslt" "cudnn" "curand" "driver" "runtime" "nccl" "nvrtc")
for path in "${modules[@]}"
do
for path in "${modules[@]}"; do
cd src/${path}/sys
bash bindgen.sh
cd ../../../
Expand Down
26 changes: 13 additions & 13 deletions src/cublas/sys/bindgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
set -exu

bindgen \
--allowlist-var="^CUDA_VERSION" \
--allowlist-type="^cublas.*" \
--allowlist-function="^cublas.*" \
--default-enum-style=rust \
--no-doc-comments \
--with-derive-default \
--with-derive-eq \
--with-derive-hash \
--with-derive-ord \
--use-core \
--dynamic-loading Lib \
wrapper.h -- -I/usr/local/cuda/include \
> tmp.rs
--allowlist-var="^CUDA_VERSION" \
--allowlist-type="^cublas.*" \
--allowlist-function="^cublas.*" \
--default-enum-style=rust \
--no-doc-comments \
--with-derive-default \
--with-derive-eq \
--with-derive-hash \
--with-derive-ord \
--use-core \
--dynamic-loading Lib \
wrapper.h -- -I$CUDA_INCLUDES \
>tmp.rs

CUDA_VERSION=$(cat tmp.rs | grep "CUDA_VERSION" | awk '{ print $6 }' | sed 's/.$//')
mv tmp.rs sys_${CUDA_VERSION}.rs
5 changes: 5 additions & 0 deletions src/cublas/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ mod sys_12060;
#[cfg(feature = "cuda-12060")]
pub use sys_12060::*;

#[cfg(feature = "cuda-12080")]
mod sys_12080;
#[cfg(feature = "cuda-12080")]
pub use sys_12080::*;

pub unsafe fn lib() -> &'static Lib {
static LIB: std::sync::OnceLock<Lib> = std::sync::OnceLock::new();
LIB.get_or_init(|| {
Expand Down
Loading
Loading