Skip to content

Commit

Permalink
Merge branch 'serprex-devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
9prady9 committed Jun 6, 2016
2 parents 895e4e5 + a781bff commit dc2a7ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 3 additions & 6 deletions examples/pi.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -16,7 +15,7 @@ fn main() {
let x = &randu::<f32>(dims);
let y = &randu::<f32>(dims);

let start = PreciseTime::now();
let start = Instant::now();

mem_info!("Before benchmark");

Expand All @@ -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");
}
18 changes: 9 additions & 9 deletions src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -228,4 +228,4 @@ pub fn sync(device: i32) {
let err_val = af_sync(device as c_int);
HANDLE_ERROR(AfError::from(err_val));
}
}
}

0 comments on commit dc2a7ed

Please sign in to comment.