Skip to content
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
86 changes: 74 additions & 12 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,19 +749,81 @@ func setLlcSize(llcSize float64, myTarget target.Target, localTempDir string) {

func setCoreFrequency(coreFrequency float64, myTarget target.Target, localTempDir string) {
fmt.Printf("set core frequency to %.1f GHz on %s\n", coreFrequency, myTarget.GetName())
freqInt := uint64(coreFrequency * 10)
var msr uint64
for i := range 8 {
msr = msr | freqInt<<uint(i*8)
targetFamily, err := myTarget.GetFamily()
if err != nil {
fmt.Fprintf(os.Stderr, "error getting target family: %v\n", err)
slog.Error("failed to get target family", slog.String("error", err.Error()))
return
}
setScript := script.ScriptDefinition{
Name: "set frequency bins",
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x1AD %d", msr),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
targetModel, err := myTarget.GetModel()
if err != nil {
fmt.Fprintf(os.Stderr, "error getting target model: %v\n", err)
slog.Error("failed to get target model", slog.String("error", err.Error()))
return
}
_, err := runScript(myTarget, setScript, localTempDir)
targetVendor, err := myTarget.GetVendor()
if err != nil {
fmt.Fprintf(os.Stderr, "error getting target vendor: %v\n", err)
slog.Error("failed to get target vendor", slog.String("error", err.Error()))
return
}
if targetVendor != "GenuineIntel" {
err := fmt.Errorf("core frequency setting not supported on %s due to vendor mismatch", myTarget.GetName())
slog.Error(err.Error())
fmt.Fprintf(os.Stderr, "Error: failed to set core frequency: %v\n", err)
return
}
var setScript script.ScriptDefinition
freqInt := uint64(coreFrequency * 10)
if targetFamily == "6" && targetModel == "175" { // SRF
// get the pstate driver
getScript := script.ScriptDefinition{
Name: "get pstate driver",
ScriptTemplate: "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver",
Vendors: []string{"GenuineIntel"},
}
output, err := runScript(myTarget, getScript, localTempDir)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to get pstate driver: %v\n", err)
slog.Error("failed to get pstate driver", slog.String("error", err.Error()))
return
}
if strings.Contains(output, "intel_pstate") {
var value uint64
for i := range 2 {
Comment thread
harp-intel marked this conversation as resolved.
value = value | freqInt<<uint(i*8)
}
setScript = script.ScriptDefinition{
Name: "set frequency bins",
ScriptTemplate: fmt.Sprintf("wrmsr 0x774 %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
}
} else {
value := freqInt << uint(2*8)
setScript = script.ScriptDefinition{
Name: "set frequency bins",
ScriptTemplate: fmt.Sprintf("wrmsr 0x199 %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
}
}
} else {
var value uint64
for i := range 8 {
value = value | freqInt<<uint(i*8)
}
setScript = script.ScriptDefinition{
Name: "set frequency bins",
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x1AD %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
}
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to set core frequency: %v\n", err)
}
Expand Down Expand Up @@ -885,7 +947,7 @@ func setUncoreFrequency(maxFreq bool, uncoreFrequency float64, myTarget target.T
slog.Error("failed to get target model", slog.String("error", err.Error()))
return
}
if targetFamily != "6" || (targetFamily == "6" && (targetModel == "173" || targetModel == "175")) {
if targetFamily != "6" || (targetFamily == "6" && (targetModel == "173" || targetModel == "175")) { // SRF, GNR
err := fmt.Errorf("uncore frequency setting not supported on %s due to family/model mismatch", myTarget.GetName())
slog.Error(err.Error())
fmt.Fprintf(os.Stderr, "Error: failed to set uncore frequency: %v\n", err)
Expand Down
22 changes: 18 additions & 4 deletions internal/script/script_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,29 @@ vendor=$(echo "$lscpu" | grep -E "^Vendor ID:" | awk '{print $3}')
if [ "$vendor" != "GenuineIntel" ]; then
exit 1
fi
# if cpu is SRF or GNR get the frequencies from tpmi
if [ "$family" -eq 6 ] && ( [ "$model" -eq 175 ] || [ "$model" -eq 173 ] ); then
# if cpu is GNR get the frequencies from tpmi
if [ "$family" -eq 6 ] && [ "$model" -eq 173 ]; then # GNR
cores=$(pcm-tpmi 0x5 0xD8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PP_INFO_10
sse=$(pcm-tpmi 0x5 0xA8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PP_INFO_4
# this works unless the TRL is overridden on MSR 0x1AD --> sse=$(pcm-tpmi 0x5 0xA8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PP_INFO_4
sse=$(rdmsr 0x1ad) # MSR_TURBO_RATIO_LIMIT: Maximum Ratio Limit of Turbo Mode
avx2=$(pcm-tpmi 0x5 0xB0 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_5
avx512=$(pcm-tpmi 0x5 0xB8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_6
avx512h=$(pcm-tpmi 0x5 0xC0 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_7
amx=$(pcm-tpmi 0x5 0xC8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_8
else # if cpu is not SRF or GNR get the frequencies from msr
elif [ "$family" -eq 6 ] && [ "$model" -eq 175 ]; then # SRF
cores=$(rdmsr 0x1ae) # MSR_TURBO_GROUP_CORE_CNT: Group Size of Active Cores for Turbo Mode Operation
# if pstate driver is intel_pstate use 0x774 else use 0x199
driver=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)
if [ "$driver" = "intel_pstate" ]; then
sse=$(rdmsr 0x774 -f 15:8) # IA32_HWP_REQUEST
else
sse=$(rdmsr 0x199 -f 15:8) # IA32_PERF_CTL
fi
avx2=0
avx512=0
avx512h=0
amx=0
else # not SRF or GNR
cores=$(rdmsr 0x1ae) # MSR_TURBO_GROUP_CORE_CNT: Group Size of Active Cores for Turbo Mode Operation
sse=$(rdmsr 0x1ad) # MSR_TURBO_RATIO_LIMIT: Maximum Ratio Limit of Turbo Mode
avx2=0
Expand Down