From aa79f0181bdc01fc1576349fc6ad2794ae564a03 Mon Sep 17 00:00:00 2001
From: Praneet Rathi <prrathi10@gmail.com>
Date: Fri, 17 Jan 2025 18:23:34 -0600
Subject: [PATCH] cuda woprk?

---
 Cargo.lock                         | 1 -
 hercules_samples/ccp/Cargo.toml    | 3 +++
 hercules_samples/ccp/build.rs      | 7 +++++++
 hercules_samples/dot/Cargo.toml    | 3 +++
 hercules_samples/dot/build.rs      | 7 +++++++
 hercules_samples/matmul/Cargo.toml | 3 +++
 hercules_samples/matmul/build.rs   | 7 +++++++
 juno_build/Cargo.toml              | 3 +--
 8 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 67731f60..ea295fdf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -718,7 +718,6 @@ name = "juno_build"
 version = "0.1.0"
 dependencies = [
  "hercules_ir",
- "hercules_rt",
  "juno_frontend",
  "with_builtin_macros",
 ]
diff --git a/hercules_samples/ccp/Cargo.toml b/hercules_samples/ccp/Cargo.toml
index 3547aa52..a5259a92 100644
--- a/hercules_samples/ccp/Cargo.toml
+++ b/hercules_samples/ccp/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.1.0"
 authors = ["Russel Arbore <rarbore2@illinois.edu>"]
 edition = "2021"
 
+[features]
+cuda = ["juno_build/cuda"]
+
 [build-dependencies]
 juno_build = { path = "../../juno_build" }
 
diff --git a/hercules_samples/ccp/build.rs b/hercules_samples/ccp/build.rs
index f04d48c7..0b984a0f 100644
--- a/hercules_samples/ccp/build.rs
+++ b/hercules_samples/ccp/build.rs
@@ -6,4 +6,11 @@ fn main() {
         .unwrap()
         .build()
         .unwrap();
+
+    #[cfg(feature = "cuda")]
+    println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-lib=cudart");
 }
diff --git a/hercules_samples/dot/Cargo.toml b/hercules_samples/dot/Cargo.toml
index 69cd39e3..9b11ddc1 100644
--- a/hercules_samples/dot/Cargo.toml
+++ b/hercules_samples/dot/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.1.0"
 authors = ["Russel Arbore <rarbore2@illinois.edu>"]
 edition = "2021"
 
+[features]
+cuda = ["juno_build/cuda", "hercules_rt/cuda"]
+
 [build-dependencies]
 juno_build = { path = "../../juno_build" }
 
diff --git a/hercules_samples/dot/build.rs b/hercules_samples/dot/build.rs
index 2a239bc6..43cd34f9 100644
--- a/hercules_samples/dot/build.rs
+++ b/hercules_samples/dot/build.rs
@@ -6,4 +6,11 @@ fn main() {
         .unwrap()
         .build()
         .unwrap();
+
+    #[cfg(feature = "cuda")]
+    println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-lib=cudart");
 }
diff --git a/hercules_samples/matmul/Cargo.toml b/hercules_samples/matmul/Cargo.toml
index 9066c153..49f05f29 100644
--- a/hercules_samples/matmul/Cargo.toml
+++ b/hercules_samples/matmul/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.1.0"
 authors = ["Russel Arbore <rarbore2@illinois.edu>"]
 edition = "2021"
 
+[features]
+cuda = ["juno_build/cuda", "hercules_rt/cuda"]
+
 [build-dependencies]
 juno_build = { path = "../../juno_build" }
 
diff --git a/hercules_samples/matmul/build.rs b/hercules_samples/matmul/build.rs
index 08478dea..b170024b 100644
--- a/hercules_samples/matmul/build.rs
+++ b/hercules_samples/matmul/build.rs
@@ -6,4 +6,11 @@ fn main() {
         .unwrap()
         .build()
         .unwrap();
+
+    #[cfg(feature = "cuda")]
+    println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64");
+    #[cfg(feature = "cuda")]
+    println!("cargo:rustc-link-lib=cudart");
 }
diff --git a/juno_build/Cargo.toml b/juno_build/Cargo.toml
index 67b5bd7e..13889171 100644
--- a/juno_build/Cargo.toml
+++ b/juno_build/Cargo.toml
@@ -5,10 +5,9 @@ authors = ["Aaron Councilman <aaronjc4@illinois.edu>"]
 edition = "2021"
 
 [features]
-cuda = ["juno_frontend/cuda", "hercules_rt/cuda"]
+cuda = ["juno_frontend/cuda"]
 
 [dependencies]
 juno_frontend = { path = "../juno_frontend" }
-hercules_rt = { path = "../hercules_rt", optional = true }
 hercules_ir = { path = "../hercules_ir" }
 with_builtin_macros = "0.1.0"
-- 
GitLab