Skip to content

Commit

Permalink
Using x/sys/cpu only with build tag amd64.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Jun 3, 2020
1 parent faf288d commit 26c5a08
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 26 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
CFG: [ [s390x,s390x,1.13], [arm64,arm64v8,1.14] ]
CFG: [ [s390x,s390x,1.14.0], [arm64,arm64v8,1.14.0] ]
steps:
- uses: actions/checkout@v2
- name: Enabling Docker Experimental
Expand All @@ -49,10 +49,15 @@ jobs:
run: |
docker pull -q multiarch/qemu-user-static
docker pull -q --platform linux/${{matrix.CFG[0]}} ${{matrix.CFG[1]}}/golang:${{matrix.CFG[2]}}
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Testing
run: |
docker run --rm -v `pwd`:`pwd` -w `pwd` ${{matrix.CFG[1]}}/golang:${{matrix.CFG[2]}} go test -v ./...
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -v `pwd`:`pwd` -w `pwd` \
-e "GODEBUG=asyncpreemptoff=1" \
-e "GOPROXY=direct" \
-e "GOFLAGS=-insecure" \
${{matrix.CFG[1]}}/golang:${{matrix.CFG[2]}} \
go test -v ./...
coverage_amd64_job:
needs: [ amd64_job ]
if: github.event_name == 'push'
Expand Down
9 changes: 3 additions & 6 deletions dh/csidh/fp511_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,!noasm
// +build amd64

package csidh

Expand All @@ -11,12 +11,9 @@ import (
var (
// Signals support for BMI2 (MULX)
hasBMI2 = cpu.X86.HasBMI2
// Signals support for ADX and BMI2
hasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX
_ = hasBMI2
)

var _ = hasBMI2

func mul512(r, m1 *fp, m2 uint64) { mul512Amd64(r, m1, m2) }
func cswap512(x, y *fp, choice uint8) { cswap512Amd64(x, y, choice) }
func mulRdc(r, x, y *fp) { mulRdcAmd64(r, x, y) }
Expand All @@ -36,7 +33,7 @@ func mulRdcAmd64(r, x, y *fp) {
var t fp
var c uint64

if hasADXandBMI2 {
if cpu.X86.HasBMI2 && cpu.X86.HasADX {
mulBmiAsm(r, x, y)
} else {
mulGeneric(r, x, y)
Expand Down
6 changes: 6 additions & 0 deletions dh/sidh/internal/p434/arith_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package p434

import "golang.org/x/sys/cpu"

// HasADXandBMI2 signals support for ADX and BMI2
var HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX
4 changes: 0 additions & 4 deletions dh/sidh/internal/p434/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package p434

import (
"github.com/cloudflare/circl/dh/sidh/internal/common"
"golang.org/x/sys/cpu"
)

const (
Expand All @@ -13,9 +12,6 @@ const (
)

var (
// HasADXandBMI2 signals support for ADX and BMI2
HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX

// P434 is a prime used by field Fp434
P434 = common.Fp{
0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFDC1767AE2FFFFFF,
Expand Down
13 changes: 13 additions & 0 deletions dh/sidh/internal/p503/arith_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package p503

import "golang.org/x/sys/cpu"

// According to https://github.com/golang/go/issues/28230,
// variables referred from the assembly must be in the same package.
var (
// HasBMI2 signals support for MULX which is in BMI2
HasBMI2 = cpu.X86.HasBMI2

// HasADXandBMI2 signals support for ADX and BMI2
HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX
)
8 changes: 0 additions & 8 deletions dh/sidh/internal/p503/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package p503

import (
"github.com/cloudflare/circl/dh/sidh/internal/common"
"golang.org/x/sys/cpu"
)

const (
Expand All @@ -14,13 +13,6 @@ const (

// P503 is a prime used by field Fp503
var (
// According to https://github.com/golang/go/issues/28230,
// variables referred from the assembly must be in the same package.
// HasBMI2 signals support for MULX which is in BMI2
HasBMI2 = cpu.X86.HasBMI2
// HasADXandBMI2 signals support for ADX and BMI2
HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX

// P503 is a prime used by field Fp503
P503 = common.Fp{
0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xABFFFFFFFFFFFFFF,
Expand Down
10 changes: 10 additions & 0 deletions dh/sidh/internal/p751/arith_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package p751

import "golang.org/x/sys/cpu"

var (
// HasBMI2 signals support for MULX which is in BMI2
HasBMI2 = cpu.X86.HasBMI2
// HasADXandBMI2 signals support for ADX and BMI2
HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX
)
5 changes: 0 additions & 5 deletions dh/sidh/internal/p751/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package p751

import (
"github.com/cloudflare/circl/dh/sidh/internal/common"
"golang.org/x/sys/cpu"
)

const (
Expand All @@ -13,10 +12,6 @@ const (
)

var (
// HasBMI2 signals support for MULX which is in BMI2
HasBMI2 = cpu.X86.HasBMI2
// HasADXandBMI2 signals support for ADX and BMI2
HasADXandBMI2 = cpu.X86.HasBMI2 && cpu.X86.HasADX
// P751 is a prime used by field Fp751
P751 = common.Fp{
0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 26c5a08

Please sign in to comment.