Fmt fix & CI #1

Closed
andrey wants to merge 1 commits from fmt-ci into master
3 changed files with 82 additions and 56 deletions

14
.drone.yml Normal file
View File

@ -0,0 +1,14 @@
kind: pipeline
name: default
steps:
- name: build
image: rust
commands:
- cargo build --verbose --all
- name: fmt-check
image: rust
commands:
- rustup component add rustfmt
- cargo fmt --all -- --check

View File

@ -6,6 +6,7 @@ use std::process::Command;
use std::{env, fs, io};
use tar::Archive;
const CBLAS_SRC: &str = "https://codeload.github.com/andreytkachenko/cblas/tar.gz/v3.6.0";
fn download<P: AsRef<Path>>(source_url: &str, target_file: P) -> anyhow::Result<()> {
@ -49,30 +50,49 @@ fn main() {
extract(cblas_name, &out_path).unwrap();
}
Command::new("gfortran")
.current_dir(cblas_dir.join("src"))
.arg("-O3")
.arg("-c").arg(cblas_dir.join("src/cdotcsub.f"))
.arg("-c").arg(cblas_dir.join("src/cdotusub.f"))
.arg("-c").arg(cblas_dir.join("src/dasumsub.f"))
.arg("-c").arg(cblas_dir.join("src/ddotsub.f"))
.arg("-c").arg(cblas_dir.join("src/dnrm2sub.f"))
.arg("-c").arg(cblas_dir.join("src/dsdotsub.f"))
.arg("-c").arg(cblas_dir.join("src/dzasumsub.f"))
.arg("-c").arg(cblas_dir.join("src/dznrm2sub.f"))
.arg("-c").arg(cblas_dir.join("src/icamaxsub.f"))
.arg("-c").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"))
.arg("-c")
.arg(cblas_dir.join("src/cdotcsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/cdotusub.f"))
.arg("-c")
.arg(cblas_dir.join("src/dasumsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/ddotsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/dnrm2sub.f"))
.arg("-c")
.arg(cblas_dir.join("src/dsdotsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/dzasumsub.f"))
.arg("-c")
.arg(cblas_dir.join("src/dznrm2sub.f"))
.arg("-c")
.arg(cblas_dir.join("src/icamaxsub.f"))
.arg("-c")
.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()
.expect("fortran failed");

View File

@ -1,4 +1,3 @@
#[cfg(test)]
mod tests {
extern crate openblas_src;
@ -8,43 +7,36 @@ mod tests {
#[test]
fn test1() {
let (m, n, k) = (2, 4, 3);
let a = vec![
1.0, 4.0,
2.0, 5.0,
3.0, 6.0,
];
let b = vec![
1.0, 5.0, 9.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 a = vec![1.0, 4.0, 2.0, 5.0, 3.0, 6.0];
let b = vec![
1.0, 5.0, 9.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 sdot_res = unsafe { ddot(6, &a, 1, &a, 1) };
let sdot_res = unsafe {
ddot(6, &a, 1, &a, 1)
};
unsafe {
dgemm(Layout::ColumnMajor, Transpose::None, Transpose::None,
m, n, k, 1.0, &a, m, &b, k, 1.0, &mut c, m);
dgemm(
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!(
c == vec![
40.0, 90.0,
50.0, 100.0,
50.0, 120.0,
60.0, 130.0,
]
);
assert!(c == vec![40.0, 90.0, 50.0, 100.0, 50.0, 120.0, 60.0, 130.0,]);
}
}
}