Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/fardream/gen-mkl-wrapper
The package relies on modernc.org/cc/v4 as AST parser, which is a pure go implementation. The binary can be installed with go install
:
go install github.com/fardream/gen-mkl-wrapper@latest
Math Kernel Library by Intel is widely used library of common mathematical routines, which provides support for various BLAS and LAPACK routines and many many more. Due to its root in Fortran and C, many routines' names contain the type its operates on, for example, the Cholesky Decomposition is
lapack_int LAPACKE_spotrf (int matrix_layout , char uplo , lapack_int n , float * a , lapack_int lda ); // for float, or 32-bit float point number.
lapack_int LAPACKE_dpotrf (int matrix_layout , char uplo , lapack_int n , double * a , lapack_int lda ); // for double, or 64-bit float point number.
For C++ or rust, it may be desired to dispatch the method based on the type. This becomes extremely handy when implementing something based on MKL for both 32-bit and 64-bit float point number.
In C++, below is valid
lapack_int LAPACKE_potrf (int matrix_layout , char uplo , lapack_int n , float * a , lapack_int lda ); // for float, or 32-bit float point number.
lapack_int LAPACKE_potrf (int matrix_layout , char uplo , lapack_int n , double * a , lapack_int lda ); // for double, or 64-bit float point number.
Similarly in rust, the below is valid
pub trait MKLRoutines {
fn LAPACKE_potrf(matrix_layout: i32, uplo: i8, n: i32, a: *mut Self, lda: i32) -> i32;
}
impl MKLRoutines for f64 {
// for f64, or 64-bit float point number.
fn LAPACKE_potrf(matrix_layout: i32, uplo: i8, n: i32, a: *mut Self, lda: i32) -> i32 {
unsafe {
LAPACKE_dpotrf(matrix_layout, uplo, n, a, lda)
}
}
}
impl MKLRoutines for f32 {
// for f32, or 32-bit float point number.
fn LAPACKE_potrf(matrix_layout: i32, uplo: i8, n: i32, a: *mut Self, lda: i32) -> i32 {
unsafe {
LAPACKE_spotrf(matrix_layout, uplo, n, a, lda)
}
}
}
This simply binary does just the above - provided with a list of routines names, it will generate the rust trait or C++ polymorphic functions to those routines.
Those generated functions can be called from template/generic functions
template <typename T>
void SomeFunctionForFloatPoint(T* x) {
// ... other codes
LAPACKE_potrf(LAPACK_ROW_MAJOR, 'U', n, x, lda);
// ... other codes
}
or
pub fn some_function_for_float<T: MKLRoutines>(x:&mut [T]) {
// ... other codes
unsafe { T::LAPACKE_potrf(LAPACK_ROW_MAJOR as i32, 'U' as i8, n x.as_mut_ptr(), lda) };
// ... other codes
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.