@@ -4,12 +4,16 @@ use defines::{AfError, DType};
4
4
use error:: HANDLE_ERROR ;
5
5
use self :: libc:: { c_int, size_t, c_char, c_void} ;
6
6
use std:: ffi:: { CStr , CString } ;
7
+ use std:: borrow:: Cow ;
7
8
use util:: free_host;
8
9
9
10
extern {
10
11
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 ;
11
13
fn af_info ( ) -> c_int ;
12
14
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 ;
13
17
fn af_init ( ) -> c_int ;
14
18
fn af_get_device_count ( nDevices : * mut c_int ) -> c_int ;
15
19
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) {
40
44
}
41
45
}
42
46
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
+
43
57
/// Print library meta-info
44
58
///
45
59
/// # Examples
@@ -81,6 +95,28 @@ pub fn info_string(verbose: bool) -> String {
81
95
result
82
96
}
83
97
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
+
84
120
/// Initialize ArrayFire library
85
121
///
86
122
/// 0th device will be the default device unless init call
0 commit comments