mirror of
https://github.com/golang/go
synced 2024-11-23 20:30:04 -07:00
internal/cpu: report CPU if known on PPC64
The PPC64 maintainers are testing on P10 hardware, so it is helpful to report the correct cpu, even if this information is not used elsewhere yet. Note, AIX will report the current CPU of the host system, so a POWER10 will not set the IsPOWER9 flag. This is existing behavior, and should be fixed in a separate patch. Change-Id: Iebe23dd96ebe03c8a1c70d1ed2dc1506bad3c330 Reviewed-on: https://go-review.googlesource.com/c/go/+/404394 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
0c43878baa
commit
51859ec229
@ -86,6 +86,7 @@ var PPC64 struct {
|
||||
HasSCV bool // Syscall vectored (requires kernel enablement)
|
||||
IsPOWER8 bool // ISA v2.07 (POWER8)
|
||||
IsPOWER9 bool // ISA v3.00 (POWER9)
|
||||
IsPOWER10 bool // ISA v3.1 (POWER10)
|
||||
_ CacheLinePad
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !386 && !amd64
|
||||
//go:build !386 && !amd64 && !ppc64 && !ppc64le
|
||||
|
||||
package cpu
|
||||
|
||||
|
@ -21,3 +21,15 @@ func doinit() {
|
||||
func isSet(hwc uint, value uint) bool {
|
||||
return hwc&value != 0
|
||||
}
|
||||
|
||||
func Name() string {
|
||||
switch {
|
||||
case PPC64.IsPOWER10:
|
||||
return "POWER10"
|
||||
case PPC64.IsPOWER9:
|
||||
return "POWER9"
|
||||
case PPC64.IsPOWER8:
|
||||
return "POWER8"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -9,12 +9,16 @@ package cpu
|
||||
const (
|
||||
// getsystemcfg constants
|
||||
_SC_IMPL = 2
|
||||
_IMPL_POWER8 = 0x10000
|
||||
_IMPL_POWER9 = 0x20000
|
||||
_IMPL_POWER10 = 0x40000
|
||||
)
|
||||
|
||||
func osinit() {
|
||||
impl := getsystemcfg(_SC_IMPL)
|
||||
PPC64.IsPOWER8 = isSet(impl, _IMPL_POWER8)
|
||||
PPC64.IsPOWER9 = isSet(impl, _IMPL_POWER9)
|
||||
PPC64.IsPOWER10 = isSet(impl, _IMPL_POWER10)
|
||||
}
|
||||
|
||||
// getsystemcfg is defined in runtime/os2_aix.go
|
||||
|
@ -17,6 +17,7 @@ const (
|
||||
// ISA Level
|
||||
hwcap2_ARCH_2_07 = 0x80000000
|
||||
hwcap2_ARCH_3_00 = 0x00800000
|
||||
hwcap2_ARCH_3_1 = 0x00040000
|
||||
|
||||
// CPU features
|
||||
hwcap2_DARN = 0x00200000
|
||||
@ -26,6 +27,7 @@ const (
|
||||
func osinit() {
|
||||
PPC64.IsPOWER8 = isSet(HWCap2, hwcap2_ARCH_2_07)
|
||||
PPC64.IsPOWER9 = isSet(HWCap2, hwcap2_ARCH_3_00)
|
||||
PPC64.IsPOWER10 = isSet(HWCap2, hwcap2_ARCH_3_1)
|
||||
PPC64.HasDARN = isSet(HWCap2, hwcap2_DARN)
|
||||
PPC64.HasSCV = isSet(HWCap2, hwcap2_SCV)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user