From 381453c19184e385e22c388487368575b47df6d8 Mon Sep 17 00:00:00 2001 From: Jason Ramapuram Date: Mon, 20 Jul 2015 19:22:32 +0200 Subject: [PATCH 1/3] add ability to specify lib directory on os's where it is not lib64 --- build.conf | 8 +++++--- build.rs | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build.conf b/build.conf index 586669218..68d9fa4d7 100644 --- a/build.conf +++ b/build.conf @@ -12,7 +12,7 @@ "build_cpu": "ON", "build_examples": "OFF", "build_test": "OFF", - "build_graphics": "OFF", + "build_graphics": "OFF", "glew_static": "OFF", "freeimage_type": "DYNAMIC", @@ -28,6 +28,8 @@ "glew_dir": "E:\\Libraries\\GLEW", "glfw_dir": "E:\\Libraries\\glfw3", "boost_dir": "E:\\Libraries\\boost_1_56_0", - "cuda_sdk": "/opt/cuda", - "opencl_sdk": "/opt/cuda" + + "cuda_sdk": "/usr/local/cuda", + "opencl_sdk": "/usr", + "sdk_lib_dir": "lib" } diff --git a/build.rs b/build.rs index caf5aded1..f074ddf0a 100644 --- a/build.rs +++ b/build.rs @@ -48,8 +48,11 @@ struct Config { glew_dir: String, glfw_dir: String, boost_dir: String, + + // GPU backends cuda_sdk: String, opencl_sdk: String, + sdk_lib_dir: String, } macro_rules! t { @@ -348,8 +351,8 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec, backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk)); backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk)); } else { - backend_dirs.push(format!("{}/lib64", conf.cuda_sdk)); - backend_dirs.push(format!("{}/nvvm/lib64", conf.cuda_sdk)); + backend_dirs.push(format!("{}/{}", conf.cuda_sdk, conf.sdk_lib_dir)); + backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, conf.sdk_lib_dir)); } } else if conf.use_backend == "opencl" { backends.push(("afopencl".to_string())); @@ -357,7 +360,7 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec, if cfg!(windows) { backend_dirs.push(format!("{}\\lib\\x64", conf.opencl_sdk)); } else { - backend_dirs.push(format!("{}/lib64", conf.opencl_sdk)); + backend_dirs.push(format!("{}/{}", conf.opencl_sdk, conf.sdk_lib_dir)); } } From 3a4f23a669646a6a5adba0b5ecbff0cd9148390c Mon Sep 17 00:00:00 2001 From: Jason Ramapuram Date: Mon, 20 Jul 2015 19:25:51 +0200 Subject: [PATCH 2/3] fix in preparation for rust 1.3 --- src/data/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/mod.rs b/src/data/mod.rs index b0ee8e4de..e6904aae4 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -121,7 +121,7 @@ macro_rules! cnst { fn generate(&self, dims: Dim4) -> Array { unsafe { let mut temp: i64 = 0; - af_constant(&mut temp as MutAfArray, *self as c_double, + af_constant(&mut temp as MutAfArray, *self as u64 as c_double, dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT, $ffi_type); Array::from(temp) From 58c489e94205f8e00eafcf0fae5bf8b8ac383355 Mon Sep 17 00:00:00 2001 From: Jason Ramapuram Date: Mon, 20 Jul 2015 20:19:38 +0200 Subject: [PATCH 3/3] specialize bool --- src/data/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/data/mod.rs b/src/data/mod.rs index e6904aae4..2f57b437a 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -114,6 +114,18 @@ impl ConstGenerator for Complex { } } +#[allow(unused_mut)] +impl ConstGenerator for bool { + fn generate(&self, dims: Dim4) -> Array { + unsafe { + let mut temp: i64 = 0; + af_constant(&mut temp as MutAfArray, *self as c_int as c_double, + dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT, 4); + Array::from(temp) + } + } +} + macro_rules! cnst { ($rust_type:ty, $ffi_type:expr) => ( #[allow(unused_mut)] @@ -121,7 +133,7 @@ macro_rules! cnst { fn generate(&self, dims: Dim4) -> Array { unsafe { let mut temp: i64 = 0; - af_constant(&mut temp as MutAfArray, *self as u64 as c_double, + af_constant(&mut temp as MutAfArray, *self as c_double, dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT, $ffi_type); Array::from(temp) @@ -133,7 +145,6 @@ macro_rules! cnst { cnst!(f32 , 0); cnst!(f64 , 2); -cnst!(bool, 4); cnst!(i32 , 5); cnst!(u32 , 6); cnst!(u8 , 7);