Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu: advertise AVX10 version #1673

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
labels["cpuid."+f] = true
}
}
for f, v := range features.Attributes[CpuidFeature].Elements {
labels["cpuid."+f] = v
}

Check warning on line 154 in source/cpu/cpu.go

View check run for this annotation

Codecov / codecov/patch

source/cpu/cpu.go#L153-L154

Added lines #L153 - L154 were not covered by tests

// CPU model
for k, v := range features.Attributes[Cpumodel].Elements {
Expand Down Expand Up @@ -203,6 +206,9 @@

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

Check warning on line 211 in source/cpu/cpu.go

View check run for this annotation

Codecov / codecov/patch

source/cpu/cpu.go#L209-L211

Added lines #L209 - L211 were not covered by tests

// 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 @@
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))
}

Check warning on line 35 in source/cpu/cpuid_amd64.go

View check run for this annotation

Codecov / codecov/patch

source/cpu/cpuid_amd64.go#L30-L35

Added lines #L30 - L35 were not covered by tests

return ret

Check warning on line 37 in source/cpu/cpuid_amd64.go

View check run for this annotation

Codecov / codecov/patch

source/cpu/cpuid_amd64.go#L37

Added line #L37 was not covered by tests
}
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 }