-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfft_amd64.go
31 lines (25 loc) · 894 Bytes
/
fft_amd64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//go:build amd64 && !purego
package fftg
import "golang.org/x/sys/cpu"
// fftInPlace is a top-level function for FFT.
func fftInPlace(coeffs []complex128, buff []float64, tw []complex128, coeffsOut []complex128) {
if cpu.X86.HasAVX2 && cpu.X86.HasFMA && len(coeffs) >= MinDegree {
cmplxToFloat4AssignAVX2(coeffs, buff)
fftInPlaceAVX2(buff, tw)
float4ToCmplxAssignAVX2(buff, coeffsOut)
return
}
copy(coeffsOut, coeffs)
fftInPlaceGeneric(coeffsOut, tw)
}
// invfftInPlace is a top-level function for inverse FFT.
func invfftInPlace(coeffs []complex128, buff []float64, twInv []complex128, coeffsOut []complex128) {
if cpu.X86.HasAVX2 && cpu.X86.HasFMA && len(coeffs) >= MinDegree {
cmplxToFloat4AssignAVX2(coeffs, buff)
invfftInPlaceAVX2(buff, twInv)
float4ToCmplxAssignAVX2(buff, coeffsOut)
return
}
copy(coeffsOut, coeffs)
invfftInPlaceGeneric(coeffsOut, twInv)
}