Skip to content

Commit

Permalink
Initial cuda support
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekvpandya committed Feb 27, 2024
1 parent 7a3b7d4 commit 0ffdb10
Show file tree
Hide file tree
Showing 18 changed files with 2,381 additions and 14 deletions.
13 changes: 13 additions & 0 deletions cuda/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "plonky2-cuda"
version = "0.1.0"
authors = ["Mozak"]
description = "GPU acceleration for plonky2"
edition = "2021"

[build-dependencies.cc]
version = "^1.0.70"

[build-dependencies.which]
version = "^4.0"

26 changes: 26 additions & 0 deletions cuda/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::{env};

fn main() {

// Detect if there is CUDA compiler and engage "cuda" feature accordingly
let nvcc = match env::var("NVCC") {
Ok(var) => which::which(var),
Err(_) => which::which("nvcc"),
};

if nvcc.is_ok() {
let mut nvcc = cc::Build::new();
nvcc.cuda(true);
nvcc.flag("-g");
nvcc.flag("-O5");
nvcc.flag("-arch=sm_75");
nvcc.flag("-maxrregcount=255");
nvcc.file("plonky2_gpu.cu").compile("plonky2_cuda");

println!("cargo:rustc-cfg=feature=\"cuda\"");
println!("cargo:rerun-if-changed=cuda");
println!("cargo:rerun-if-env-changed=CXXFLAGS");
} else {
println!("nvcc must be in the path. Consider adding /usr/local/cuda/bin.");
}
}
309 changes: 309 additions & 0 deletions cuda/constants.cuh

Large diffs are not rendered by default.

Loading

0 comments on commit 0ffdb10

Please sign in to comment.