Skip to content

Commit 5aa5bbd

Browse files
committed
fn to change fft plan cache size used by ArrayFire fft fns
1 parent bcdc406 commit 5aa5bbd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod lapack;
8282
mod macros;
8383
mod num;
8484

85-
pub use signal::{approx1, approx2};
85+
pub use signal::{approx1, approx2, set_fft_plan_cache_size};
8686
pub use signal::{fft, fft2, fft3, ifft, ifft2, ifft3};
8787
pub use signal::{fft_r2c, fft2_r2c, fft3_r2c, fft_c2r, fft2_c2r, fft3_c2r};
8888
pub use signal::{fft_inplace, fft2_inplace, fft3_inplace};

src/signal/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate libc;
33
use array::Array;
44
use defines::{AfError, ConvDomain, ConvMode, InterpType};
55
use error::HANDLE_ERROR;
6-
use self::libc::{uint8_t, c_int, c_float, c_double, c_longlong};
6+
use self::libc::{uint8_t, c_int, c_float, c_double, c_longlong, size_t};
77

88
type MutAfArray = *mut self::libc::c_longlong;
99
type AfArray = self::libc::c_longlong;
@@ -16,6 +16,8 @@ extern {
1616
fn af_approx2(out: MutAfArray, inp: AfArray, pos0: AfArray, pos1: AfArray,
1717
method: c_int, off_grid: c_float) -> c_int;
1818

19+
fn af_set_fft_plan_cache_size(cache_size: size_t) -> c_int;
20+
1921
fn af_fft(out: MutAfArray, arr: AfArray,
2022
nfac: c_double, odim0: c_longlong) -> c_int;
2123

@@ -115,6 +117,18 @@ pub fn approx2(input: &Array, pos0: &Array, pos1: &Array,
115117
}
116118
}
117119

120+
/// Set fft plan cache size
121+
///
122+
/// Though this is a low overhead function, it is advised not to change
123+
/// the fft plan cache size a mid program execution unless that is what
124+
/// you intend to do.
125+
pub fn set_fft_plan_cache_size(cache_size: usize) {
126+
unsafe {
127+
let err_val = af_set_fft_plan_cache_size(cache_size as size_t);
128+
HANDLE_ERROR(AfError::from(err_val));
129+
}
130+
}
131+
118132
/// Fast fourier transform for 1d signals
119133
///
120134
/// # Parameters

0 commit comments

Comments
 (0)