Skip to content

Commit d1d2e39

Browse files
committed
try to fix an atomic intrinsic problem and add ptxas in builder to validate
1 parent f21da08 commit d1d2e39

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/cuda_builder/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,18 @@ impl CudaBuilder {
366366

367367
let path = invoke_rustc(&self)?;
368368
println!("cargo:warning=Build completed successfully, PTX file generated at: {}", path.display());
369+
370+
// run ptxas on it to validate
371+
// example: ptxas -v -arch=sm_120 /home/brandon/vanity-miner-rs/target/release/build/gpu_runner-34ef728ec383c50f/out/kernels.ptx -o /tmp/temp.cubin
372+
let ptxas_output = Command::new("ptxas")
373+
.arg("-v")
374+
.arg(format!("-arch={}", self.arch.to_string()))
375+
.arg(&path)
376+
.arg("-o")
377+
.arg("/tmp/temp.cubin")
378+
.output()
379+
.expect("Failed to run ptxas");
380+
println!("cargo:warning=PTXAS output: {:?}", ptxas_output);
369381

370382
if let Some(copy_path) = &self.ptx_file_copy_path {
371383
println!("cargo:warning=Copying PTX file from {} to {}", path.display(), copy_path.display());

crates/cuda_std/src/atomic/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ macro_rules! load {
7070
pub unsafe fn [<atomic_load_ $ordering _ $width _ $scope>](ptr: *const [<u $width>]) -> [<u $width>] {
7171
let mut out;
7272
asm!(
73-
concat!("ld.", stringify!($ordering), load_scope!($ordering, $scope), ".", stringify!([<u $width>]), " {}, [{}];"),
73+
concat!("ld.", stringify!($ordering), load_scope!($ordering, $scope_asm), ".", stringify!([<u $width>]), " {}, [{}];"),
7474
out([<reg $width>]) out,
7575
in(reg64) ptr
7676
);
@@ -116,7 +116,7 @@ macro_rules! store {
116116
#[doc = concat!("Performs a ", stringify!($ordering), " atomic store at the ", stringify!($scope), " level with a width of ", stringify!($width), " bits")]
117117
pub unsafe fn [<atomic_store_ $ordering _ $width _ $scope>](ptr: *mut [<u $width>], val: [<u $width>]) {
118118
asm!(
119-
concat!("st.", stringify!($ordering), load_scope!($ordering, $scope), ".", stringify!([<u $width>]), " [{}], {};"),
119+
concat!("st.", stringify!($ordering), load_scope!($ordering, $scope_asm), ".", stringify!([<u $width>]), " [{}], {};"),
120120
in(reg64) ptr,
121121
in([<reg $width>]) val,
122122
);

0 commit comments

Comments
 (0)