github.com/segmentio/parquet-go@v0.0.0-20230712180008-5d42db8f0d47/encoding/delta/binary_packed_amd64_test.go (about) 1 //go:build amd64 && !purego 2 3 package delta 4 5 import ( 6 "testing" 7 8 "golang.org/x/sys/cpu" 9 ) 10 11 func requireAVX2(t testing.TB) { 12 if !cpu.X86.HasAVX2 { 13 t.Skip("CPU does not support AVX2") 14 } 15 } 16 17 func TestBlockDeltaInt32AVX2(t *testing.T) { 18 requireAVX2(t) 19 testBlockDeltaInt32(t, blockDeltaInt32AVX2) 20 } 21 22 func TestBlockMinInt32AVX2(t *testing.T) { 23 requireAVX2(t) 24 testBlockMinInt32(t, blockMinInt32AVX2) 25 } 26 27 func TestBlockSubInt32AVX2(t *testing.T) { 28 requireAVX2(t) 29 testBlockSubInt32(t, blockSubInt32AVX2) 30 } 31 32 func TestBlockBitWidthsInt32AVX2(t *testing.T) { 33 requireAVX2(t) 34 testBlockBitWidthsInt32(t, blockBitWidthsInt32AVX2) 35 } 36 37 func TestEncodeMiniBlockInt32AVX2(t *testing.T) { 38 requireAVX2(t) 39 testEncodeMiniBlockInt32(t, 40 func(dst []byte, src *[miniBlockSize]int32, bitWidth uint) { 41 encodeMiniBlockInt32AVX2(&dst[0], src, bitWidth) 42 }, 43 ) 44 } 45 46 func BenchmarkBlockDeltaInt32AVX2(b *testing.B) { 47 requireAVX2(b) 48 benchmarkBlockDeltaInt32(b, blockDeltaInt32AVX2) 49 } 50 51 func BenchmarkBlockMinInt32AVX2(b *testing.B) { 52 requireAVX2(b) 53 benchmarkBlockMinInt32(b, blockMinInt32AVX2) 54 } 55 56 func BenchmarkBlockSubInt32AVX2(b *testing.B) { 57 requireAVX2(b) 58 benchmarkBlockSubInt32(b, blockSubInt32AVX2) 59 } 60 61 func BenchmarkBlockBitWidthsInt32AVX2(b *testing.B) { 62 requireAVX2(b) 63 benchmarkBlockBitWidthsInt32(b, blockBitWidthsInt32AVX2) 64 } 65 66 func BenchmarkEncodeMiniBlockInt32AVX2(b *testing.B) { 67 requireAVX2(b) 68 benchmarkEncodeMiniBlockInt32(b, 69 func(dst []byte, src *[miniBlockSize]int32, bitWidth uint) { 70 encodeMiniBlockInt32AVX2(&dst[0], src, bitWidth) 71 }, 72 ) 73 } 74 75 func TestBlockDeltaInt64AVX2(t *testing.T) { 76 requireAVX2(t) 77 testBlockDeltaInt64(t, blockDeltaInt64AVX2) 78 } 79 80 func TestBlockMinInt64AVX2(t *testing.T) { 81 requireAVX2(t) 82 testBlockMinInt64(t, blockMinInt64AVX2) 83 } 84 85 func TestBlockSubInt64AVX2(t *testing.T) { 86 requireAVX2(t) 87 testBlockSubInt64(t, blockSubInt64AVX2) 88 } 89 90 func TestBlockBitWidthsInt64AVX2(t *testing.T) { 91 requireAVX2(t) 92 testBlockBitWidthsInt64(t, blockBitWidthsInt64AVX2) 93 } 94 95 func TestEncodeMiniBlockInt64AVX2(t *testing.T) { 96 requireAVX2(t) 97 testEncodeMiniBlockInt64(t, 98 func(dst []byte, src *[miniBlockSize]int64, bitWidth uint) { 99 encodeMiniBlockInt64AVX2(&dst[0], src, bitWidth) 100 }, 101 ) 102 } 103 104 func BenchmarkBlockDeltaInt64AVX2(b *testing.B) { 105 requireAVX2(b) 106 benchmarkBlockDeltaInt64(b, blockDeltaInt64AVX2) 107 } 108 109 func BenchmarkBlockMinInt64AVX2(b *testing.B) { 110 requireAVX2(b) 111 benchmarkBlockMinInt64(b, blockMinInt64AVX2) 112 } 113 114 func BenchmarkBlockSubInt64AVX2(b *testing.B) { 115 requireAVX2(b) 116 benchmarkBlockSubInt64(b, blockSubInt64AVX2) 117 } 118 119 func BenchmarkBlockBitWidthsInt64AVX2(b *testing.B) { 120 requireAVX2(b) 121 benchmarkBlockBitWidthsInt64(b, blockBitWidthsInt64AVX2) 122 } 123 124 func BenchmarkEncodeMiniBlockInt64AVX2(b *testing.B) { 125 requireAVX2(b) 126 benchmarkEncodeMiniBlockInt64(b, 127 func(dst []byte, src *[miniBlockSize]int64, bitWidth uint) { 128 encodeMiniBlockInt64AVX2(&dst[0], src, bitWidth) 129 }, 130 ) 131 }