Skip to main content

set_ilp64_backend

Function set_ilp64_backend 

Source
pub unsafe fn set_ilp64_backend(
    dgemm64: unsafe extern "C" fn(*const i8, *const i8, *const i64, *const i64, *const i64, *const f64, *const f64, *const i64, *const f64, *const i64, *const f64, *mut f64, *const i64),
    zgemm64: unsafe extern "C" fn(*const i8, *const i8, *const i64, *const i64, *const i64, *const Complex<f64>, *const Complex<f64>, *const i64, *const Complex<f64>, *const i64, *const Complex<f64>, *mut Complex<f64>, *const i64),
)
Expand description

Set the process-wide default to an ILP64 BLAS.

§Safety

As for set_blas_backend, with 64-bit integer arguments.

§Example

use sparse_ir::Matrix;
use sparse_ir::gemm::{clear_blas_backend, get_backend_info, matmul, set_ilp64_backend};

// `my_dgemm64` and `my_zgemm64` are the ILP64 (64-bit integer) Fortran BLAS
// `dgemm_` and `zgemm_` to use. (This example defines naive stand-ins in
// hidden lines so that it runs without an ILP64 BLAS library.)
unsafe {
    set_ilp64_backend(my_dgemm64, my_zgemm64);
}
assert_eq!(get_backend_info(), ("External BLAS (ILP64)", true, true));

// Calls without an explicit backend handle now go through the injected BLAS
// Column-major data: [[1, 2], [3, 4]] and [[5, 6], [7, 8]]
let a = Matrix::<f64>::from_vec_col_major([2, 2], vec![1.0, 3.0, 2.0, 4.0]).unwrap();
let b = Matrix::<f64>::from_vec_col_major([2, 2], vec![5.0, 7.0, 6.0, 8.0]).unwrap();
let c = matmul(None, &a, &b).unwrap();
assert_eq!(c.host_data().unwrap(), &[19.0, 43.0, 22.0, 50.0]); // [[19, 22], [43, 50]]

clear_blas_backend(); // back to the pure-Rust Faer backend
let (_, is_external, is_ilp64) = get_backend_info();
assert!(!is_external && !is_ilp64);