Skip to content

Commit

Permalink
Merge pull request #1673 from marquiz/devel/avx10
Browse files Browse the repository at this point in the history
cpu: advertise AVX10 version
  • Loading branch information
k8s-ci-robot committed May 24, 2024
2 parents 814255b + fa2f008 commit 891d163
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 0 deletions.
11 changes: 11 additions & 0 deletions deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ spec:
- "SSE42"
- "SSSE3"

- name: "nfd built-in cpu-cpuid non-bool labels"
labelsTemplate: |
{{ range .cpu.cpuid }}cpu-cpuid.{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: cpu.cpuid
matchName:
op: In
value:
- "AVX10_VERSION"

- name: "nfd built-in cpu-hardware_multithreading label"
labelsTemplate: |
{{ range .cpu.topology }}cpu-{{ .Name }}={{ .Value }}
Expand Down
2 changes: 2 additions & 0 deletions docs/usage/customization-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,8 @@ The following features are available for matching:
| ---------------- | ------------ | -------- | ---------- | ----------- |
| **`cpu.cpuid`** | flag | | | Supported CPU capabilities |
| | | **`<cpuid-flag>`** | | CPUID flag is present |
| | attribute | | | CPU capability attributes |
| | | **AVX10_VERSION** | int | AVX10 vector ISA version (if supported) |
| **`cpu.cstate`** | attribute | | | Status of cstates in the intel_idle cpuidle driver |
| | | **`enabled`** | bool | 'true' if cstates are set, otherwise 'false'. Does not exist of intel_idle driver is not active. |
| **`cpu.model`** | attribute | | | CPU model related attributes |
Expand Down
7 changes: 7 additions & 0 deletions docs/usage/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ feature.node.kubernetes.io/<feature> = <value>
| Feature name | Value | Description |
| ----------------------------------- | ------ | --------------------------------------------------------------------------- |
| **`cpu-cpuid.<cpuid-flag>`** | true | CPU capability is supported. **NOTE:** the capability might be supported but not enabled. |
| **`cpu-cpuid.<cpuid-attribute>`** | string | CPU attribute value |
| **`cpu-hardware_multithreading`** | true | Hardware multithreading, such as Intel HTT, enabled (number of logical CPUs is greater than physical CPUs) |
| **`cpu-coprocessor.nx_gzip`** | true | Nest Accelerator for GZIP is supported(Power). |
| **`cpu-power.sst_bf.enabled`** | true | Intel SST-BF ([Intel Speed Select Technology][intel-sst] - Base frequency) enabled |
Expand Down Expand Up @@ -123,6 +124,12 @@ configuration options to change the behavior.

See the full list in [github.com/klauspost/cpuid][klauspost-cpuid].

#### X86 CPUID attributes

| Attribute | Description |
| ------------------ | ------------------------------------------------------- |
| AVX10_VERSION | AVX10 vector ISA version (if supported) |

#### Arm CPUID flags (partial list)

| Flag | Description |
Expand Down
6 changes: 6 additions & 0 deletions source/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func (s *cpuSource) GetLabels() (source.FeatureLabels, error) {
labels["cpuid."+f] = true
}
}
for f, v := range features.Attributes[CpuidFeature].Elements {
labels["cpuid."+f] = v
}

// CPU model
for k, v := range features.Attributes[Cpumodel].Elements {
Expand Down Expand Up @@ -203,6 +206,9 @@ func (s *cpuSource) Discover() error {

// Detect CPUID
s.features.Flags[CpuidFeature] = nfdv1alpha1.NewFlagFeatures(getCpuidFlags()...)
if cpuidAttrs := getCpuidAttributes(); cpuidAttrs != nil {
s.features.Attributes[CpuidFeature] = nfdv1alpha1.NewAttributeFeatures(cpuidAttrs)
}

// Detect CPU model
s.features.Attributes[Cpumodel] = nfdv1alpha1.NewAttributeFeatures(getCPUModel())
Expand Down
12 changes: 12 additions & 0 deletions source/cpu/cpuid_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ limitations under the License.
package cpu

import (
"strconv"

"github.com/klauspost/cpuid/v2"
)

// getCpuidFlags returns feature names for all the supported CPU features.
func getCpuidFlags() []string {
return cpuid.CPU.FeatureSet()
}

func getCpuidAttributes() map[string]string {
ret := map[string]string{}

if cpuid.CPU.AVX10Level > 0 {
ret["AVX10_VERSION"] = strconv.Itoa(int(cpuid.CPU.AVX10Level))
}

return ret
}
2 changes: 2 additions & 0 deletions source/cpu/cpuid_linux_arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ func getCpuidFlags() []string {
}
return r
}

func getCpuidAttributes() map[string]string { return nil }
2 changes: 2 additions & 0 deletions source/cpu/cpuid_linux_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,5 @@ func getCpuidFlags() []string {
}
return r
}

func getCpuidAttributes() map[string]string { return nil }
2 changes: 2 additions & 0 deletions source/cpu/cpuid_linux_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ func getCpuidFlags() []string {
}
return r
}

func getCpuidAttributes() map[string]string { return nil }
2 changes: 2 additions & 0 deletions source/cpu/cpuid_linux_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ func getCpuidFlags() []string {
}
return r
}

func getCpuidAttributes() map[string]string { return nil }
2 changes: 2 additions & 0 deletions source/cpu/cpuid_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ limitations under the License.
package cpu

func getCpuidFlags() []string { return nil }

func getCpuidAttributes() map[string]string { return nil }

0 comments on commit 891d163

Please sign in to comment.