Skip to content

Commit

Permalink
New rlst scalar (#63)
Browse files Browse the repository at this point in the history
* WIP: Remove rlst_common

* Removed rlst_common

* Removed cyclic dependency

* Renamed Scalar to RlstScalar

* Added pointer to original licese for Scalar package derived RlstScalar trait.

* Removed cauchy from dependencies

* Fixed serde issue
  • Loading branch information
tbetcke authored Mar 8, 2024
1 parent d5dc768 commit d0cf6cb
Show file tree
Hide file tree
Showing 71 changed files with 964 additions and 587 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"dense",
"operator",
"sparse",
"common",
"io",
"suitesparse-src",
"blis-src",
Expand Down
1 change: 0 additions & 1 deletion blis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = "2021"
rlst-blis-src = { path = "../blis-src" }
num_cpus = "1"
num = "0.4"
cauchy = "0.4"

[lib]
name = "rlst_blis"
Expand Down
10 changes: 0 additions & 10 deletions blis/examples/threads.rs

This file was deleted.

27 changes: 1 addition & 26 deletions blis/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
//! Public interface to Blis routines.
pub mod gemm;
// pub mod gemm;
pub mod threading;
pub mod types;

use cauchy::Scalar;

/// Compute expected size of a data slice from stride and shape.
pub fn get_expected_data_size(stride: [usize; 2], shape: [usize; 2]) -> usize {
if shape[0] == 0 || shape[1] == 0 {
return 0;
}

1 + (shape[0] - 1) * stride[0] + (shape[1] - 1) * stride[1]
}

/// Panic if expected data size is not identical to actual data size.
pub fn assert_data_size<T: Scalar>(data: &[T], stride: [usize; 2], shape: [usize; 2]) {
let expected = get_expected_data_size(stride, shape);

assert_eq!(
expected,
data.len(),
"Wrong size for data slice. Actual size {}. Expected size {}.",
data.len(),
expected
);
}
21 changes: 17 additions & 4 deletions blis/src/interface/gemm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@
use super::types::TransMode;
use crate::interface::assert_data_size;
use crate::raw;
use cauchy::{c32, c64, Scalar};
use cauchy::{c32, c64};

/// Transposition Mode.
#[derive(Clone, Copy, PartialEq)]
#[repr(u32)]

pub enum TransMode {
/// Complex conjugate of matrix.
ConjNoTrans,
/// No modification of matrix.
NoTrans,
/// Transposition of matrix.
Trans,
/// Conjugate transpose of matrix.
ConjTrans,
}

/// Safe interface to using the Blis Gemm routine.
///
/// Performs the matrix multiplication `C = alpha * A * B + beta * C`.
/// # Arguments
///
Expand All @@ -25,7 +38,7 @@ use cauchy::{c32, c64, Scalar};
/// - `c` - Reference to data of C.
/// - `rsc` - Row stride of C.
/// - `csc` - Column stride of C.
pub trait Gemm: Scalar {
pub trait Gemm: Sized {
#[allow(clippy::too_many_arguments)]
fn gemm(
transa: TransMode,
Expand Down
30 changes: 15 additions & 15 deletions blis/src/interface/types.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//! Interface to Blis types
use crate::raw;
// //! Interface to Blis types
// use crate::raw;

/// Transposition Mode.
#[derive(Clone, Copy, PartialEq)]
#[repr(u32)]
pub enum TransMode {
/// Complex conjugate of matrix.
ConjNoTrans = raw::trans_t_BLIS_CONJ_NO_TRANSPOSE,
/// No modification of matrix.
NoTrans = raw::trans_t_BLIS_NO_TRANSPOSE,
/// Transposition of matrix.
Trans = raw::trans_t_BLIS_TRANSPOSE,
/// Conjugate transpose of matrix.
ConjTrans = raw::trans_t_BLIS_CONJ_TRANSPOSE,
}
// /// Transposition Mode.
// #[derive(Clone, Copy, PartialEq)]
// #[repr(u32)]
// pub enum TransMode {
// /// Complex conjugate of matrix.
// ConjNoTrans = raw::trans_t_BLIS_CONJ_NO_TRANSPOSE,
// /// No modification of matrix.
// NoTrans = raw::trans_t_BLIS_NO_TRANSPOSE,
// /// Transposition of matrix.
// Trans = raw::trans_t_BLIS_TRANSPOSE,
// /// Conjugate transpose of matrix.
// ConjTrans = raw::trans_t_BLIS_CONJ_TRANSPOSE,
// }
2 changes: 0 additions & 2 deletions blis/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

extern crate rlst_blis_src;

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
22 changes: 0 additions & 22 deletions common/Cargo.toml

This file was deleted.

4 changes: 0 additions & 4 deletions common/src/lib.rs

This file was deleted.

47 changes: 0 additions & 47 deletions common/src/types.rs

This file was deleted.

7 changes: 4 additions & 3 deletions dense/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ categories = ["mathematics", "science"]
name = "rlst_dense"

[dependencies]
num = "0.4"
cauchy = "0.4"
num = {version = "0.4", features = ["serde", "rand"] }
rand = "0.8"
itertools = "0.12"
rand_distr = "0.4"
rlst-blis = { path = "../blis" }
approx = { version = "0.5", features = ["num-complex"] }
rlst-common = { path = "../common" }
paste = "1"
rand_chacha = "0.3"
rlst-blis-src = { path = "../blis-src" }
rlst-netlib-lapack-src = { path = "../netlib-lapack-src" }
lapack = "0.19.*"
thiserror = "1.0.40"
serde = "1.*"


[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
Expand Down
Loading

0 comments on commit d0cf6cb

Please sign in to comment.