Skip to content

Commit f50708b

Browse files
committed
support sm_100 and llvm v19
1 parent caaef11 commit f50708b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+19339
-10
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ exclude = [
2222
"crates/optix/examples/common",
2323
]
2424

25-
[profile.dev.package.rustc_codegen_nvvm]
25+
[profile.dev.package.rustc_codegen_nvvm_v7]
26+
opt-level = 3
27+
28+
[profile.dev.package.rustc_codegen_nvvm_v19]
2629
opt-level = 3

container/ubuntu22-cuda12/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04
1+
FROM nvidia/cuda:12.9.0-cudnn-devel-ubuntu22.04
22

33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
44
build-essential \

container/ubuntu24-cuda12/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04
1+
FROM nvidia/cuda:12.9.0-cudnn-devel-ubuntu24.04
22

33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
44
build-essential \

crates/cuda_builder/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ repository = "https://github.com/Rust-GPU/Rust-CUDA"
99
readme = "../../README.md"
1010

1111
[dependencies]
12-
rustc_codegen_nvvm = { version = "0.3", path = "../rustc_codegen_nvvm" }
12+
rustc_codegen_nvvm_v7 = { version = "0.3", path = "../rustc_codegen_nvvm_v7" }
13+
rustc_codegen_nvvm_v19 = { version = "0.3", path = "../rustc_codegen_nvvm_v19" }
1314
nvvm = { path = "../nvvm", version = "0.1" }
1415
serde = { version = "1.0.217", features = ["derive"] }
1516
serde_json = "1.0.138"

crates/cuda_std/src/cfg.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ pub enum ComputeCapability {
1616
Compute72,
1717
Compute75,
1818
Compute80,
19+
Compute86,
20+
Compute87,
21+
Compute89,
22+
Compute90,
23+
Compute100
1924
}
2025

2126
impl ComputeCapability {
@@ -42,6 +47,11 @@ impl ComputeCapability {
4247
"720" => ComputeCapability::Compute72,
4348
"750" => ComputeCapability::Compute75,
4449
"800" => ComputeCapability::Compute80,
50+
"860" => ComputeCapability::Compute86, // Ampere (RTX 30 series, A100)
51+
"870" => ComputeCapability::Compute87, // Ampere (Jetson AGX Orin)
52+
"890" => ComputeCapability::Compute89, // Ada Lovelace (RTX 40 series)
53+
"900" => ComputeCapability::Compute90, // Hopper (H100)
54+
"1000" => ComputeCapability::Compute100, // Blackwell (RTX 50 series, H200, B100)
4555
_ => panic!("CUDA_ARCH had an invalid value"),
4656
}
4757
}

crates/cust/src/module.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ pub enum JitTarget {
5656
Compute75 = 75,
5757
Compute80 = 80,
5858
Compute86 = 86,
59+
Compute87 = 87,
60+
Compute89 = 89,
61+
Compute90 = 90,
62+
Compute100 = 100,
5963
}
6064

6165
/// How to handle cases where a loaded module's data does not contain an exact match for the

crates/nvvm/src/lib.rs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{
44
ffi::{CStr, CString},
55
fmt::Display,
66
mem::MaybeUninit,
7-
ptr::null_mut,
87
str::FromStr,
98
};
109

@@ -255,6 +254,11 @@ impl FromStr for NvvmOption {
255254
"72" => NvvmArch::Compute72,
256255
"75" => NvvmArch::Compute75,
257256
"80" => NvvmArch::Compute80,
257+
"86" => NvvmArch::Compute86,
258+
"87" => NvvmArch::Compute87,
259+
"89" => NvvmArch::Compute89,
260+
"90" => NvvmArch::Compute90,
261+
"100" => NvvmArch::Compute100,
258262
_ => return Err("unknown arch"),
259263
};
260264
Self::Arch(arch)
@@ -279,6 +283,11 @@ pub enum NvvmArch {
279283
Compute72,
280284
Compute75,
281285
Compute80,
286+
Compute86,
287+
Compute87,
288+
Compute89,
289+
Compute90,
290+
Compute100,
282291
}
283292

284293
impl Display for NvvmArch {
@@ -403,8 +412,21 @@ impl NvvmProgram {
403412

404413
/// Verify the program without actually compiling it. In the case of invalid IR, you can find
405414
/// more detailed error info by calling [`compiler_log`](Self::compiler_log).
406-
pub fn verify(&self) -> Result<(), NvvmError> {
407-
unsafe { nvvm_sys::nvvmVerifyProgram(self.raw, 0, null_mut()).to_result() }
415+
pub fn verify(&self, options: &[NvvmOption]) -> Result<(), NvvmError> {
416+
let option_strings: Vec<_> = options.iter().map(|opt| opt.to_string()).collect();
417+
let option_cstrings: Vec<_> = option_strings.iter()
418+
.map(|s| std::ffi::CString::new(s.as_str()).unwrap())
419+
.collect();
420+
let mut option_ptrs: Vec<_> = option_cstrings.iter()
421+
.map(|cs| cs.as_ptr())
422+
.collect();
423+
unsafe {
424+
nvvm_sys::nvvmVerifyProgram(
425+
self.raw,
426+
option_ptrs.len() as i32,
427+
option_ptrs.as_mut_ptr()
428+
).to_result()
429+
}
408430
}
409431
}
410432

@@ -433,6 +455,11 @@ mod tests {
433455
"-arch=compute_72",
434456
"-arch=compute_75",
435457
"-arch=compute_80",
458+
"-arch=compute_86",
459+
"-arch=compute_87",
460+
"-arch=compute_89",
461+
"-arch=compute_90",
462+
"-arch=compute_100",
436463
"-ftz=1",
437464
"-prec-sqrt=0",
438465
"-prec-div=0",
@@ -454,6 +481,11 @@ mod tests {
454481
Arch(Compute72),
455482
Arch(Compute75),
456483
Arch(Compute80),
484+
Arch(Compute86),
485+
Arch(Compute87),
486+
Arch(Compute89),
487+
Arch(Compute90),
488+
Arch(Compute100),
457489
Ftz,
458490
FastSqrt,
459491
FastDiv,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[package]
2+
name = "rustc_codegen_nvvm_v19"
3+
version = "0.3.0"
4+
authors = [
5+
"Riccardo D'Ambrosio <[email protected]>",
6+
"The Rust Project Developers",
7+
]
8+
edition = "2024"
9+
license = "MIT OR Apache-2.0"
10+
description = "A codegen backend for Rustc which targets the libnvvm CUDA library"
11+
repository = "https://github.com/Rust-GPU/Rust-CUDA"
12+
readme = "../../README.md"
13+
14+
[lib]
15+
crate-type = ["dylib"]
16+
17+
[dependencies]
18+
nvvm = { version = "0.1", path = "../nvvm" }
19+
rustc-demangle = "0.1.24"
20+
libc = "0.2.169"
21+
libloading = "0.8.0"
22+
tar = "0.4.43"
23+
object = "0.36.7"
24+
bitflags = "2.8.0"
25+
# To avoid duplicate dependencies, this should match the version of gimli used
26+
# by `rustc_codegen_ssa` via its `thorin-dwp` dependency.
27+
gimli = "0.30"
28+
tracing = { version = "0.1.41", features = ["release_max_level_debug"] }
29+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
30+
rustc_codegen_nvvm_macros = { version = "0.1", path = "../rustc_codegen_nvvm_macros" }
31+
smallvec = { version = "1.14.0", features = ["union", "may_dangle"] }
32+
itertools = "0.14.0"
33+
34+
[build-dependencies]
35+
build-helper = "0.1.1"
36+
cc = { version = "1.0", features = ["parallel"] }
37+
xz = "0.1.0"
38+
tar = "0.4.37"
39+
curl = "0.4.40"
40+
41+
[package.metadata.rust-analyzer]
42+
rustc_private = true

0 commit comments

Comments
 (0)