Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix runtime architecture decision flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kilic committed Mar 17, 2020
1 parent 3714b40 commit 10ed275
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
11 changes: 7 additions & 4 deletions arithmetic_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import (
var mul func(c, a, b *fe) = mulADX
var mulAssign func(a, b *fe) = mulAssignADX

func setup() {
if !(cpu.X86.HasADX && cpu.X86.HasBMI2) || forceNonADXArch {
mul = mulNoADX
mulAssign = mulAssignNoADX
func cfgArch() {
if !x86ArchitectureSet {
if !(cpu.X86.HasADX && cpu.X86.HasBMI2) || forceNonADXArch {
mul = mulNoADX
mulAssign = mulAssignNoADX
}
x86ArchitectureSet = true
}
}

Expand Down
8 changes: 5 additions & 3 deletions arithmetic_fallback.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions bls12_381.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,10 @@ var frobeniusCoeffs12 = [12]fe2{
*/

var x, _ = new(big.Int).SetString("d201000000010000", 16)

/*
Non bls related
*/

var forceNonADXArch bool
var x86ArchitectureSet bool = false
3 changes: 1 addition & 2 deletions bls12_381_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
)

var fuz int
var forceNonADXArch bool

func TestMain(m *testing.M) {
_fuz := flag.Int("fuzz", 10, "# of iterations")
adx := flag.Bool("noadx", false, "to enfoce non adx arch")
flag.Parse()
forceNonADXArch = *adx
fuz = *_fuz
setup()
cfgArch()
m.Run()
}

Expand Down
1 change: 1 addition & 0 deletions g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type G1 struct {
}

func NewG1() *G1 {
cfgArch()
t := newTempG1()
return &G1{t}
}
Expand Down
1 change: 1 addition & 0 deletions g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type G2 struct {
}

func NewG2(f *fp2) *G2 {
cfgArch()
if f == nil {
f = newFp2()
}
Expand Down
1 change: 1 addition & 0 deletions pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Engine struct {
}

func NewEngine() *Engine {
cfgArch()
fp2 := newFp2()
fp6 := newFp6(fp2)
fp12 := newFp12(fp6)
Expand Down

0 comments on commit 10ed275

Please sign in to comment.