Fmt fix & CI
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Andrey Tkachenko 2022-03-06 00:00:52 +04:00
parent 3e7ce44242
commit ddfe99dcab
3 changed files with 80 additions and 56 deletions

13
.drone.yml Normal file
View File

@ -0,0 +1,13 @@
kind: pipeline
name: default
steps:
- name: build
image: hub.aidev.ru/rust-blas
commands:
- cargo build --verbose --all
- name: fmt-check
image: hub.aidev.ru/rust-blas
commands:
- cargo fmt --all -- --check

View File

@ -49,30 +49,49 @@ fn main() {
extract(cblas_name, &out_path).unwrap(); extract(cblas_name, &out_path).unwrap();
} }
Command::new("gfortran") Command::new("gfortran")
.current_dir(cblas_dir.join("src")) .current_dir(cblas_dir.join("src"))
.arg("-O3") .arg("-O3")
.arg("-c").arg(cblas_dir.join("src/cdotcsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/cdotusub.f")) .arg(cblas_dir.join("src/cdotcsub.f"))
.arg("-c").arg(cblas_dir.join("src/dasumsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/ddotsub.f")) .arg(cblas_dir.join("src/cdotusub.f"))
.arg("-c").arg(cblas_dir.join("src/dnrm2sub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/dsdotsub.f")) .arg(cblas_dir.join("src/dasumsub.f"))
.arg("-c").arg(cblas_dir.join("src/dzasumsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/dznrm2sub.f")) .arg(cblas_dir.join("src/ddotsub.f"))
.arg("-c").arg(cblas_dir.join("src/icamaxsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/idamaxsub.f")) .arg(cblas_dir.join("src/dnrm2sub.f"))
.arg("-c").arg(cblas_dir.join("src/isamaxsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/izamaxsub.f")) .arg(cblas_dir.join("src/dsdotsub.f"))
.arg("-c").arg(cblas_dir.join("src/sasumsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/scasumsub.f")) .arg(cblas_dir.join("src/dzasumsub.f"))
.arg("-c").arg(cblas_dir.join("src/scnrm2sub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/sdotsub.f")) .arg(cblas_dir.join("src/dznrm2sub.f"))
.arg("-c").arg(cblas_dir.join("src/sdsdotsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/snrm2sub.f")) .arg(cblas_dir.join("src/icamaxsub.f"))
.arg("-c").arg(cblas_dir.join("src/zdotcsub.f")) .arg("-c")
.arg("-c").arg(cblas_dir.join("src/zdotusub.f")) .arg(cblas_dir.join("src/idamaxsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/isamaxsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/izamaxsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/sasumsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/scasumsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/scnrm2sub.f"))
.arg("-c")
.arg(cblas_dir.join("src/sdotsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/sdsdotsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/snrm2sub.f"))
.arg("-c")
.arg(cblas_dir.join("src/zdotcsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/zdotusub.f"))
.status() .status()
.expect("fortran failed"); .expect("fortran failed");

View File

@ -1,4 +1,3 @@
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
extern crate openblas_src; extern crate openblas_src;
@ -8,43 +7,36 @@ mod tests {
#[test] #[test]
fn test1() { fn test1() {
let (m, n, k) = (2, 4, 3); let (m, n, k) = (2, 4, 3);
let a = vec![ let a = vec![1.0, 4.0, 2.0, 5.0, 3.0, 6.0];
1.0, 4.0,
2.0, 5.0,
3.0, 6.0,
];
let b = vec![ let b = vec![
1.0, 5.0, 9.0, 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0,
2.0, 6.0, 10.0,
3.0, 7.0, 11.0,
4.0, 8.0, 12.0,
];
let mut c = vec![
2.0, 7.0,
6.0, 2.0,
0.0, 7.0,
4.0, 2.0,
]; ];
let mut c = vec![2.0, 7.0, 6.0, 2.0, 0.0, 7.0, 4.0, 2.0];
let sdot_res = unsafe { let sdot_res = unsafe { ddot(6, &a, 1, &a, 1) };
ddot(6, &a, 1, &a, 1)
};
unsafe { unsafe {
dgemm(Layout::ColumnMajor, Transpose::None, Transpose::None, dgemm(
m, n, k, 1.0, &a, m, &b, k, 1.0, &mut c, m); Layout::ColumnMajor,
Transpose::None,
Transpose::None,
m,
n,
k,
1.0,
&a,
m,
&b,
k,
1.0,
&mut c,
m,
);
} }
assert_eq!(sdot_res, 91.0); assert_eq!(sdot_res, 91.0);
assert!( assert!(c == vec![40.0, 90.0, 50.0, 100.0, 50.0, 120.0, 60.0, 130.0,]);
c == vec![
40.0, 90.0,
50.0, 100.0,
50.0, 120.0,
60.0, 130.0,
]
);
} }
} }