github.com/parquet-go/parquet-go@v0.20.0/encoding/rle/rle_amd64.go (about)

     1  //go:build !purego
     2  
     3  package rle
     4  
     5  import (
     6  	"golang.org/x/sys/cpu"
     7  )
     8  
     9  var (
    10  	encodeInt32IndexEqual8Contiguous func(words [][8]int32) int
    11  	encodeInt32Bitpack               func(dst []byte, src [][8]int32, bitWidth uint) int
    12  	encodeBytesBitpack               func(dst []byte, src []uint64, bitWidth uint) int
    13  	decodeBytesBitpack               func(dst, src []byte, count, bitWidth uint)
    14  )
    15  
    16  func init() {
    17  	switch {
    18  	case cpu.X86.HasAVX2:
    19  		encodeInt32IndexEqual8Contiguous = encodeInt32IndexEqual8ContiguousAVX2
    20  		encodeInt32Bitpack = encodeInt32BitpackAVX2
    21  	default:
    22  		encodeInt32IndexEqual8Contiguous = encodeInt32IndexEqual8ContiguousSSE
    23  		encodeInt32Bitpack = encodeInt32BitpackDefault
    24  	}
    25  
    26  	switch {
    27  	case cpu.X86.HasBMI2:
    28  		encodeBytesBitpack = encodeBytesBitpackBMI2
    29  		decodeBytesBitpack = decodeBytesBitpackBMI2
    30  	default:
    31  		encodeBytesBitpack = encodeBytesBitpackDefault
    32  		decodeBytesBitpack = decodeBytesBitpackDefault
    33  	}
    34  }
    35  
    36  //go:noescape
    37  func encodeBytesBitpackBMI2(dst []byte, src []uint64, bitWidth uint) int
    38  
    39  //go:noescape
    40  func encodeInt32IndexEqual8ContiguousAVX2(words [][8]int32) int
    41  
    42  //go:noescape
    43  func encodeInt32IndexEqual8ContiguousSSE(words [][8]int32) int
    44  
    45  //go:noescape
    46  func encodeInt32Bitpack1to16bitsAVX2(dst []byte, src [][8]int32, bitWidth uint) int
    47  
    48  func encodeInt32BitpackAVX2(dst []byte, src [][8]int32, bitWidth uint) int {
    49  	switch {
    50  	case bitWidth == 0:
    51  		return 0
    52  	case bitWidth <= 16:
    53  		return encodeInt32Bitpack1to16bitsAVX2(dst, src, bitWidth)
    54  	default:
    55  		return encodeInt32BitpackDefault(dst, src, bitWidth)
    56  	}
    57  }
    58  
    59  //go:noescape
    60  func decodeBytesBitpackBMI2(dst, src []byte, count, bitWidth uint)