-
Notifications
You must be signed in to change notification settings - Fork 130
feat[gpu]: for kernel and framework for running pipeline #4857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d3d2499
wip[gpu]: for kernel and framework for running pipeline
joseph-isaacs b1bfd4f
wip[gpu]: for kernel and framework for running pipeline
joseph-isaacs 19bef64
wip[gpu]: for kernel and framework for running pipeline
joseph-isaacs f0c8914
wip[gpu]: for kernel and framework for running pipeline
joseph-isaacs c35602d
u
joseph-isaacs cc14810
u
joseph-isaacs 1f66e5e
fix
joseph-isaacs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 +1,2 @@ | ||
| kernels/ | ||
| kernels/fls* | ||
| *.ptx |
This file contains hidden or 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 hidden or 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,149 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-FileCopyrightText: Copyright the Vortex contributors | ||
|
|
||
| #![allow(clippy::unwrap_used)] | ||
|
|
||
| use std::sync::Arc; | ||
| use std::time::Duration; | ||
|
|
||
| use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; | ||
| use cudarc::driver::CudaContext; | ||
| use rand::prelude::StdRng; | ||
| use rand::{Rng, SeedableRng}; | ||
| use vortex_array::{IntoArray, ToCanonical}; | ||
| use vortex_buffer::BufferMut; | ||
| use vortex_dtype::NativePType; | ||
| use vortex_error::VortexUnwrap; | ||
| use vortex_fastlanes::{BitPackedArray, FoRArray}; | ||
| use vortex_gpu::{cuda_bit_unpack_timed, cuda_for_unpack_timed}; | ||
|
|
||
| // Data sizes: 1GB, 2.5GB, 5GB, 10GB | ||
| // These are approximate sizes in bytes, accounting for bit-packing compression | ||
| const DATA_SIZES: &[(usize, &str)] = &[ | ||
| (268_435_456, "1GB"), // ~1GB when unpacked (268M * 4 bytes) | ||
| // (671_088_640, "2.5GB"), // ~2.5GB when unpacked | ||
| // (1_342_177_280, "5GB"), // ~5GB when unpacked | ||
| (2_684_354_560, "10GB"), // ~10GB when unpacked | ||
| ]; | ||
|
|
||
| /// Creates a bitpackable dataset of the given size. | ||
| /// Values are chosen to fit in 6 bits (0-63) to ensure no patches are needed. | ||
| fn make_bitpackable_array<T: NativePType>(len: usize) -> BitPackedArray { | ||
| let mut rng = StdRng::seed_from_u64(42); | ||
| // Generate values that fit in 6 bits (0-63) | ||
| let values = (0..len) | ||
| .map(|_| T::from(rng.random_range(0..64)).unwrap()) | ||
| .collect::<BufferMut<T>>() | ||
| .into_array() | ||
| .to_primitive(); | ||
|
|
||
| // Encode with 6-bit width, which will not need patches | ||
| BitPackedArray::encode(values.as_ref(), 6).unwrap() | ||
| } | ||
|
|
||
| /// Creates a FoR bitpackable dataset of the given size. | ||
| /// Values are chosen to fit in 6 bits after subtracting the reference value. | ||
| fn make_for_bitpackable_array(len: usize) -> FoRArray { | ||
| let mut rng = StdRng::seed_from_u64(42); | ||
| let reference = 100u32; | ||
|
|
||
| // Generate values that fit in 6 bits (0-63) | ||
| let values = (0..len) | ||
| .map(|_| rng.random_range(0..64)) | ||
| .collect::<BufferMut<u32>>() | ||
| .into_array() | ||
| .to_primitive(); | ||
|
|
||
| // Create bitpacked array first | ||
| let bitpacked = BitPackedArray::encode(values.as_ref(), 6).unwrap(); | ||
|
|
||
| // Wrap in FoR encoding with reference value | ||
| FoRArray::try_new(bitpacked.into_array(), reference.into()).vortex_unwrap() | ||
| } | ||
|
|
||
| fn benchmark_gpu_decompress_kernel_only(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("gpu_decompress_kernel_only"); | ||
|
|
||
| group.sample_size(10); | ||
|
|
||
| // Initialize CUDA context once | ||
|
|
||
| for (len, label) in DATA_SIZES { | ||
| let len = len.next_multiple_of(1024); | ||
| let array = make_bitpackable_array::<u32>(len); | ||
|
|
||
| let ctx = CudaContext::new(0).unwrap(); | ||
| ctx.set_blocking_synchronize().unwrap(); | ||
| let ctx = Arc::new(ctx); | ||
|
|
||
| group.throughput(Throughput::Bytes((len * size_of::<u32>()) as u64)); | ||
| group.bench_with_input(BenchmarkId::new("u32", label), &array, |b, array| { | ||
joseph-isaacs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| b.iter_custom(|iters| { | ||
| let mut total_time = Duration::ZERO; | ||
| for _ in 0..iters { | ||
| // This only measures kernel execution time, not memory transfers | ||
| let kernel_time_ns = cuda_bit_unpack_timed(array, Arc::clone(&ctx)).unwrap(); | ||
| total_time += kernel_time_ns; | ||
| } | ||
| total_time | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| group.finish(); | ||
| } | ||
|
|
||
| fn benchmark_gpu_for_decompress_kernel_only(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("gpu_for_decompress_kernel_only"); | ||
|
|
||
| group.sample_size(10); | ||
|
|
||
| for (len, label) in DATA_SIZES { | ||
| let len = len.next_multiple_of(1024); | ||
| let array = make_for_bitpackable_array(len); | ||
|
|
||
| let ctx = CudaContext::new(0).unwrap(); | ||
| ctx.set_blocking_synchronize().unwrap(); | ||
| let ctx = Arc::new(ctx); | ||
|
|
||
| group.throughput(Throughput::Bytes((len * size_of::<u32>()) as u64)); | ||
| group.bench_with_input(BenchmarkId::new("u32", label), &array, |b, array| { | ||
| b.iter_custom(|iters| { | ||
| let mut total_time = Duration::ZERO; | ||
| for _ in 0..iters { | ||
| // This only measures kernel execution time, not memory transfers | ||
| let (_result, kernel_time) = | ||
| cuda_for_unpack_timed(array, Arc::clone(&ctx)).unwrap(); | ||
| total_time += kernel_time; | ||
| } | ||
| total_time | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| group.finish(); | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| fn benchmark_cpu_canonicalize(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("cpu_canonicalize"); | ||
|
|
||
| for (len, label) in DATA_SIZES { | ||
| let len = len.next_multiple_of(1024); | ||
| let array = make_bitpackable_array::<u32>(len); | ||
|
|
||
| group.throughput(Throughput::Bytes((len * size_of::<u32>()) as u64)); | ||
| group.bench_with_input(BenchmarkId::new("u32", label), &array, |b, array| { | ||
| b.iter(|| array.clone().into_array().to_canonical()); | ||
| }); | ||
| } | ||
|
|
||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group!( | ||
| benches, | ||
| benchmark_gpu_decompress_kernel_only, | ||
| benchmark_gpu_for_decompress_kernel_only, | ||
| ); | ||
| criterion_main!(benches); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.