Skip to content

Commit f503a95

Browse files
committed
Merge branch 'devel' into af3.4
2 parents 81c50f7 + 7a7d453 commit f503a95

File tree

7 files changed

+46
-40
lines changed

7 files changed

+46
-40
lines changed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ exclude = [
1515
]
1616

1717
[dependencies]
18-
libc = "0.1.10"
19-
num = "0.1.27"
20-
time = "0.1.32"
18+
libc = "0.2.11"
19+
num = "0.1.32"
2120
lazy_static = "0.2.1"
2221

2322
[build-dependencies]
24-
rustc-serialize = "0.3.16"
23+
rustc-serialize = "0.3.19"
2524
rustc_version = "0.1.7"
2625

2726
[lib]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ first.
3030
3. Make sure you add the path to library files to your path environment variables.
3131
- On Linux & OSX: do `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$AF_PATH/lib`
3232
- On Windows: Add `%AF_PATH%\lib` to your PATH environment variable.
33-
4. Add `arrayfire = "3.3.0"` to the dependencies section of your project's Cargo.toml file.
33+
4. Add `arrayfire = "3.3.1"` to the dependencies section of your project's Cargo.toml file.
3434

3535
Once step (4) is over, you should be able to use ArrayFire in your Rust project. If you find any bugs, please report them [here](https://github.com/arrayfire/arrayfire-rust/issues).
3636

examples/pi.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#[macro_use(mem_info)]
22
extern crate arrayfire as af;
3-
extern crate time;
43

5-
use time::PreciseTime;
4+
use std::time::Instant;
65
use af::*;
76

87
#[allow(unused_must_use)]
@@ -16,7 +15,7 @@ fn main() {
1615
let x = &randu::<f32>(dims);
1716
let y = &randu::<f32>(dims);
1817

19-
let start = PreciseTime::now();
18+
let start = Instant::now();
2019

2120
mem_info!("Before benchmark");
2221

@@ -30,9 +29,7 @@ fn main() {
3029
let pi_val = real*4.0/(samples as f64);
3130
}
3231

33-
let end = PreciseTime::now();
34-
35-
println!("Estimated Pi Value in {} seconds", start.to(end) / 100);
32+
println!("Estimated Pi Value in {:?}", start.elapsed());
3633

3734
mem_info!("After benchmark");
3835
}

src/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern {
2626

2727
fn af_get_elements(out: MutAfArray, arr: AfArray) -> c_int;
2828

29-
fn af_get_type(out: *mut uint8_t, arr: AfArray) -> c_int;
29+
fn af_get_type(out: *mut c_int, arr: AfArray) -> c_int;
3030

3131
fn af_get_dims(dim0: *mut c_longlong, dim1: *mut c_longlong, dim2: *mut c_longlong,
3232
dim3: *mut c_longlong, arr: AfArray) -> c_int;
@@ -206,8 +206,8 @@ impl Array {
206206
/// Returns the Array data type
207207
pub fn get_type(&self) -> DType {
208208
unsafe {
209-
let mut ret_val: u8 = 0;
210-
let err_val = af_get_type(&mut ret_val as *mut uint8_t, self.handle as AfArray);
209+
let mut ret_val: i32 = 0;
210+
let err_val = af_get_type(&mut ret_val as *mut c_int, self.handle as AfArray);
211211
HANDLE_ERROR(AfError::from(err_val));
212212
DType::from(ret_val)
213213
}

src/defines.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl Error for AfError {
106106
}
107107

108108
/// Types of Array data type
109+
#[repr(C)]
109110
#[derive(Clone, Copy, Debug, PartialEq)]
110111
pub enum DType {
111112
/// 32 bit float
@@ -135,6 +136,7 @@ pub enum DType {
135136
}
136137

137138
/// Dictates the interpolation method to be used by a function
139+
#[repr(C)]
138140
#[derive(Clone, Copy, Debug, PartialEq)]
139141
pub enum InterpType {
140142
/// Nearest Neighbor interpolation method
@@ -148,6 +150,7 @@ pub enum InterpType {
148150
}
149151

150152
/// Helps determine how to pad kernels along borders
153+
#[repr(C)]
151154
#[derive(Clone, Copy, Debug, PartialEq)]
152155
pub enum BorderType {
153156
/// Pad using zeros
@@ -157,6 +160,7 @@ pub enum BorderType {
157160
}
158161

159162
/// Used by `regions` function to identify type of connectivity
163+
#[repr(C)]
160164
#[derive(Clone, Copy, Debug, PartialEq)]
161165
pub enum Connectivity {
162166
/// North-East-South-West (N-E-S-W) connectivity from given pixel/point
@@ -166,6 +170,7 @@ pub enum Connectivity {
166170
}
167171

168172
/// Helps determine the size of output of convolution
173+
#[repr(C)]
169174
#[derive(Clone, Copy, Debug, PartialEq)]
170175
pub enum ConvMode {
171176
/// Default convolution mode where output size is same as input size
@@ -175,6 +180,7 @@ pub enum ConvMode {
175180
}
176181

177182
/// Helps determine if convolution is in Spatial or Frequency domain
183+
#[repr(C)]
178184
#[derive(Clone, Copy, Debug, PartialEq)]
179185
pub enum ConvDomain {
180186
/// ArrayFire chooses whether the convolution will be in spatial domain or frequency domain
@@ -186,6 +192,7 @@ pub enum ConvDomain {
186192
}
187193

188194
/// Error metric used by `matchTemplate` function
195+
#[repr(C)]
189196
#[derive(Clone, Copy, Debug, PartialEq)]
190197
pub enum MatchType {
191198
/// Sum of Absolute Differences
@@ -209,6 +216,7 @@ pub enum MatchType {
209216
}
210217

211218
/// Identify the color space of given image(Array)
219+
#[repr(C)]
212220
#[derive(Clone, Copy, Debug, PartialEq)]
213221
pub enum ColorSpace {
214222
/// Grayscale color space
@@ -220,6 +228,7 @@ pub enum ColorSpace {
220228
}
221229

222230
/// Helps determine the type of a Matrix
231+
#[repr(C)]
223232
#[derive(Clone, Copy, Debug, PartialEq)]
224233
pub enum MatProp {
225234
/// Default (no-op)
@@ -248,6 +257,7 @@ pub enum MatProp {
248257

249258
/// Norm type
250259
#[allow(non_camel_case_types)]
260+
#[repr(C)]
251261
#[derive(Clone, Copy, Debug, PartialEq)]
252262
pub enum NormType {
253263
/// Treats input as a vector and return sum of absolute values

src/device/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ pub fn get_device() -> i32 {
131131
/// * Number of buffers allocated
132132
/// * Number of bytes locked
133133
/// * Number of buffers locked
134-
pub fn device_mem_info() -> (u64, u64, u64, u64) {
134+
pub fn device_mem_info() -> (usize, usize, usize, usize) {
135135
unsafe {
136-
let mut o0: u64 = 0;
137-
let mut o1: u64 = 0;
138-
let mut o2: u64 = 0;
139-
let mut o3: u64 = 0;
136+
let mut o0: usize = 0;
137+
let mut o1: usize = 0;
138+
let mut o2: usize = 0;
139+
let mut o3: usize = 0;
140140
let err_val = af_device_mem_info(&mut o0 as *mut size_t,
141141
&mut o1 as *mut size_t,
142142
&mut o2 as *mut size_t,
@@ -181,7 +181,7 @@ pub fn print_mem_info(msg: String, device: i32) {
181181
/// # Return Values
182182
///
183183
/// None
184-
pub fn set_mem_step_size(step_bytes: u64) {
184+
pub fn set_mem_step_size(step_bytes: usize) {
185185
unsafe {
186186
let err_val = af_set_mem_step_size(step_bytes as size_t);
187187
HANDLE_ERROR(AfError::from(err_val));
@@ -197,9 +197,9 @@ pub fn set_mem_step_size(step_bytes: u64) {
197197
/// # Return Values
198198
///
199199
/// Returns is the size of minimum memory chunk in bytes
200-
pub fn get_mem_step_size() -> u64 {
200+
pub fn get_mem_step_size() -> usize {
201201
unsafe {
202-
let mut temp: u64 = 0;
202+
let mut temp: usize = 0;
203203
let err_val = af_get_mem_step_size(&mut temp as *mut size_t);
204204
HANDLE_ERROR(AfError::from(err_val));
205205
temp
@@ -228,4 +228,4 @@ pub fn sync(device: i32) {
228228
let err_val = af_sync(device as c_int);
229229
HANDLE_ERROR(AfError::from(err_val));
230230
}
231-
}
231+
}

src/util.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ extern {
1313
}
1414

1515
/// Get size, in bytes, of the arrayfire native type
16-
pub fn get_size(value: DType) -> u64 {
16+
pub fn get_size(value: DType) -> usize {
1717
unsafe {
18-
let mut ret_val: u64 = 0;
18+
let mut ret_val: usize = 0;
1919
let err_val = af_get_size_of(&mut ret_val as *mut size_t, value as uint8_t);
2020
HANDLE_ERROR(AfError::from(err_val));
2121
ret_val
@@ -29,37 +29,37 @@ impl From<i32> for AfError {
2929
}
3030
}
3131

32-
impl From<u8> for DType {
33-
fn from(t: u8) -> DType {
34-
assert!(DType::F32 as u8 <= t && t <= DType::U64 as u8);
32+
impl From<i32> for DType {
33+
fn from(t: i32) -> DType {
34+
assert!(DType::F32 as i32 <= t && t <= DType::U64 as i32);
3535
unsafe { mem::transmute(t) }
3636
}
3737
}
3838

39-
impl From<u8> for InterpType {
40-
fn from(t: u8) -> InterpType {
41-
assert!(InterpType::NEAREST as u8 <= t && t <= InterpType::CUBIC as u8);
39+
impl From<i32> for InterpType {
40+
fn from(t: i32) -> InterpType {
41+
assert!(InterpType::NEAREST as i32 <= t && t <= InterpType::CUBIC as i32);
4242
unsafe { mem::transmute(t) }
4343
}
4444
}
4545

46-
impl From<u8> for ConvMode {
47-
fn from(t: u8) -> ConvMode {
48-
assert!(ConvMode::DEFAULT as u8 <= t && t <= ConvMode::EXPAND as u8);
46+
impl From<i32> for ConvMode {
47+
fn from(t: i32) -> ConvMode {
48+
assert!(ConvMode::DEFAULT as i32 <= t && t <= ConvMode::EXPAND as i32);
4949
unsafe { mem::transmute(t) }
5050
}
5151
}
5252

53-
impl From<u8> for ConvDomain {
54-
fn from(t: u8) -> ConvDomain {
55-
assert!(ConvDomain::AUTO as u8 <= t && t <= ConvDomain::FREQUENCY as u8);
53+
impl From<i32> for ConvDomain {
54+
fn from(t: i32) -> ConvDomain {
55+
assert!(ConvDomain::AUTO as i32 <= t && t <= ConvDomain::FREQUENCY as i32);
5656
unsafe { mem::transmute(t) }
5757
}
5858
}
5959

60-
impl From<u8> for MatchType {
61-
fn from(t: u8) -> MatchType {
62-
assert!(MatchType::SAD as u8 <= t && t <= MatchType::SHD as u8);
60+
impl From<i32> for MatchType {
61+
fn from(t: i32) -> MatchType {
62+
assert!(MatchType::SAD as i32 <= t && t <= MatchType::SHD as i32);
6363
unsafe { mem::transmute(t) }
6464
}
6565
}

0 commit comments

Comments
 (0)