-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
93 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[build] | ||
rustflags = ["-C", "target-cpu=native"] | ||
rustflags = ["-C", "target-cpu=native"] | ||
|
||
# Can also specify your simd flags like avx512 etc. | ||
# https://rust-lang.github.io/packed_simd/perf-guide/target-feature/rustflags.html | ||
# rustflags = ["-C", "target-cpu=native", "-C", "target-feature=+avx,+fma"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,4 @@ path = "src/main.rs" | |
[profile.release] | ||
debug = false | ||
lto = true | ||
# codegen-units = 1 | ||
incremental = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg, clippy::manual_memcpy)] | ||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, clippy::manual_memcpy, unused_variables)] | ||
pub fn copy(c: &mut Vec<f64>, a: &Vec<f64>, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in 0..n { | ||
c[i] = a[i]; | ||
} | ||
c.par_iter_mut().enumerate().for_each(|(i, x)| *x = a[i]); | ||
|
||
// Serial version | ||
// for i in 0..n { | ||
// c[i] = a[i]; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
pub fn daxpy(a: &mut Vec<f64>, b: &mut Vec<f64>, scalar: f64, n: usize) -> f64 { | ||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn daxpy(a: &mut Vec<f64>, b: &Vec<f64>, scalar: f64, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in 0..n { | ||
a[i] += scalar * b[i]; | ||
} | ||
a.par_iter_mut() | ||
.enumerate() | ||
.for_each(|(i, x)| *x += scalar * b[i]); | ||
|
||
// Serial version | ||
// for i in 0..n { | ||
// a[i] += scalar * b[i]; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn init(b: &mut Vec<f64>, scalar: f64, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in b.iter_mut().take(n) { | ||
*i = scalar; | ||
} | ||
b.par_iter_mut().for_each(|x| *x = scalar); | ||
|
||
// Serial version | ||
// for i in b.iter_mut().take(n) { | ||
// *i = scalar; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
pub fn sdaxpy(a: &mut Vec<f64>, b: &mut Vec<f64>, c: &mut Vec<f64>, n: usize) -> f64 { | ||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn sdaxpy(a: &mut Vec<f64>, b: &Vec<f64>, c: &Vec<f64>, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in 0..n { | ||
a[i] += b[i] * c[i]; | ||
} | ||
a.par_iter_mut() | ||
.enumerate() | ||
.for_each(|(i, x)| *x += b[i] * c[i]); | ||
|
||
// Serial version | ||
// for i in 0..n { | ||
// a[i] += b[i] * c[i]; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
pub fn striad( | ||
a: &mut Vec<f64>, | ||
b: &mut Vec<f64>, | ||
c: &mut Vec<f64>, | ||
d: &mut Vec<f64>, | ||
n: usize, | ||
) -> f64 { | ||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn striad(a: &mut Vec<f64>, b: &Vec<f64>, c: &Vec<f64>, d: &Vec<f64>, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in 0..n { | ||
a[i] = b[i] + d[i] * c[i]; | ||
} | ||
a.par_iter_mut() | ||
.enumerate() | ||
.for_each(|(i, x)| *x = b[i] + d[i] * c[i]); | ||
|
||
// Serial version | ||
// for i in 0..n { | ||
// a[i] = b[i] + d[i] * c[i]; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn triad(a: &mut Vec<f64>, b: &Vec<f64>, c: &Vec<f64>, scalar: f64, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in 0..n { | ||
a[i] = b[i] + scalar * c[i]; | ||
} | ||
a.par_iter_mut() | ||
.enumerate() | ||
.for_each(|(i, x)| *x = b[i] + scalar * c[i]); | ||
|
||
// Serial version | ||
// for i in 0..n { | ||
// a[i] = b[i] + scalar * c[i]; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
use std::time::Instant; | ||
|
||
#[allow(clippy::ptr_arg)] | ||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; | ||
|
||
#[allow(clippy::ptr_arg, unused_variables)] | ||
pub fn update(b: &mut Vec<f64>, scalar: f64, n: usize) -> f64 { | ||
let s = Instant::now(); | ||
|
||
for i in b.iter_mut().take(n) { | ||
*i = scalar; | ||
} | ||
b.par_iter_mut().for_each(|x| *x += scalar); | ||
|
||
// Serial version | ||
// for i in b.iter_mut().take(n) { | ||
// *i += scalar; | ||
// } | ||
|
||
s.elapsed().as_secs_f64() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters