From 4f8791be1631390b483a0e84be8a603abc78396d Mon Sep 17 00:00:00 2001 From: Denis Steckelmacher Date: Tue, 4 Sep 2018 16:54:28 +0200 Subject: [PATCH] Test on Threadripper 2990WX and fix SMT On almost every Linux kernel, core i and i+1 are the two threads of a single physical core. Power consumption statistics can therefore be obtained by reading the MSRs or cores 0, 2, 4, ..., 60, 62. --- README.md | 1 + ryzen.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20b7746..9fa89e2 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,6 @@ gcc -o ryzen ryzen.c -lm Needs access to /dev/cpu/CPUNO/msr files. So may need root rights ## Tested on: ## + * AMD Ryzen Threadripper 2990WX * AMD Ryzen Threadripper 1950x * AMD Epyc 7501 diff --git a/ryzen.c b/ryzen.c index 3c9aff4..f0fe962 100644 --- a/ryzen.c +++ b/ryzen.c @@ -137,7 +137,7 @@ static int rapl_msr_amd_core() { int *fd = (int*)malloc(sizeof(int)*total_cores/2); for (int i = 0; i < total_cores/2; i++) { - fd[i] = open_msr(i); + fd[i] = open_msr(i*2); } int core_energy_units = read_msr(fd[0], AMD_MSR_PWR_UNIT);