From a46e59bdb229522dada3db4ca69298684fb708ff Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Sun, 5 Jun 2016 13:27:48 +0000 Subject: [PATCH 1/2] Remove time dependency & try bump libc I'm not on a system capable of testing, but currently our own dependency causes cargo to pull down both libc 0.1 & 0.2. We should update to libc 0.2 to combine dependencies. time is deprecated in favor of std::time --- Cargo.toml | 3 +-- examples/pi.rs | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 39b661d74..cbed52650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,8 @@ exclude = [ ] [dependencies] -libc = "0.1.10" +libc = "0.2" num = "0.1.27" -time = "0.1.32" lazy_static = "0.2.1" [build-dependencies] diff --git a/examples/pi.rs b/examples/pi.rs index a32b94c63..5fe1c79e4 100644 --- a/examples/pi.rs +++ b/examples/pi.rs @@ -1,8 +1,7 @@ #[macro_use(mem_info)] extern crate arrayfire as af; -extern crate time; -use time::PreciseTime; +use std::time::Instant; use af::*; #[allow(unused_must_use)] @@ -16,7 +15,7 @@ fn main() { let x = &randu::(dims); let y = &randu::(dims); - let start = PreciseTime::now(); + let start = Instant::now(); mem_info!("Before benchmark"); @@ -30,9 +29,7 @@ fn main() { let pi_val = real*4.0/(samples as f64); } - let end = PreciseTime::now(); - - println!("Estimated Pi Value in {} seconds", start.to(end) / 100); + println!("Estimated Pi Value in {:?}", start.elapsed()); mem_info!("After benchmark"); } From a781bffb1b8d3dfb3d7ba3fe2f8315a80c73cd73 Mon Sep 17 00:00:00 2001 From: pradeep Date: Mon, 6 Jun 2016 09:53:55 +0530 Subject: [PATCH 2/2] Replace u64 with usize type in device module fns --- src/device/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/device/mod.rs b/src/device/mod.rs index f8dfd57ea..250b2fbb5 100644 --- a/src/device/mod.rs +++ b/src/device/mod.rs @@ -131,12 +131,12 @@ pub fn get_device() -> i32 { /// * Number of buffers allocated /// * Number of bytes locked /// * Number of buffers locked -pub fn device_mem_info() -> (u64, u64, u64, u64) { +pub fn device_mem_info() -> (usize, usize, usize, usize) { unsafe { - let mut o0: u64 = 0; - let mut o1: u64 = 0; - let mut o2: u64 = 0; - let mut o3: u64 = 0; + let mut o0: usize = 0; + let mut o1: usize = 0; + let mut o2: usize = 0; + let mut o3: usize = 0; let err_val = af_device_mem_info(&mut o0 as *mut size_t, &mut o1 as *mut size_t, &mut o2 as *mut size_t, @@ -181,7 +181,7 @@ pub fn print_mem_info(msg: String, device: i32) { /// # Return Values /// /// None -pub fn set_mem_step_size(step_bytes: u64) { +pub fn set_mem_step_size(step_bytes: usize) { unsafe { let err_val = af_set_mem_step_size(step_bytes as size_t); HANDLE_ERROR(AfError::from(err_val)); @@ -197,9 +197,9 @@ pub fn set_mem_step_size(step_bytes: u64) { /// # Return Values /// /// Returns is the size of minimum memory chunk in bytes -pub fn get_mem_step_size() -> u64 { +pub fn get_mem_step_size() -> usize { unsafe { - let mut temp: u64 = 0; + let mut temp: usize = 0; let err_val = af_get_mem_step_size(&mut temp as *mut size_t); HANDLE_ERROR(AfError::from(err_val)); temp @@ -228,4 +228,4 @@ pub fn sync(device: i32) { let err_val = af_sync(device as c_int); HANDLE_ERROR(AfError::from(err_val)); } -} \ No newline at end of file +}