diff --git a/hercules_cg/src/gpu.rs b/hercules_cg/src/gpu.rs index 85ee7d90f8e69e74a079c32816a5bf27be764f5b..3e0ae81dac796a85361a4df88067792655df581f 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 6db177de459db63a9a2cb173cf719a912573d352..04c9ef93e45a64fc07d55349b6b0eee33cde4bba 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");