-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a scalar subtraction compute function for primitive arrays. - Bounds checking is done for integer values only on the minimum and maximum elements. (ie if neither the smallest nor the largest elementg underflow, nothing else will) - No bounds checking is performed for floating-point operations as they will over/underflow to inf
- Loading branch information
Showing
15 changed files
with
454 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,41 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use itertools::Itertools; | ||
use rand::distributions::Uniform; | ||
use rand::{thread_rng, Rng}; | ||
use vortex::array::chunked::ChunkedArray; | ||
use vortex::IntoArray; | ||
use vortex_error::VortexError; | ||
|
||
fn scalar_subtract(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("scalar_subtract"); | ||
|
||
let mut rng = thread_rng(); | ||
let range = Uniform::new(0i64, 100_000_000); | ||
let data1 = (0..10_000_000) | ||
.map(|_| rng.sample(range)) | ||
.collect_vec() | ||
.into_array(); | ||
let data2 = (0..10_000_000) | ||
.map(|_| rng.sample(range)) | ||
.collect_vec() | ||
.into_array(); | ||
|
||
let to_subtract = -1i64; | ||
|
||
let chunked = ChunkedArray::from_iter([data1.clone(), data2]).into_array(); | ||
|
||
group.bench_function("vortex", |b| { | ||
b.iter(|| { | ||
let array = | ||
vortex::compute::scalar_subtract::subtract_scalar(&chunked, &to_subtract.into()) | ||
.unwrap(); | ||
|
||
let chunked = ChunkedArray::try_from(array).unwrap(); | ||
black_box(chunked); | ||
Ok::<(), VortexError>(()) | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, scalar_subtract); | ||
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
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
Oops, something went wrong.