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

4GHz was detected as 8GHz #91

Open
edisonchan opened this issue Oct 28, 2021 · 13 comments
Open

4GHz was detected as 8GHz #91

edisonchan opened this issue Oct 28, 2021 · 13 comments

Comments

@edisonchan
Copy link

I have set my CPU (ADL-S) to 4GHz in BIOS and set the power mode to "performance" in Ubuntu 21.10 kernel 5.15rc7, but uarch-bench was detected it is running 8GHz.

@travisdowns
Copy link
Owner

travisdowns commented Oct 28, 2021

@edisonchan - that is very interesting. It might indicate a interesting microarchitectural effect in ADL. Basically the way the speed is determined is by running a long chain of dependent addition instructions. Except on the Pentium 4 with double-pumped ALU, these should never run faster than 1 per cycle.

It is possible the CPU can fuse two adjacent additions into one in some cases, and run them at 2 every cycle.

You can set the MHZ manually like so:

export UARCH_BENCH_CLOCK_MHZ=4000

Then run uarch bench and it will just use the specified MHZ. I am wondering if you could upload here the results of running ./uarch-bench.sh --test-tag=~slow here so I could further investigate the issue. If it seems like fusion is occurring, I could create a few tests to probe the behavior a bit more.

@edisonchan
Copy link
Author

edisonchan commented Oct 28, 2021

Something wrong here.
The cpu core clock was droped after run the uarch-bench, now it is about 3.1GHz not 4ghz.
The system is connected via ssh, and it have a problem that it would hang on shutdown stage(I dont know how to not fix this problem).
There is not pepole near the system now, so I can not run reboot for back to 4GHz.
Now the problem is how to set it back to 4GHz in Ubuntu?

sudo cpufreq-set -c 0 -f 4GHz
Error setting new values. Common errors:
- Do you have proper administration rights? (super-user?)
- Is the governor you requested available and modprobed?
- Trying to set an invalid policy?
- Trying to set a specific frequency, but userspace governor is not available,
   for example because of hardware which cannot be set to a specific frequency
   or because the userspace governor isn't loaded?

cpufreq-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4294.55 ms.
  hardware limits: 800 MHz - 6.50 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 4.00 GHz and 4.00 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 3.10 GHz.

@travisdowns
Copy link
Owner

travisdowns commented Oct 28, 2021

@edisonchan

What is the non-turbo frequency of the P and E cores on your CPU?

Usually you can reboot unattended with shutdown -r now or sudo shutdown -r now. The -r flag asks for a reboot instead of a shutdown.

We can also try to undo whatever uarch-bench.sh does if it you think it was that. Before the test starts, uarch-bench.sh tries to disable turbo boost to get stable results (in cycles) and then it restores the old setting after. However, if a run is terminated with ^C or crashes or whatever, the restoration won't occur.

If you still have your results from the first/any run, there is some diagnostic output at the top which indicates if/how turbo was disabled, but anyway, the approaches are:

Write 1 to /sys/devices/system/cpu/intel_pstate/no_turbo. If that file exists on your system, trying writing 0 to it.

If that file doesn't exist, wrmsr will be used (if msr-tools is installed) to disable turbo, you can undo this with:

for core in {0..16}; do
	sudo wrmsr -p${core} 0x1a0 0x850089
done

This assumes your system has 16 or fewer cores (if fewer you will get some error messages about the cores not existing).

Another theory is that the 3.2 GHz value comes from the E cores, not the P cores.

@edisonchan
Copy link
Author

edisonchan commented Oct 28, 2021

@travisdowns I had try echo "0" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo, now the pcores are still 3.1GHz, but the ecores are about 4GHz now.

if echo "1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo, the pcores are 3.1GHz, and the ecores are 2.4 GHz.

update: the shutdown -r now works, I can run it on 4GHz again now.

@edisonchan
Copy link
Author

export UARCH_BENCH_CLOCK_MHZ=4000 still not works in my case:

Welcome to uarch-bench (ae3db99-dirty)
Supported CPU features: SSE3 PCLMULQDQ VMX SMX EST TM2 SSSE3 FMA CX16 SSE4_1 SSE4_2 MOVBE POPCNT AES AVX RDRND TSC_ADJ BMI1 AVX2 BMI2 ERMS PQE RDSEED ADX CLFLUSHOPT CLWB INTEL_PT SHA
Pinned to CPU 0
Source pages allocated with transparent hugepages: 100.0%)
Median CPU speed: 8.000 GHz
Running benchmarks groups using timer clock

** Running group basic : Basic Benchmarks **
                               Benchmark    Cycles     Nanos
                     Dependent add chain      2.00      0.25
                   Independent add chain      0.42      0.05

@travisdowns
Copy link
Owner

@edisonchan - thanks for the update! FWIW for setting frequencies, you might try sudo cpupower -c all frequency-set -u <FREQ> instead of cpufreq-set. I am not sure how up-to-date the cpufreq tools are: at least on my old Skylake system they consistently report bogus values for frequency (cpufreq-aperf, at least) and the set tool does not work, but cpupower does.

What model is this? Strange the pcores are still at 3.1 GHz. I guess this is the i9-12900K[F], so 3.2 sounds like the base frequency for the pcores.

Note that you can test the pcores and ecores separately by pinning the cpu in uarch-bench, like -c1 to pin to core 1, etc.

Is it still reporting 2x the frequency? If you can share some of the output, I can help diagnose it. You can email me if you don't want to share in public.

@travisdowns
Copy link
Owner

@edisonchan - just saw your reply. I created a branch edison:

https://github.com/travisdowns/uarch-bench/tree/edison

If you could pull this branch and run it, it has some extra logging around the MHz setting. I'm adding more too in case that doesn't work.

@travisdowns
Copy link
Owner

travisdowns commented Oct 28, 2021

By the way, if you want to avoid uarch-bench messing with the no_turbo flag or any MSRs, you can run it like ./uarch-bench instead of uarch-bench.sh. The .sh is a wrapper script that tries to disable turbo and set performance code before running the main binary.

@travisdowns
Copy link
Owner

@edisonchan - I just added in f89b7eb some tests for loops similar to the calibration routine to the benchmark. If you could pull and run:

make && ./uarch-bench --test-name=*calib*

and share the results it might help get to the bottom of this.

@edisonchan
Copy link
Author

The clock is still detected as 8.0 GHz.

I don't know how to use git to update the local files, so I just download the "RAW" file to local through the "view file" option.

@travisdowns
Copy link
Owner

travisdowns commented Oct 29, 2021

The clock is still detected as 8.0 GHz.

Thanks, I am narrowing down the issue (but it's not clear why the env var override doesn't work).

I don't know how to use git to update the local files, so I just download the "RAW" file to local through the "view file" option.

How did you originally clone the repository? I've merged these changes to master now, so if you have git on the command line a git pull should be enough to bring you up to date. You might get errors now though if you've locally modified files. You could also just clone the repository a second time to a new directory.

@travisdowns
Copy link
Owner

@edisonchan - I think I've fixed the frequency calibration. Why don't you pull master or clone a new repo and try?

@edisonchan
Copy link
Author

edisonchan commented Oct 30, 2021

@travisdowns The system is offline now, I need to wait for guys to boot it.

The results of f89b7eb was sent to your gmail.

Update, now the clock was detect as 4GHz.

I had sent the new results to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants