diff options
| author | Agniva De Sarker <agnivade@yahoo.co.in> | 2017-09-09 19:47:37 +0530 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2017-09-20 21:43:00 +0000 |
| commit | d2f317218bf563121e80b36bb06a8ba46d040a20 (patch) | |
| tree | 9b106df1bfdd0751c57edd4501aaf086ca1b4045 /src/math/exp_asm.go | |
| parent | 475df0ebccaf0871c86b2c0b55ee841aede324b7 (diff) | |
| download | go-d2f317218bf563121e80b36bb06a8ba46d040a20.tar.xz | |
math: implement fast path for Exp
- using FMA and AVX instructions if available to speed-up
Exp calculation on amd64
- using a data table instead of #define'ed constants because
these instructions do not support loading floating point immediates.
One has to use a memory operand / register.
- Benchmark results on Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz:
Original vs New (non-FMA path)
name old time/op new time/op delta
Exp 16.0ns ± 1% 16.1ns ± 3% ~ (p=0.308 n=9+10)
Original vs New (FMA path)
name old time/op new time/op delta
Exp 16.0ns ± 1% 13.7ns ± 2% -14.80% (p=0.000 n=9+10)
Change-Id: I3d8986925d82b39b95ee979ae06f59d7e591d02e
Reviewed-on: https://go-review.googlesource.com/62590
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/math/exp_asm.go')
| -rw-r--r-- | src/math/exp_asm.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/math/exp_asm.go b/src/math/exp_asm.go new file mode 100644 index 0000000000..421618eea9 --- /dev/null +++ b/src/math/exp_asm.go @@ -0,0 +1,11 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build amd64 amd64p32 + +package math + +import "internal/cpu" + +var useFMA = cpu.X86.HasAVX && cpu.X86.HasFMA |
