-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpu: add GODEBUG options to disable use of instruction set extensions
The GODEBUG environment variable can be used to disable usage of specific processor features of Go programs that use the sys/cpu package. This is useful for testing and benchmarking different code paths that are guarded by sys/cpu variable checks. Use of processor features can not be enabled through GODEBUG. To disable usage of AVX and SSE41 cpu features on GOARCH amd64 use: GODEBUG=cpu.avx=off,cpu.sse41=off The special "all" option can be used to disable all options: GODEBUG=all=off This aligns the support of GODEBUG for sys/cpu with existing support for GODEBUG in the Go standard library package internal/cpu. Fixes golang/go#33963 Change-Id: I618b71af397bf06c57a49b2a300d032a16d05664 Reviewed-on: https://go-review.googlesource.com/c/sys/+/245237 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Martin Möhrmann <moehrmann@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
- Loading branch information
Showing
15 changed files
with
260 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
package cpu | ||
|
||
func init() { | ||
func archInit() { | ||
if err := readHWCAP(); err != nil { | ||
return | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
package cpu | ||
|
||
const cacheLineSize = 32 | ||
|
||
func initOptions() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2020 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 !linux,arm | ||
|
||
package cpu | ||
|
||
func archInit() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2020 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 ppc64 ppc64le | ||
|
||
package cpu | ||
|
||
const cacheLineSize = 128 | ||
|
||
func initOptions() { | ||
options = []option{ | ||
{Name: "darn", Feature: &PPC64.HasDARN}, | ||
{Name: "scv", Feature: &PPC64.HasSCV}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
package cpu | ||
|
||
const cacheLineSize = 32 | ||
|
||
func initOptions() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2020 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. | ||
|
||
package cpu | ||
|
||
const cacheLineSize = 256 | ||
|
||
func initOptions() { | ||
options = []option{ | ||
{Name: "zarch", Feature: &S390X.HasZARCH}, | ||
{Name: "stfle", Feature: &S390X.HasSTFLE}, | ||
{Name: "ldisp", Feature: &S390X.HasLDISP}, | ||
{Name: "eimm", Feature: &S390X.HasEIMM}, | ||
{Name: "dfp", Feature: &S390X.HasDFP}, | ||
{Name: "etf3eh", Feature: &S390X.HasETF3EH}, | ||
{Name: "msa", Feature: &S390X.HasMSA}, | ||
{Name: "aes", Feature: &S390X.HasAES}, | ||
{Name: "aescbc", Feature: &S390X.HasAESCBC}, | ||
{Name: "aesctr", Feature: &S390X.HasAESCTR}, | ||
{Name: "aesgcm", Feature: &S390X.HasAESGCM}, | ||
{Name: "ghash", Feature: &S390X.HasGHASH}, | ||
{Name: "sha1", Feature: &S390X.HasSHA1}, | ||
{Name: "sha256", Feature: &S390X.HasSHA256}, | ||
{Name: "sha3", Feature: &S390X.HasSHA3}, | ||
{Name: "sha512", Feature: &S390X.HasSHA512}, | ||
{Name: "vx", Feature: &S390X.HasVX}, | ||
{Name: "vxe", Feature: &S390X.HasVXE}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ package cpu | |
// rules are good enough. | ||
|
||
const cacheLineSize = 0 | ||
|
||
func initOptions() {} | ||
|
||
func archInit() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters