Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ arch is therefore a durable foundation. The numeric loops live in
on every 64-bit target Go supports (amd64, arm64, ppc64le, loong64, riscv64,
s390x), behind the same API and held to the same tests.

The one-dimensional float64 kernels that other libraries need too live once, in
[go-simd/floats](https://github.com/go-simd/floats) (K1 of the go-scikit
[performance campaign](https://github.com/go-scikit/roadmap/blob/main/docs/performance-campaign.md)),
which this module imports: on amd64 (AVX2) and arm64 (NEON) the elementwise
`Add`/`Sub`/`Mul`/`Div`, `Sqrt`, `Max`/`Min` and `Clip` kernels, and everywhere
`Exp`, `Log` and the correctly rounded float32 `Exp`/`Log` (the AVX2 and NEON
kernels were written here and moved down). **`Sum` is NumPy's pairwise sum**
(`floats.SumPairwise`): bit-identical to `np.sum` of a contiguous 1-D float64
array, on every architecture, at every size. It replaces lane-parallel sums whose
last bits differed from NumPy's and from one architecture to the next, and it is
serial (a multicore split would regroup NumPy's order). The other architectures
keep their own elementwise kernels here until floats has them.

## Goroutines

Operations on large arrays are spread over `GOMAXPROCS` goroutines. After the
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ module github.com/go-ndarray/ndarray

go 1.27.2

require github.com/go-fft/fft v0.28.11
require (
github.com/go-fft/fft v0.28.11
github.com/go-simd/floats v0.9.0
)

require golang.org/x/sys v0.49.0 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
github.com/go-fft/fft v0.28.11 h1:ZfT78fSmPjZU2E9PgkSI/0f0E3sesYpl13GHmIFzRGc=
github.com/go-fft/fft v0.28.11/go.mod h1:GN5V4TWCjV05ECqH1ONfjFM6Z1m2shqCdssxKGqQ41s=
github.com/go-simd/floats v0.9.0 h1:P/sMlwYWwaqCah/cMcBRfffK1JcUxXZVj76f4AwQRN0=
github.com/go-simd/floats v0.9.0/go.mod h1:Aq5a6oY5pUqm9Hpi+iV2nrNmaaUb0rwHvUHIerXWSvA=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
17 changes: 5 additions & 12 deletions internal/kernels/asmgen/amd64/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ import (

func main() {
f := emit.NewFile("amd64")
f.Add(sumKernel())
f.Add(sqrtKernel())
f.Add(extremeKernel("maxSSE2", "MAXPD", "MAXSD"))
f.Add(extremeKernel("minSSE2", "MINPD", "MINSD"))
f.Add(binKernel("addSSE2", "ADDPD", "ADDSD"))
f.Add(binKernel("subSSE2", "SUBPD", "SUBSD"))
f.Add(binKernel("mulSSE2", "MULPD", "MULSD"))
f.Add(binKernel("divSSE2", "DIVPD", "DIVSD"))
// The float64 sum, sqrt, max/min and add/sub/mul/div kernels, and the float32
// exp/log and float64 log kernels, moved to go-simd/floats (K1 of the
// go-scikit performance campaign): sumKernel, sqrtKernel, extremeKernel,
// binKernel, exp32CRKernel, log32CRKernel and logKernel below are no longer
// emitted.
f.Add(gemmFMAKernel())
f.Add(gemm32FMAKernel())
for mr := 1; mr <= gemmMR; mr++ {
Expand All @@ -54,10 +51,6 @@ func main() {
f.Add(dotFMAKernel())
f.Add(gemmSSE2HalfKernel())
f.Add(amd64.FeatureProbe("hasFMA", amd64.FMA))
f.Add(amd64.FeatureProbe("hasAVX2", amd64.AVX2))
f.Add(exp32CRKernel())
f.Add(log32CRKernel())
f.Add(logKernel())
f.Add(blocks8Kernel())
f.Add(bin32Kernel("add32SSE2", "ADDPS", "ADDSS"))
f.Add(bin32Kernel("sub32SSE2", "SUBPS", "SUBSS"))
Expand Down
11 changes: 3 additions & 8 deletions internal/kernels/asmgen/arm64/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,15 @@ func reduceSig() arm64.Signature {

func main() {
f := emit.NewFile("arm64")
f.Add(sumKernel())
// The float64 sum, sqrt, add/sub/mul/div and max/min kernels moved to
// go-simd/floats (K1 of the go-scikit performance campaign): sumKernel,
// sqrtKernel, binKernel and extremumKernel below are no longer emitted.
f.Add(dotKernel())
f.Add(sqrtKernel())
f.Add(binKernel("addNEON", "VFADD", "FADDD"))
f.Add(binKernel("subNEON", "VFSUB", "FSUBD"))
f.Add(binKernel("mulNEON", "VFMUL", "FMULD"))
f.Add(binKernel("divNEON", "VFDIV", "FDIVD"))
f.Add(bin32Kernel("add32NEON", "VFADD", "FADDS"))
f.Add(bin32Kernel("sub32NEON", "VFSUB", "FSUBS"))
f.Add(bin32Kernel("mul32NEON", "VFMUL", "FMULS"))
f.Add(bin32Kernel("div32NEON", "VFDIV", "FDIVS"))
f.Add(sqrt32Kernel())
f.Add(extremumKernel("maxNEON", "VFMAX", "FMAXD"))
f.Add(extremumKernel("minNEON", "VFMIN", "FMIND"))
f.Add(extremum32Kernel("max32NEON", "VFMAX", "FMAXS"))
f.Add(extremum32Kernel("min32NEON", "VFMIN", "FMINS"))
f.Add(gemmKernel())
Expand Down
270 changes: 0 additions & 270 deletions internal/kernels/exp.go

This file was deleted.

Loading
Loading