github.com/segmentio/parquet-go@v0.0.0-20230712180008-5d42db8f0d47/internal/bitpack/unpack_int32_amd64.go (about)

     1  //go:build !purego
     2  
     3  package bitpack
     4  
     5  import (
     6  	"github.com/segmentio/parquet-go/internal/unsafecast"
     7  	"golang.org/x/sys/cpu"
     8  )
     9  
    10  //go:noescape
    11  func unpackInt32Default(dst []int32, src []byte, bitWidth uint)
    12  
    13  //go:noescape
    14  func unpackInt32x1to16bitsAVX2(dst []int32, src []byte, bitWidth uint)
    15  
    16  //go:noescape
    17  func unpackInt32x17to26bitsAVX2(dst []int32, src []byte, bitWidth uint)
    18  
    19  //go:noescape
    20  func unpackInt32x27to31bitsAVX2(dst []int32, src []byte, bitWidth uint)
    21  
    22  func unpackInt32(dst []int32, src []byte, bitWidth uint) {
    23  	hasAVX2 := cpu.X86.HasAVX2
    24  	switch {
    25  	case hasAVX2 && bitWidth <= 16:
    26  		unpackInt32x1to16bitsAVX2(dst, src, bitWidth)
    27  	case hasAVX2 && bitWidth <= 26:
    28  		unpackInt32x17to26bitsAVX2(dst, src, bitWidth)
    29  	case hasAVX2 && bitWidth <= 31:
    30  		unpackInt32x27to31bitsAVX2(dst, src, bitWidth)
    31  	case bitWidth == 32:
    32  		copy(dst, unsafecast.BytesToInt32(src))
    33  	default:
    34  		unpackInt32Default(dst, src, bitWidth)
    35  	}
    36  }