- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I am trying to detect the Intel CPU temperature inside the code, but I can't find any solution to do that in the forum/Google. Does anyone know there is any way to detect the Real-time temperature of CPU inside the code(Like library or other tools to do that)?
Thanks,
Jiawen
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jiawen
You may be interested in the 'turbostat' tool: http://manpages.ubuntu.com/manpages/oneiric/man8/turbostat.8.html
Here some output from a IBM x3250-M5 (in idle state):
[root@x3250-m5 bin]# /usr/local/bin/turbostat -i 5
Avg_MHz %Busy Bzy_MHz TSC_MHz SMI CPU%c1 CPU%c3 CPU%c6 CPU%c7 CoreTmp PkgTmp Pkg%pc2 Pkg%pc3 Pkg%pc6 Pkg%pc7 PkgWatt CorWatt
1 0.02 2992 2993 0 0.02 99.96 0.00 0.00 30 32 4.18 95.77 0.00 0.00 4.73 0.16
(in bold, Temp and wattage).
Hope it helps.
Kind regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Performance Counter Monitor provides a C++ API to measure hardware counters, including energy consumption. It doesn't report the absolute temperature but the thermal headroom, i.e. the difference to the maximum temperature that the processor allows.
Kind regards
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Patrick,
I am really interested in this tool even though I can't use it inside a program like APIs/library. But I couldn't find the way to install it. When I download the files from Github (https://github.com/torvalds/linux/tree/master/tools/power/x86/turbostat) and try to make, the following errors show up. Do you have any ideas how to get it successfully
[liu@fornax Temp]$ sudo make
gcc -Wall -DMSRHEADER=/usr/include/asm/msr-index.h turbostat.c -o /home/liu/Temp/turbostat
turbostat.c: In function ‘get_counters’:
turbostat.c:1044: error: ‘MSR_KNL_CORE_C6_RESIDENCY’ undeclared (first use in this function)
turbostat.c:1044: error: (Each undeclared identifier is reported only once
turbostat.c:1044: error: for each function it appears in.)
turbostat.c:1064: error: ‘MSR_PKG_WEIGHTED_CORE_C0_RES’ undeclared (first use in this function)
turbostat.c:1066: error: ‘MSR_PKG_ANY_CORE_C0_RES’ undeclared (first use in this function)
turbostat.c:1068: error: ‘MSR_PKG_ANY_GFXE_C0_RES’ undeclared (first use in this function)
turbostat.c:1070: error: ‘MSR_PKG_BOTH_CORE_GFXE_C0_RES’ undeclared (first use in this function)
turbostat.c: In function ‘dump_hsw_turbo_ratio_limits’:
turbostat.c:1202: error: ‘MSR_TURBO_RATIO_LIMIT2’ undeclared (first use in this function)
turbostat.c: In function ‘dump_ivt_turbo_ratio_limits’:
turbostat.c:1224: error: ‘MSR_TURBO_RATIO_LIMIT1’ undeclared (first use in this function)
turbostat.c: In function ‘dump_nhm_turbo_ratio_limits’:
turbostat.c:1276: error: ‘MSR_TURBO_RATIO_LIMIT’ undeclared (first use in this function)
turbostat.c: In function ‘dump_config_tdp’:
turbostat.c:1411: error: ‘MSR_CONFIG_TDP_NOMINAL’ undeclared (first use in this function)
turbostat.c:1415: error: ‘MSR_CONFIG_TDP_LEVEL_1’ undeclared (first use in this function)
turbostat.c:1425: error: ‘MSR_CONFIG_TDP_LEVEL_2’ undeclared (first use in this function)
turbostat.c:1435: error: ‘MSR_CONFIG_TDP_CONTROL’ undeclared (first use in this function)
turbostat.c:1442: error: ‘MSR_TURBO_ACTIVATION_RATIO’ undeclared (first use in this function)
turbostat.c: In function ‘print_perf_limit’:
turbostat.c:2066: error: ‘MSR_CORE_PERF_LIMIT_REASONS’ undeclared (first use in this function)
turbostat.c:2101: error: ‘MSR_GFX_PERF_LIMIT_REASONS’ undeclared (first use in this function)
turbostat.c:2123: error: ‘MSR_RING_PERF_LIMIT_REASONS’ undeclared (first use in this function)
make: *** [turbostat] Error 1
Regards,
Jiawen
Patrick A. wrote:
Hi Jiawen
You may be interested in the 'turbostat' tool: http://manpages.ubuntu.com/manpages/oneiric/man8/turbostat.8.html
Here some output from a IBM x3250-M5 (in idle state):
[root@x3250-m5 bin]# /usr/local/bin/turbostat -i 5
Avg_MHz %Busy Bzy_MHz TSC_MHz SMI CPU%c1 CPU%c3 CPU%c6 CPU%c7 CoreTmp PkgTmp Pkg%pc2 Pkg%pc3 Pkg%pc6 Pkg%pc7 PkgWatt CorWatt
1 0.02 2992 2993 0 0.02 99.96 0.00 0.00 30 32 4.18 95.77 0.00 0.00 4.73 0.16(in bold, Temp and wattage).
Hope it helps.
Kind regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Thomas,
It's a really good tool to get the performance collection. But it couldn't get the package CPU of real-time temperature which I want to collect.
Thanks,
Jiawen
Thomas Willhalm (Intel) wrote:
Intel Performance Counter Monitor provides a C++ API to measure hardware counters, including energy consumption. It doesn't report the absolute temperature but the thermal headroom, i.e. the difference to the maximum temperature that the processor allows.
Kind regards
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jiawen,
What kind of processor are you using? The temperature sensors are not available on all platforms.
What does the included pcm tool report when you run it? Is the last column with the temperature available?
This is what I see on my (idle) laptop:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page