Quellcode durchsuchen

WIP

trials/PERF_try1
Kris Kwiatkowski vor 6 Jahren
Ursprung
Commit
70b81002a7
2 geänderte Dateien mit 26 neuen und 10 gelöschten Zeilen
  1. +2
    -2
      Makefile
  2. +24
    -8
      p503/arith_decl.go

+ 2
- 2
Makefile Datei anzeigen

@@ -12,7 +12,7 @@ OPTS ?=
OPTS_TAGS ?= -tags=noasm
NOASM ?=
# -run="NonExistent" is set to make sure tests are not run before benchmarking
BENCH_OPTS ?= -bench=. -run="NonExistent"
BENCH_OPTS ?= -bench=. -run="NonExistent" -benchmem
# whether to be verbose
V ?= 1

@@ -22,7 +22,7 @@ endif

ifeq ($(V),1)
OPTS += -v # Be verbose
BENCH_OPTS += -gcflags=-m # Show results from inlining
BENCH_OPTS += -gcflags="-m -m" # Show results from inlining
endif

all: test


+ 24
- 8
p503/arith_decl.go Datei anzeigen

@@ -41,7 +41,13 @@ func fp503StrongReduce(x *FpElement)
// Concrete implementation depends on capabilities of the CPU which
// are resolved at runtime. CPUs with ADCX, ADOX and MULX support
// run most optimized implementation
var fp503Mul func(z *FpElementX2, x, y *FpElement)
func fp503Mul(z *FpElementX2, x, y *FpElement) {
if cpu.HasBMI2 {
mulWithMULXADX(z, x, y)
} else {
mul(z, x, y)
}
}

// Mul implementattion for legacy CPUs
//go:noescape
@@ -58,7 +64,17 @@ func mulWithMULXADX(z *FpElementX2, x, y *FpElement)

// Computes the Montgomery reduction z = x R^{-1} (mod 2*p). On return value
// of x may be changed. z=x not allowed.
var fp503MontgomeryReduce func(z *FpElement, x *FpElementX2)
func fp503MontgomeryReduce(z *FpElement, x *FpElementX2) {
if cpu.HasBMI2 {
if cpu.HasADX {
redcWithMULXADX(z, x)
} else {
redcWithMULX(z, x)
}
} else {
redc(z, x)
}
}

func redc(z *FpElement, x *FpElementX2)

@@ -76,14 +92,14 @@ func redcWithMULXADX(z *FpElement, x *FpElementX2)
func init() {
if cpu.HasBMI2 {
if cpu.HasADX {
fp503Mul = mulWithMULXADX
fp503MontgomeryReduce = redcWithMULXADX
//fp503Mul = mulWithMULXADX
//fp503MontgomeryReduce = redcWithMULXADX
} else {
fp503Mul = mulWithMULX
fp503MontgomeryReduce = redcWithMULX
//fp503Mul = mulWithMULX
//fp503MontgomeryReduce = redcWithMULX
}
} else {
fp503Mul = mul
fp503MontgomeryReduce = redc
//fp503Mul = mul
//fp503MontgomeryReduce = redc
}
}

Laden…
Abbrechen
Speichern