gitee.com/quant1x/engine@v1.8.4/utils/optimize.go (about)

     1  package utils
     2  
     3  import (
     4  	"errors"
     5  	"gitee.com/quant1x/gox/logger"
     6  	"gitee.com/quant1x/num"
     7  	"golang.org/x/sys/cpu"
     8  )
     9  
    10  var (
    11  	ErrAccelerationNotSupported = errors.New("acceleration not supported on this platform")
    12  )
    13  
    14  // Optimize 系统优化系列
    15  func Optimize() {
    16  	// 如果支持AVX2就打开
    17  	if cpu.X86.HasAVX2 && cpu.X86.HasFMA {
    18  		num.SetAvx2Enabled(true)
    19  	} else {
    20  		logger.Warn(ErrAccelerationNotSupported)
    21  	}
    22  }