@@ -4,12 +4,16 @@ use defines::{AfError, DType};
44use error:: HANDLE_ERROR ;
55use self :: libc:: { c_int, size_t, c_char, c_void} ;
66use std:: ffi:: { CStr , CString } ;
7+ use std:: borrow:: Cow ;
78use util:: free_host;
89
910extern {
1011 fn af_get_version ( major : * mut c_int , minor : * mut c_int , patch : * mut c_int ) -> c_int ;
12+ fn af_get_revision ( ) -> * const c_char ;
1113 fn af_info ( ) -> c_int ;
1214 fn af_info_string ( str : * mut * mut c_char , verbose : bool ) -> c_int ;
15+ fn af_device_info ( d_name : * mut c_char , d_platform : * mut c_char ,
16+ d_toolkit : * mut c_char , d_compute : * mut c_char ) -> c_int ;
1317 fn af_init ( ) -> c_int ;
1418 fn af_get_device_count ( nDevices : * mut c_int ) -> c_int ;
1519 fn af_get_dbl_support ( available : * mut c_int , device : c_int ) -> c_int ;
@@ -40,6 +44,16 @@ pub fn get_version() -> (i32, i32, i32) {
4044 }
4145}
4246
47+ /// Get ArrayFire Revision (commit) information of the library.
48+ ///
49+ /// # Return Values
50+ /// This returns a `Cow<'static, str>` as the string is constructed at compile time.
51+ pub fn get_revision ( ) -> Cow < ' static , str > {
52+ unsafe {
53+ CStr :: from_ptr ( af_get_revision ( ) ) . to_string_lossy ( )
54+ }
55+ }
56+
4357/// Print library meta-info
4458///
4559/// # Examples
@@ -81,6 +95,28 @@ pub fn info_string(verbose: bool) -> String {
8195 result
8296}
8397
98+ /// Gets the information about device and platform as strings.
99+ ///
100+ /// # Return Values
101+ /// A tuple of `String` indicating the name, platform, toolkit and compute.
102+ pub fn device_info ( ) -> ( String , String , String , String ) {
103+ let mut name = [ 0 as c_char ; 64 ] ;
104+ let mut platform = [ 0 as c_char ; 10 ] ;
105+ let mut toolkit = [ 0 as c_char ; 64 ] ;
106+ let mut compute = [ 0 as c_char ; 10 ] ;
107+ unsafe {
108+ let err_val = af_device_info ( & mut name[ 0 ] ,
109+ & mut platform[ 0 ] ,
110+ & mut toolkit[ 0 ] ,
111+ & mut compute[ 0 ] ) ;
112+ HANDLE_ERROR ( AfError :: from ( err_val) ) ;
113+ ( CStr :: from_ptr ( name. as_mut_ptr ( ) ) . to_string_lossy ( ) . into_owned ( ) ,
114+ CStr :: from_ptr ( platform. as_mut_ptr ( ) ) . to_string_lossy ( ) . into_owned ( ) ,
115+ CStr :: from_ptr ( toolkit. as_mut_ptr ( ) ) . to_string_lossy ( ) . into_owned ( ) ,
116+ CStr :: from_ptr ( compute. as_mut_ptr ( ) ) . to_string_lossy ( ) . into_owned ( ) )
117+ }
118+ }
119+
84120/// Initialize ArrayFire library
85121///
86122/// 0th device will be the default device unless init call
0 commit comments