Skip to content

Commit 036e9a2

Browse files
committed
Compare primitive values through the shared RowFn executor
PrimitiveCompare only selects the predicate for each primitive type and operator. The RowFn executor handles decoding, batch constants, validity, and packed Boolean output, so the private lane kernel packing path and PrimitiveOperand are removed. CompareArgs borrows both operands and builds their primitive dtypes, so a call does not allocate. The public Binary identity and the floating-point total ordering are unchanged. A constant on either side gets the same full-width loop in the rustc 1.99.1 LLVM IR for x86 AVX-512 and aarch64, so the comparison does not move a constant left operand to the right. Signed-off-by: Connor Tsui <[email protected]>
1 parent 518ee6e commit 036e9a2

12 files changed

Lines changed: 152 additions & 295 deletions

File tree

‎vortex-array/benches/compare.rs‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33

44
//! Benchmarks for the binary comparison path, over every array kind it accepts.
55
//!
6-
//! The primitive cases carry `#[cpu_features]`, so they are measured on every walltime
7-
//! CPU-feature leg rather than in simulation. Each is written once and compiled differently
8-
//! per leg: today the primitive comparison path is a portable lane kernel, and how well it
9-
//! auto-vectorizes is decided by the build. That is the baseline a hand-written kernel
10-
//! selected through `cfg(target_feature)` has to beat, measured on the silicon it would run
11-
//! on.
6+
//! Primitive cases use `#[cpu_features]` so walltime runs exercise the multiversioned Boolean
7+
//! collector used by [`RowFn`] on each CPU-feature runner. Simulation does not measure those
8+
//! target-specific paths.
129
//!
13-
//! Every case here compares one array against another, which is the shape the path is tuned for.
14-
//! The three constant cases that remain — boolean, integer, and string — are a regression guard on
15-
//! constant handling rather than coverage of it: a constant operand is decoded the same way
16-
//! whatever it holds. Constant orientation is measured once, in `binary_ops.rs`.
10+
//! Array-pair cases cover the comparison kernels. Boolean, integer, and string constant cases are
11+
//! regression guards rather than exhaustive constant coverage. Shared constant setup is measured
12+
//! in `binary_ops.rs` with both operand orientations, so it does not need a full matrix here.
1713
//!
18-
//! The boolean, decimal, string, and struct cases are not tagged. A wider vector register is
19-
//! not what decides them: booleans are already word-at-a-time over a bitmap, decimals are
20-
//! `i128`, and the string and struct cases are dominated by view chasing and per-field
21-
//! dispatch. They stay in simulation.
14+
//! Boolean, decimal, string, and struct cases stay in simulation. They use bitmap operations,
15+
//! `i128` comparisons, view access, or per-field dispatch rather than the multiversioned collector.
16+
//!
17+
//! [`RowFn`]: vortex_array::scalar_fn::unstable::row::RowFn
2218
2319
#![expect(clippy::unwrap_used)]
2420

@@ -66,7 +62,7 @@ fn main() {
6662
divan::main();
6763
}
6864

69-
// Sized to keep CodSpeed simulation under 1ms per benchmark.
65+
// Keep simulated workloads within CodSpeed's per-case runtime limit.
7066
const ARRAY_SIZE: usize = 8_192;
7167

7268
fn bench_compare(bencher: Bencher, lhs: ArrayRef, rhs: ArrayRef, op: Operator) {

‎vortex-array/src/scalar_fn/fns/binary/compare/mod.rs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
//! Native comparison kernels.
55
//!
66
//! [`execute_compare`] dispatches on the logical [`DType`] of its operands and evaluates every
7-
//! comparison directly over Vortex canonical arrays: bit buffers for booleans, lane kernels from
8-
//! `vortex-compute` for primitives and decimals, binary views for strings/bytes, and a row-wise
9-
//! comparator for nested types. There is no Arrow fallback.
7+
//! comparison directly over Vortex canonical arrays: bit buffers for booleans, [`RowFn`] for
8+
//! primitives, lane kernels from `vortex-compute` for decimals, binary views for strings/bytes, and
9+
//! a row-wise comparator for nested types. There is no Arrow fallback.
1010
//!
11-
//! Floating point values compare with Vortex's total ordering (`NaN` is the largest value,
12-
//! `-0.0 < +0.0`, and equality is bitwise), matching [`Scalar`] comparison semantics.
11+
//! Floating-point values use the same total ordering as [`Scalar`]: negative NaNs sort below
12+
//! negative infinity, positive NaNs sort above positive infinity, and `-0.0 < +0.0`. Equality is
13+
//! bitwise, so signed zeros and distinct NaN payloads remain distinct.
1314
//!
1415
//! Binary scalar functions can execute through encoding-specific kernels before reaching the native
1516
//! dispatcher. [`CompareExecuteAdaptor`] connects these execution paths to [`CompareKernel`], which
1617
//! lets an encoding compare values without first converting them to canonical arrays.
18+
//!
19+
//! [`RowFn`]: crate::scalar_fn::unstable::row::RowFn
1720
1821
use std::cmp::Ordering;
1922

@@ -209,7 +212,7 @@ fn compare_arrays(
209212
)
210213
.into_array()),
211214
DType::Bool(_) => boolean::compare_bool(lhs, rhs, op, nullability, ctx),
212-
DType::Primitive(..) => primitive::compare_primitive(lhs, rhs, op, nullability, ctx),
215+
DType::Primitive(..) => primitive::compare_primitive(lhs, rhs, op, ctx),
213216
DType::Decimal(..) => decimal::compare_decimal(lhs, rhs, op, nullability, ctx),
214217
DType::Utf8(_) | DType::Binary(_) => bytes::compare_bytes(lhs, rhs, op, nullability, ctx),
215218
DType::Struct(..) | DType::List(..) | DType::FixedSizeList(..) | DType::Map(..) => {

0 commit comments

Comments
 (0)