fixed format in "multithreading" and "lib"
This commit is contained in:
parent
d6bb8f38fa
commit
aed49466ce
|
@ -1,4 +1,5 @@
|
||||||
/target
|
/target
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
/.vscode
|
/.vscode
|
|
@ -37,7 +37,6 @@ fn dot(a: &[f64], b: &[f64]) -> f64 {
|
||||||
/// sized slices which then get passed ot their own thread to compute the partial dot product. After all threads have
|
/// sized slices which then get passed ot their own thread to compute the partial dot product. After all threads have
|
||||||
/// finished the partial dot products will be summed to create the final result.
|
/// finished the partial dot products will be summed to create the final result.
|
||||||
fn dot_parallel(a: Arc<Vec<f64>>, b: Arc<Vec<f64>>, threads: usize) {
|
fn dot_parallel(a: Arc<Vec<f64>>, b: Arc<Vec<f64>>, threads: usize) {
|
||||||
|
|
||||||
let mut pool = ThreadPool::with_limit(threads);
|
let mut pool = ThreadPool::with_limit(threads);
|
||||||
|
|
||||||
// number of elements in each vector for each thread
|
// number of elements in each vector for each thread
|
||||||
|
@ -56,7 +55,7 @@ fn dot_parallel(a: Arc<Vec<f64>>, b: Arc<Vec<f64>>, threads: usize) {
|
||||||
dot(a, b)
|
dot(a, b)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.join_all();
|
pool.join_all();
|
||||||
|
|
||||||
black_box(pool.get_results().iter().sum::<f64>());
|
black_box(pool.get_results().iter().sum::<f64>());
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
pub mod image;
|
pub mod image;
|
||||||
|
|
Loading…
Reference in New Issue