From c06b1537d7b8811ba47457e020c243f3693ab272 Mon Sep 17 00:00:00 2001
From: Praneet Rathi <prrathi10@gmail.com>
Date: Fri, 17 Jan 2025 18:05:56 -0600
Subject: [PATCH] cuda

---
 hercules_cg/src/gpu.rs | 12 ++++++++++--
 hercules_rt/build.rs   |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hercules_cg/src/gpu.rs b/hercules_cg/src/gpu.rs
index 85ee7d90..3e0ae81d 100644
--- a/hercules_cg/src/gpu.rs
+++ b/hercules_cg/src/gpu.rs
@@ -1639,8 +1639,8 @@ extern \"C\" {} {}(", if ret_primitive { ret_type.clone() } else { "void".to_str
             Constant::UnsignedInteger32(val) => write!(w, "{}{} = {}ul;\n", tabs, name, val)?,
             Constant::Integer64(val) => write!(w, "{}{} = {}ll;\n", tabs, name, val)?,
             Constant::UnsignedInteger64(val) => write!(w, "{}{} = {}ull;\n", tabs, name, val)?,
-            Constant::Float32(val) => write!(w, "{}{} = {}f;\n", tabs, name, val)?,
-            Constant::Float64(val) => write!(w, "{}{} = {};\n", tabs, name, val)?,
+            Constant::Float32(val) => write!(w, "{}{} = {}f;\n", tabs, name, format_float(**val as f64))?,
+            Constant::Float64(val) => write!(w, "{}{} = {};\n", tabs, name, format_float(**val))?,
             // All three following collections involve align then allocate from the
             // single dynamic shared memory buffer by using and updating the offset.
             Constant::Product(type_id, constant_fields) => {
@@ -2025,3 +2025,11 @@ fn convert_type(ty: &Type, make_pointer: bool) -> String {
     }
     result
 }
+
+fn format_float(val: f64) -> String {
+    let mut s = val.to_string();
+    if !s.contains('.') && !s.contains('e') && !s.contains('E') {
+        s.push_str(".0");
+    }
+    s
+}
diff --git a/hercules_rt/build.rs b/hercules_rt/build.rs
index 6db177de..04c9ef93 100644
--- a/hercules_rt/build.rs
+++ b/hercules_rt/build.rs
@@ -18,7 +18,7 @@ fn main() {
 
         println!("cargo::rustc-link-search=native={}", out_dir);
         println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
-        println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64");
+        println!("cargo::rustc-link-search=native=/usr/local/cuda/lib64");
         println!("cargo::rustc-link-lib=static=rtdefs");
         println!("cargo::rustc-link-lib=cudart");
         println!("cargo::rerun-if-changed=src/rtdefs.cu");
-- 
GitLab