Skip to content

perf(compute): vectorize numeric to boolean casts - #1282

Merged
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:perf/compute-numeric-to-bool-simd
Sep 3, 2026
Merged

perf(compute): vectorize numeric to boolean casts#1282
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:perf/compute-numeric-to-bool-simd

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Adds an ARM64 NEON fast path for numeric to boolean casts.
  • Reuses the existing NEON array != scalar comparison kernel to produce the output bitmap.
  • Covers int32, uint32, int64, uint64, float32, and float64.
  • Keeps the scalar path for narrow integers, noasm builds, unsupported CPUs, and appengine.
  • Adds coverage for NaN, signed zero, infinities, sliced input, and bitmap tails.
  • Adds a benchmark matrix for the supported types, sizes, and zero distributions.

Benchmark

Apple M1 Pro, GOMAXPROCS=1, compared with -tags noasm.

  • 32-bit types: about 9x faster at 65K values and about 14x faster at 1M values.
  • 64-bit types: about 6x faster at 65K values and about 8x faster at 1M values.
  • Small arrays keep the same allocation count and retain the scalar tail path.

Tests

  • go test ./arrow/compute ./arrow/compute/internal/kernels
  • go test -tags noasm ./arrow/compute ./arrow/compute/internal/kernels
  • amd64 compile check for the compute package noasm fallback

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally on Apple M1: the NEON path is exercised natively and passes, including NaN, signed zero, infinities, sliced inputs, and bitmap tails; noasm parity passes. Reusing the existing comparison kernel keeps the semantics aligned with the scalar isNonZero path.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow Go maintainer.

@zeroshade
zeroshade merged commit 497a462 into apache:main Sep 3, 2026
42 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants