Skip to content

Commit 49ec12a

Browse files
committed
w
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 73dbb94 commit 49ec12a

3 files changed

Lines changed: 30 additions & 14 deletions

File tree

vortex-compute/src/lane_kernels/map_in_place.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
use vortex_buffer::BitBuffer;
1010

11+
use crate::lane_kernels::CHUNK_LEN;
1112
use crate::lane_kernels::sink::IndexedSink;
1213

1314
/// Extension trait providing in-place lane-kernel methods on any [`IndexedSink`].
@@ -54,14 +55,14 @@ pub trait IndexedSinkExt: IndexedSink + Sized {
5455

5556
let mut values = self;
5657
let len = values.len();
57-
let chunks_count = len / 64;
58-
let remainder = len % 64;
58+
let chunks_count = len / CHUNK_LEN;
59+
let remainder = len % CHUNK_LEN;
5960

6061
for chunk_idx in 0..chunks_count {
61-
chunk(&mut values, &mut f, chunk_idx * 64, 64);
62+
chunk(&mut values, &mut f, chunk_idx * CHUNK_LEN, CHUNK_LEN);
6263
}
6364
if remainder != 0 {
64-
chunk(&mut values, &mut f, chunks_count * 64, remainder);
65+
chunk(&mut values, &mut f, chunks_count * CHUNK_LEN, remainder);
6566
}
6667
}
6768

vortex-compute/src/lane_kernels/map_into.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::mem::MaybeUninit;
88

99
use vortex_buffer::BitBuffer;
1010

11+
use crate::lane_kernels::CHUNK_LEN;
1112
use crate::lane_kernels::source::IndexedSource;
1213

1314
/// Extension trait providing out-of-place lane-kernel methods on any [`IndexedSource`].
@@ -144,14 +145,14 @@ pub trait IndexedSourceExt: IndexedSource + Sized {
144145
let len = values.len();
145146
assert_eq!(out.len(), len, "out must have the same length as values");
146147

147-
let chunks_count = len / 64;
148-
let remainder = len % 64;
148+
let chunks_count = len / CHUNK_LEN;
149+
let remainder = len % CHUNK_LEN;
149150

150151
for chunk_idx in 0..chunks_count {
151-
chunk(&values, out, &mut f, chunk_idx * 64, 64);
152+
chunk(&values, out, &mut f, chunk_idx * CHUNK_LEN, CHUNK_LEN);
152153
}
153154
if remainder != 0 {
154-
chunk(&values, out, &mut f, chunks_count * 64, remainder);
155+
chunk(&values, out, &mut f, chunks_count * CHUNK_LEN, remainder);
155156
}
156157
}
157158

@@ -216,17 +217,17 @@ pub trait IndexedSourceExt: IndexedSource + Sized {
216217
let len = values.len();
217218
assert_eq!(out.len(), len, "out must have the same length as values");
218219

219-
let chunks_count = len / 64;
220-
let remainder = len % 64;
220+
let chunks_count = len / CHUNK_LEN;
221+
let remainder = len % CHUNK_LEN;
221222

222223
for chunk_idx in 0..chunks_count {
223-
let base = chunk_idx * 64;
224-
if chunk(&values, out, &mut f, base, 64) {
225-
return Err(attribute_failure_no_mask(&values, base, 64, &mut f));
224+
let base = chunk_idx * CHUNK_LEN;
225+
if chunk(&values, out, &mut f, base, CHUNK_LEN) {
226+
return Err(attribute_failure_no_mask(&values, base, CHUNK_LEN, &mut f));
226227
}
227228
}
228229
if remainder != 0 {
229-
let base = chunks_count * 64;
230+
let base = chunks_count * CHUNK_LEN;
230231
if chunk(&values, out, &mut f, base, remainder) {
231232
return Err(attribute_failure_no_mask(&values, base, remainder, &mut f));
232233
}

vortex-compute/src/lane_kernels/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ pub use sink::IndexedSink;
3333
pub use sink::ReinterpretSink;
3434
pub use source::IndexedSource;
3535
pub use source::LaneZip;
36+
37+
/// Loop-tiling chunk length for the **no-mask** kernels ([`IndexedSourceExt::map_into`],
38+
/// [`IndexedSourceExt::try_map_into`], [`IndexedSinkExt::map_into_in_place`]).
39+
///
40+
/// This is a pure tuning knob: those kernels split the lane range into
41+
/// `len / CHUNK_LEN` full chunks plus a remainder, so any value yields correct
42+
/// results and only the codegen/tiling changes. Vary it to tune performance.
43+
///
44+
/// It does **not** apply to the masked or bit-packed kernels: those consume one
45+
/// [`BitBuffer::chunks`] u64 validity word per chunk and pack per-lane fail bits
46+
/// with `<< bit_idx` into a `u64`, so their chunk length is locked to 64.
47+
///
48+
/// [`BitBuffer::chunks`]: vortex_buffer::BitBuffer::chunks
49+
pub(crate) const CHUNK_LEN: usize = 64;

0 commit comments

Comments
 (0)