This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git


The following commit(s) were added to refs/heads/main by this push:
     new a06e17a5 perf(compute): reuse amd64 SIMD comparisons for 
numeric-to-bool casts (#1351)
a06e17a5 is described below

commit a06e17a52f7fe8207c54589efa0269977437c986
Author: Minh Vu <[email protected]>
AuthorDate: Mon Oct 19 18:17:15 2026 +0200

    perf(compute): reuse amd64 SIMD comparisons for numeric-to-bool casts 
(#1351)
    
    **What**
    - Use amd64 AVX2 and SSE4.2 comparisons for numeric-to-bool casts.
    
    **Why**
    - Compare values in batches on large arrays.
    
    **Implementation**
    - Keep scalar handling for short tails and unsupported builds.
    - Benchmark six types with valid and null masks at 64K and 1M rows.
    - Cover bitmap boundaries, slices, NaN, and signed zero.
---
 arrow/compute/boolean_cast_bench_test.go           |  77 +++++++++-
 arrow/compute/cast_test.go                         |  91 ++++++++++++
 arrow/compute/internal/kernels/boolean_cast.go     |   7 +-
 ...an_cast_neon_arm64.go => boolean_cast_amd64.go} |  20 ++-
 .../internal/kernels/boolean_cast_bench_test.go    |  50 +++++++
 .../internal/kernels/boolean_cast_neon_arm64.go    |  13 +-
 .../compute/internal/kernels/boolean_cast_noasm.go |   4 +-
 .../compute/internal/kernels/boolean_cast_test.go  | 165 +++++++++++++++++++++
 8 files changed, 408 insertions(+), 19 deletions(-)

diff --git a/arrow/compute/boolean_cast_bench_test.go 
b/arrow/compute/boolean_cast_bench_test.go
index 7c4e2873..180f4aa3 100644
--- a/arrow/compute/boolean_cast_bench_test.go
+++ b/arrow/compute/boolean_cast_bench_test.go
@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build go1.18
+//go:build go1.24
 
 package compute_test
 
@@ -65,12 +65,11 @@ func BenchmarkNumericToBoolCast(b *testing.B) {
                                        defer input.Release()
                                        opts := compute.DefaultCastOptions(true)
                                        opts.ToType = 
arrow.FixedWidthTypes.Boolean
-                                       ctx := context.Background()
+                                       ctx := 
compute.WithAllocator(context.Background(), mem)
 
                                        b.ReportAllocs()
                                        b.SetBytes(int64(size) * width)
-                                       b.ResetTimer()
-                                       for i := 0; i < b.N; i++ {
+                                       for b.Loop() {
                                                output, err := 
compute.CastArray(ctx, input, opts)
                                                if err != nil {
                                                        b.Fatal(err)
@@ -82,3 +81,73 @@ func BenchmarkNumericToBoolCast(b *testing.B) {
                }
        }
 }
+
+func BenchmarkNumericToBoolCastNullPatterns(b *testing.B) {
+       patterns := []struct {
+               name   string
+               isNull func(i, size int) bool
+       }{
+               {name: "all-valid", isNull: func(int, int) bool { return false 
}},
+               {name: "sparse-1pct", isNull: func(i, _ int) bool { return 
i%100 == 0 }},
+               {name: "alternating-null", isNull: func(i, _ int) bool { return 
i%2 == 0 }},
+               {name: "clustered50-null", isNull: func(i, _ int) bool { return 
(i/4096)%2 == 0 }},
+       }
+
+       for _, typ := range []arrow.DataType{
+               arrow.PrimitiveTypes.Int32,
+               arrow.PrimitiveTypes.Uint32,
+               arrow.PrimitiveTypes.Int64,
+               arrow.PrimitiveTypes.Uint64,
+               arrow.PrimitiveTypes.Float32,
+               arrow.PrimitiveTypes.Float64,
+       } {
+               width := int64(typ.(arrow.FixedWidthDataType).Bytes())
+               for _, size := range []int{65536, 1_000_000} {
+                       for _, pattern := range patterns {
+                               b.Run(fmt.Sprintf("type=%s/size=%d/nulls=%s", 
typ, size, pattern.name), func(b *testing.B) {
+                                       mem := memory.NewGoAllocator()
+                                       input := 
newBooleanCastBenchmarkArrayWithNullPattern(mem, typ, size, pattern.isNull)
+                                       defer input.Release()
+                                       opts := compute.DefaultCastOptions(true)
+                                       opts.ToType = 
arrow.FixedWidthTypes.Boolean
+                                       ctx := 
compute.WithAllocator(context.Background(), mem)
+
+                                       b.ReportAllocs()
+                                       b.SetBytes(int64(size) * width)
+                                       for b.Loop() {
+                                               output, err := 
compute.CastArray(ctx, input, opts)
+                                               if err != nil {
+                                                       b.Fatal(err)
+                                               }
+                                               output.Release()
+                                       }
+                               })
+                       }
+               }
+       }
+}
+
+func newBooleanCastBenchmarkArrayWithNullPattern(
+       mem memory.Allocator, typ arrow.DataType, size int, isNull func(i, size 
int) bool,
+) arrow.Array {
+       builder := array.NewBuilder(mem, typ)
+       builder.Reserve(size)
+       validIndex := 0
+       for i := 0; i < size; i++ {
+               if isNull(i, size) {
+                       builder.AppendNull()
+                       continue
+               }
+               value := "1"
+               if validIndex%2 == 0 {
+                       value = "0"
+               }
+               if err := builder.AppendValueFromString(value); err != nil {
+                       panic(err)
+               }
+               validIndex++
+       }
+       result := builder.NewArray()
+       builder.Release()
+       return result
+}
diff --git a/arrow/compute/cast_test.go b/arrow/compute/cast_test.go
index f514582c..532c3d62 100644
--- a/arrow/compute/cast_test.go
+++ b/arrow/compute/cast_test.go
@@ -466,6 +466,57 @@ func (c *CastSuite) TestNumericToBool() {
        }
 }
 
+func (c *CastSuite) TestNumericToBoolSIMDBoundaries() {
+       types := []arrow.DataType{
+               arrow.PrimitiveTypes.Int32,
+               arrow.PrimitiveTypes.Uint32,
+               arrow.PrimitiveTypes.Int64,
+               arrow.PrimitiveTypes.Uint64,
+               arrow.PrimitiveTypes.Float32,
+               arrow.PrimitiveTypes.Float64,
+       }
+       for _, dt := range types {
+               for _, size := range []int{0, 7, 8, 9, 15, 16, 17, 31, 32, 33} {
+                       c.Run(fmt.Sprintf("%s/size=%d", dt, size), func() {
+                               builder := array.NewBuilder(c.mem, dt)
+                               builder.Reserve(size + 1)
+                               for i := 0; i <= size; i++ {
+                                       if i%11 == 5 {
+                                               builder.AppendNull()
+                                               continue
+                                       }
+                                       value := "0"
+                                       if i%3 != 0 {
+                                               value = "1"
+                                       }
+                                       if err := 
builder.AppendValueFromString(value); err != nil {
+                                               c.T().Fatal(err)
+                                       }
+                               }
+                               base := builder.NewArray()
+                               builder.Release()
+                               input := array.NewSlice(base, 1, int64(size+1))
+                               base.Release()
+                               defer input.Release()
+
+                               expectedBuilder := 
array.NewBooleanBuilder(c.mem)
+                               for i := 1; i <= size; i++ {
+                                       if i%11 == 5 {
+                                               expectedBuilder.AppendNull()
+                                       } else {
+                                               expectedBuilder.Append(i%3 != 0)
+                                       }
+                               }
+                               expected := expectedBuilder.NewArray()
+                               expectedBuilder.Release()
+                               defer expected.Release()
+
+                               checkCast(c.T(), input, expected, 
*compute.DefaultCastOptions(true))
+                       })
+               }
+       }
+}
+
 func (c *CastSuite) TestNumericToBoolSpecialValues() {
        builder := array.NewFloat64Builder(c.mem)
        builder.AppendValues([]float64{
@@ -506,6 +557,46 @@ func (c *CastSuite) TestNumericToBoolSpecialValues() {
        checkCast(c.T(), sliced, expected, *compute.DefaultCastOptions(true))
 }
 
+func (c *CastSuite) TestNumericToBoolFloat32SpecialValues() {
+       builder := array.NewFloat32Builder(c.mem)
+       builder.AppendValues([]float32{
+               1,
+               float32(math.Copysign(0, -1)),
+               0,
+               float32(math.NaN()),
+               float32(math.Inf(1)),
+               float32(math.Inf(-1)),
+               1,
+               -1,
+               0,
+               1,
+               float32(math.Copysign(0, -1)),
+               float32(math.NaN()),
+               float32(math.Inf(1)),
+               float32(math.Inf(-1)),
+               0,
+               -1,
+               1,
+       }, nil)
+       input := builder.NewArray()
+       builder.Release()
+       defer input.Release()
+
+       sliced := array.NewSlice(input, 1, 16)
+       defer sliced.Release()
+
+       expectedBuilder := array.NewBooleanBuilder(c.mem)
+       expectedBuilder.AppendValues([]bool{
+               false, false, true, true, true, true, true, false,
+               true, false, true, true, true, false, true,
+       }, nil)
+       expected := expectedBuilder.NewArray()
+       expectedBuilder.Release()
+       defer expected.Release()
+
+       checkCast(c.T(), sliced, expected, *compute.DefaultCastOptions(true))
+}
+
 func (c *CastSuite) StringToBool() {
        for _, dt := range []arrow.DataType{arrow.BinaryTypes.String, 
arrow.BinaryTypes.LargeString} {
                c.checkCast(dt, arrow.FixedWidthTypes.Boolean,
diff --git a/arrow/compute/internal/kernels/boolean_cast.go 
b/arrow/compute/internal/kernels/boolean_cast.go
index 4232b0df..0b17ba5b 100644
--- a/arrow/compute/internal/kernels/boolean_cast.go
+++ b/arrow/compute/internal/kernels/boolean_cast.go
@@ -27,6 +27,11 @@ import (
        "github.com/apache/arrow-go/v18/arrow/compute/exec"
 )
 
+// Numeric-to-bool SIMD kernels compare against this shared, zero-initialized
+// scalar storage instead of taking the address of a per-call local value.
+// Eight bytes cover the widest supported numeric type.
+var numericToBoolZero [8]byte
+
 func isNonZero[T arrow.FixedWidthType](ctx *exec.KernelCtx, in []T, out 
[]byte) error {
        var zero T
        for i, v := range in {
@@ -37,7 +42,7 @@ func isNonZero[T arrow.FixedWidthType](ctx *exec.KernelCtx, 
in []T, out []byte)
 
 func numericToBoolKernel[T arrow.NumericType](typ arrow.Type) 
func(*exec.KernelCtx, []T, []byte) error {
        return func(ctx *exec.KernelCtx, in []T, out []byte) error {
-               return numericToBoolNeon(typ, ctx, in, out)
+               return numericToBoolSIMD(typ, ctx, in, out)
        }
 }
 
diff --git a/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go 
b/arrow/compute/internal/kernels/boolean_cast_amd64.go
similarity index 69%
copy from arrow/compute/internal/kernels/boolean_cast_neon_arm64.go
copy to arrow/compute/internal/kernels/boolean_cast_amd64.go
index 78211f29..75a72c88 100644
--- a/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go
+++ b/arrow/compute/internal/kernels/boolean_cast_amd64.go
@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build go1.18 && arm64 && !noasm && !appengine
+//go:build go1.18 && amd64 && !noasm && !appengine
 
 package kernels
 
@@ -27,8 +27,8 @@ import (
        "golang.org/x/sys/cpu"
 )
 
-func numericToBoolNeon[T arrow.NumericType](typ arrow.Type, ctx 
*exec.KernelCtx, in []T, out []byte) error {
-       if !cpu.ARM64.HasASIMD {
+func numericToBoolSIMD[T arrow.NumericType](typ arrow.Type, ctx 
*exec.KernelCtx, in []T, out []byte) error {
+       if pureGo {
                return isNonZero(ctx, in, out)
        }
 
@@ -36,12 +36,16 @@ func numericToBoolNeon[T arrow.NumericType](typ arrow.Type, 
ctx *exec.KernelCtx,
        bulk := len(in) &^ 7
        if bulk != 0 {
                left := arrow.GetBytes(in[:bulk])
-               right := unsafe.Slice((*byte)(unsafe.Pointer(&zero)), 
int(unsafe.Sizeof(zero)))
-               _comparison_neon(int(typ), int(CmpNE), neonCompareArrayScalar,
-                       unsafe.Pointer(&left[0]), unsafe.Pointer(&right[0]), 
unsafe.Pointer(&out[0]), int64(bulk/8))
+               right := numericToBoolZero[:int(unsafe.Sizeof(zero))]
+               // Avoid indirect calls through the comparison function map.
+               if cpu.X86.HasAVX2 {
+                       comparisonNotEqualArrScalarAvx2(typ, left, right, out, 
int64(bulk), 0)
+               } else {
+                       comparisonNotEqualArrScalarSSE4(typ, left, right, out, 
int64(bulk), 0)
+               }
        }
-       for i, v := range in[bulk:] {
-               bitutil.SetBitTo(out, bulk+i, v != zero)
+       for i, value := range in[bulk:] {
+               bitutil.SetBitTo(out, bulk+i, value != zero)
        }
        return nil
 }
diff --git a/arrow/compute/internal/kernels/boolean_cast_bench_test.go 
b/arrow/compute/internal/kernels/boolean_cast_bench_test.go
new file mode 100644
index 00000000..96bd3335
--- /dev/null
+++ b/arrow/compute/internal/kernels/boolean_cast_bench_test.go
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//go:build go1.24
+
+package kernels
+
+import (
+       "fmt"
+       "testing"
+       "unsafe"
+
+       "github.com/apache/arrow-go/v18/arrow"
+)
+
+func benchmarkNumericToBoolSIMD[T arrow.NumericType](b *testing.B, typ 
arrow.Type) {
+       for _, size := range []int{64, 1024, 65536} {
+               b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) {
+                       values := numericToBoolBoundaryValues[T](size)
+                       out := make([]byte, (size+7)/8)
+                       b.ReportAllocs()
+                       b.SetBytes(int64(size) * int64(unsafe.Sizeof(T(0))))
+                       for b.Loop() {
+                               if err := numericToBoolSIMD(typ, nil, values, 
out); err != nil {
+                                       b.Fatal(err)
+                               }
+                       }
+               })
+       }
+}
+
+func BenchmarkNumericToBoolSIMD(b *testing.B) {
+       b.Run("int32", func(b *testing.B) { 
benchmarkNumericToBoolSIMD[int32](b, arrow.INT32) })
+       b.Run("int64", func(b *testing.B) { 
benchmarkNumericToBoolSIMD[int64](b, arrow.INT64) })
+       b.Run("float32", func(b *testing.B) { 
benchmarkNumericToBoolSIMD[float32](b, arrow.FLOAT32) })
+       b.Run("float64", func(b *testing.B) { 
benchmarkNumericToBoolSIMD[float64](b, arrow.FLOAT64) })
+}
diff --git a/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go 
b/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go
index 78211f29..90592107 100644
--- a/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go
+++ b/arrow/compute/internal/kernels/boolean_cast_neon_arm64.go
@@ -27,7 +27,7 @@ import (
        "golang.org/x/sys/cpu"
 )
 
-func numericToBoolNeon[T arrow.NumericType](typ arrow.Type, ctx 
*exec.KernelCtx, in []T, out []byte) error {
+func numericToBoolSIMD[T arrow.NumericType](typ arrow.Type, ctx 
*exec.KernelCtx, in []T, out []byte) error {
        if !cpu.ARM64.HasASIMD {
                return isNonZero(ctx, in, out)
        }
@@ -36,9 +36,14 @@ func numericToBoolNeon[T arrow.NumericType](typ arrow.Type, 
ctx *exec.KernelCtx,
        bulk := len(in) &^ 7
        if bulk != 0 {
                left := arrow.GetBytes(in[:bulk])
-               right := unsafe.Slice((*byte)(unsafe.Pointer(&zero)), 
int(unsafe.Sizeof(zero)))
-               _comparison_neon(int(typ), int(CmpNE), neonCompareArrayScalar,
-                       unsafe.Pointer(&left[0]), unsafe.Pointer(&right[0]), 
unsafe.Pointer(&out[0]), int64(bulk/8))
+               right := numericToBoolZero[:int(unsafe.Sizeof(zero))]
+               if unsafe.Sizeof(zero) <= 2 {
+                       _comparison_narrow_neon(int(typ), int(CmpNE), 
neonCompareArrayScalar,
+                               unsafe.Pointer(&left[0]), 
unsafe.Pointer(&right[0]), unsafe.Pointer(&out[0]), int64(bulk/8))
+               } else {
+                       _comparison_neon(int(typ), int(CmpNE), 
neonCompareArrayScalar,
+                               unsafe.Pointer(&left[0]), 
unsafe.Pointer(&right[0]), unsafe.Pointer(&out[0]), int64(bulk/8))
+               }
        }
        for i, v := range in[bulk:] {
                bitutil.SetBitTo(out, bulk+i, v != zero)
diff --git a/arrow/compute/internal/kernels/boolean_cast_noasm.go 
b/arrow/compute/internal/kernels/boolean_cast_noasm.go
index 2bdd800c..cb4beff7 100644
--- a/arrow/compute/internal/kernels/boolean_cast_noasm.go
+++ b/arrow/compute/internal/kernels/boolean_cast_noasm.go
@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build go1.18 && (noasm || !arm64 || appengine)
+//go:build go1.18 && (noasm || (!amd64 && !arm64) || appengine)
 
 package kernels
 
@@ -23,6 +23,6 @@ import (
        "github.com/apache/arrow-go/v18/arrow/compute/exec"
 )
 
-func numericToBoolNeon[T arrow.NumericType](_ arrow.Type, ctx *exec.KernelCtx, 
in []T, out []byte) error {
+func numericToBoolSIMD[T arrow.NumericType](_ arrow.Type, ctx *exec.KernelCtx, 
in []T, out []byte) error {
        return isNonZero(ctx, in, out)
 }
diff --git a/arrow/compute/internal/kernels/boolean_cast_test.go 
b/arrow/compute/internal/kernels/boolean_cast_test.go
new file mode 100644
index 00000000..ff9f6bbb
--- /dev/null
+++ b/arrow/compute/internal/kernels/boolean_cast_test.go
@@ -0,0 +1,165 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//go:build go1.18
+
+package kernels
+
+import (
+       "bytes"
+       "fmt"
+       "math"
+       "testing"
+
+       "github.com/apache/arrow-go/v18/arrow"
+       "github.com/apache/arrow-go/v18/arrow/bitutil"
+)
+
+func checkNumericToBoolSIMD[T arrow.NumericType](t *testing.T, typ arrow.Type, 
values []T) {
+       t.Helper()
+
+       var zero T
+       for _, fill := range []byte{0, 0xff} {
+               nbytes := (len(values) + 7) / 8
+               backing := bytes.Repeat([]byte{fill}, nbytes+1)
+               backing[nbytes] = 0xa5
+               out := backing[:nbytes]
+               want := bytes.Repeat([]byte{fill}, nbytes)
+               for i, value := range values {
+                       bitutil.SetBitTo(want, i, value != zero)
+               }
+               if err := numericToBoolSIMD(typ, nil, values, out); err != nil {
+                       t.Fatal(err)
+               }
+               if !bytes.Equal(out, want) {
+                       t.Fatalf("fill=%#x: output = %08b, want %08b", fill, 
out, want)
+               }
+               if backing[nbytes] != 0xa5 {
+                       t.Fatal("cast wrote beyond the output bitmap")
+               }
+       }
+}
+
+func numericToBoolBoundaryValues[T arrow.NumericType](length int) []T {
+       values := make([]T, length)
+       for i := range values {
+               if i%3 != 0 {
+                       values[i] = T(1)
+               }
+       }
+       return values
+}
+
+func TestNumericToBoolSIMDBoundaries(t *testing.T) {
+       types := []struct {
+               name string
+               run  func(*testing.T, int)
+       }{
+               {
+                       name: "int8",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.INT8, 
numericToBoolBoundaryValues[int8](n))
+                       },
+               },
+               {
+                       name: "uint8",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.UINT8, 
numericToBoolBoundaryValues[uint8](n))
+                       },
+               },
+               {
+                       name: "int16",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.INT16, 
numericToBoolBoundaryValues[int16](n))
+                       },
+               },
+               {
+                       name: "uint16",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.UINT16, 
numericToBoolBoundaryValues[uint16](n))
+                       },
+               },
+               {
+                       name: "int32",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.INT32, 
numericToBoolBoundaryValues[int32](n))
+                       },
+               },
+               {
+                       name: "uint32",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.UINT32, 
numericToBoolBoundaryValues[uint32](n))
+                       },
+               },
+               {
+                       name: "int64",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.INT64, 
numericToBoolBoundaryValues[int64](n))
+                       },
+               },
+               {
+                       name: "uint64",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.UINT64, 
numericToBoolBoundaryValues[uint64](n))
+                       },
+               },
+               {
+                       name: "float32",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.FLOAT32, 
numericToBoolBoundaryValues[float32](n))
+                       },
+               },
+               {
+                       name: "float64",
+                       run: func(t *testing.T, n int) {
+                               checkNumericToBoolSIMD(t, arrow.FLOAT64, 
numericToBoolBoundaryValues[float64](n))
+                       },
+               },
+       }
+
+       for _, size := range []int{0, 7, 8, 9, 15, 16, 17, 31, 32, 33} {
+               for _, typ := range types {
+                       t.Run(fmt.Sprintf("%s/size=%d", typ.name, size), func(t 
*testing.T) {
+                               typ.run(t, size)
+                       })
+               }
+       }
+}
+
+func TestNumericToBoolSIMDFloatSpecialValues(t *testing.T) {
+       checkNumericToBoolSIMD(t, arrow.FLOAT32, []float32{
+               0, float32(math.Copysign(0, -1)), float32(math.NaN()),
+               float32(math.Inf(1)), float32(math.Inf(-1)), 1, -1, 0, 1,
+       })
+       checkNumericToBoolSIMD(t, arrow.FLOAT64, []float64{
+               0, math.Copysign(0, -1), math.NaN(), math.Inf(1),
+               math.Inf(-1), 1, -1, 0, 1, math.NaN(),
+       })
+}
+
+func TestNumericToBoolSIMDNoAllocations(t *testing.T) {
+       values := numericToBoolBoundaryValues[int64](33)
+       out := make([]byte, bitutil.BytesForBits(int64(len(values))))
+       allocs := testing.AllocsPerRun(100, func() {
+               if err := numericToBoolSIMD(arrow.INT64, nil, values, out); err 
!= nil {
+                       t.Fatal(err)
+               }
+       })
+       if allocs != 0 {
+               t.Fatalf("numericToBoolSIMD allocated %g times, want 0", allocs)
+       }
+}

Reply via email to