run over a directory

This commit is contained in:
Saurabh 2022-02-28 21:37:13 -07:00
parent 8c1186db3c
commit 424207914b
1 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,8 @@
extern crate nalgebra_sparse; extern crate nalgebra_sparse;
use nalgebra_sparse::CsrMatrix; use nalgebra_sparse::CsrMatrix;
use std::fs::{self, DirEntry};
use std::io;
use std::path::Path;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
#[cfg(feature = "io")] #[cfg(feature = "io")]
@ -7,16 +10,20 @@ use nalgebra_sparse::io::load_coo_from_matrix_market_file;
fn main() { fn main() {
#[cfg(feature = "io")] #[cfg(feature = "io")]
{ {
let sparse_input_matrix = let mut file_iter = fs::read_dir("./data").unwrap();
load_coo_from_matrix_market_file::<f64, _>("./data/crankseg_1.mtx").unwrap(); for f in file_iter {
let sparse_input_matrix = CsrMatrix::from(&sparse_input_matrix); println!("Benchmark file {:?}", f);
let spmm_result = &sparse_input_matrix * &sparse_input_matrix; let f = f.unwrap().path();
let now = Instant::now(); let sparse_input_matrix = load_coo_from_matrix_market_file::<f64, _>(&f).unwrap();
let spmm_result = &sparse_input_matrix * &sparse_input_matrix; let sparse_input_matrix = CsrMatrix::from(&sparse_input_matrix);
let spmm_time = now.elapsed().as_millis(); let spmm_result = &sparse_input_matrix * &sparse_input_matrix;
println!("SGEMM time was {}", spmm_time); let now = Instant::now();
let sum: f64 = spmm_result.triplet_iter().map(|(_, _, v)| v).sum(); let spmm_result = &sparse_input_matrix * &sparse_input_matrix;
println!("sum of product is {}", sum); let spmm_time = now.elapsed().as_millis();
println!("SGEMM time was {}", spmm_time);
let sum: f64 = spmm_result.triplet_iter().map(|(_, _, v)| v).sum();
println!("sum of product is {}", sum);
}
} }
#[cfg(not(feature = "io"))] #[cfg(not(feature = "io"))]
{ {