-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from TooManyBees/avx
Add experimental SIMD functions
- Loading branch information
Showing
8 changed files
with
775 additions
and
29 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#[macro_use] | ||
extern crate criterion; | ||
#[macro_use] | ||
extern crate lazy_static; | ||
extern crate rand; | ||
extern crate lab; | ||
|
||
use criterion::Criterion; | ||
use rand::Rng; | ||
use rand::distributions::Standard; | ||
|
||
lazy_static! { | ||
static ref LABS: Vec<lab::Lab> = { | ||
let rand_seed = [0u8;32]; | ||
let mut rng: rand::StdRng = rand::SeedableRng::from_seed(rand_seed); | ||
let labs: Vec<[f32; 8]> = rng.sample_iter(&Standard).take(512).collect(); | ||
labs.iter().map(|lab| lab::Lab { l: lab[0], a: lab[1], b: lab[2] }).collect() | ||
}; | ||
} | ||
|
||
fn labs_to_rgbs(c: &mut Criterion) { | ||
c.bench_function("labs_to_rgbs", move |b| { | ||
b.iter(|| lab::labs_to_rgbs(&LABS)) | ||
}); | ||
} | ||
|
||
fn labs_to_rgbs_simd(c: &mut Criterion) { | ||
c.bench_function("labs_to_rgbs_simd", move |b| { | ||
b.iter(|| unsafe { lab::simd::labs_to_rgbs(&LABS) }) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, labs_to_rgbs, labs_to_rgbs_simd); | ||
criterion_main!(benches); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#[macro_use] | ||
extern crate criterion; | ||
#[macro_use] | ||
extern crate lazy_static; | ||
extern crate rand; | ||
extern crate lab; | ||
|
||
use criterion::Criterion; | ||
use rand::Rng; | ||
use rand::distributions::Standard; | ||
|
||
lazy_static! { | ||
static ref RGBS: Vec<[u8;3]> = { | ||
let rand_seed = [0u8;32]; | ||
let mut rng: rand::StdRng = rand::SeedableRng::from_seed(rand_seed); | ||
rng.sample_iter(&Standard).take(512).collect() | ||
}; | ||
} | ||
|
||
// fn rgb_to_lab(c: &mut Criterion) { | ||
// let rgb = RGBS[0]; | ||
// c.bench_function("rgb_to_lab", move |b| { | ||
// b.iter(|| lab::Lab::from_rgb(&rgb)) | ||
// }); | ||
// } | ||
|
||
fn rgbs_to_labs(c: &mut Criterion) { | ||
c.bench_function("rgbs_to_labs", move |b| { | ||
b.iter(|| lab::rgbs_to_labs(&RGBS)) | ||
}); | ||
} | ||
|
||
fn rgbs_to_labs_simd(c: &mut Criterion) { | ||
c.bench_function("rgbs_to_labs_simd", move |b| { | ||
b.iter(|| unsafe { lab::simd::rgbs_to_labs(&RGBS) }) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, rgbs_to_labs, rgbs_to_labs_simd); | ||
criterion_main!(benches); |
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
Oops, something went wrong.