Yesterday I made a blog entry about the Intel CPU topology tool to help understand Xeon 5500 SMT and how it maps to Linux OS CPUs. I received a few emails about the tool. Some folks where having trouble figuring it out on their system (the tool works on other Xeons too).
This is just a quick blog entry to explain the tool for those readers and the possible future wayward googler.
In the following session snap you’ll see that the CPU topology tool tar file is called topo03062009.tar. In the session I do the following:
- Extract the tarball
- Change directories into the directory created by the tar extraction
- Run the make for 64 bit Linux
- Ignore the warnings
- Run ls(1) to see what I picked up. Hmmm, there are no file names that appear to be executable.
- I look into the script that builds the tool. I see the binary is produced into cpu_topology64.out. ( Uh, I think even a.out would have been more intuitive).
- I use file(1) to make sure it is an executable
- I run it but throw away all but the last 40 lines of output.
# ls -l topo* -rw-r--r-- 1 root root 163840 Apr 13 21:16 topo03062009.tar # tar xvf topo03062009.tar topo/cpu_topo.c topo/cputopology.h topo/get_cpuid.asm topo/get_cpuid_lix32.s topo/get_cpuid_lix64.s topo/Intel Source Code License Agreement.doc topo/mk_32.bat topo/mk_32.sh topo/mk_64.bat topo/mk_64.sh topo/util_os.c # cd topo # sh ./mk_64.sh cpu_topo.c: In function ?DumpCPUIDArray?: cpu_topo.c:1857: warning: comparison is always false due to limited range of data type # ls cpu_topo.c get_cpuid_lix32.s mk_32.bat util_os.c cpu_topology64.out get_cpuid_lix64.o mk_32.sh util_os.o cputopology.h get_cpuid_lix64.s mk_64.bat get_cpuid.asm Intel Source Code License Agreement.doc mk_64.sh # # more mk*64*sh #!/bin/sh gcc -g -c get_cpuid_lix64.s -o get_cpuid_lix64.o gcc -g -c util_os.c gcc -g -DBUILD_MAIN cpu_topo.c -o cpu_topology64.out get_cpuid_lix64.o util_os.o # # # file cpu_topology64.out cpu_topology64.out: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped # ./cpu_topology64.out | tail -40 +-----------------------------------------------+ Combined socket AffinityMask= 0xf0f Package 1 Cache and Thread details Box Description: Cache is cache level designator Size is cache size OScpu# is cpu # as seen by OS Core is core#[_thread# if > 1 thread/core] inside socket AffMsk is AffinityMask(extended hex) for core and thread CmbMsk is Combined AffinityMask(extended hex) for hw threads sharing cache CmbMsk will differ from AffMsk if > 1 hw_thread/cache Extended Hex replaces trailing zeroes with 'z#' where # is number of zeroes (so '8z5' is '0x800000') +-----------+-----------+-----------+-----------+ Cache | L1D | L1D | L1D | L1D | Size | 32K | 32K | 32K | 32K | OScpu#| 4 12| 5 13| 6 14| 7 15| Core |c0_t0 c0_t1|c1_t0 c1_t1|c2_t0 c2_t1|c3_t0 c3_t1| AffMsk| 10 1z3| 20 2z3| 40 4z3| 80 8z3| CmbMsk| 1010 | 2020 | 4040 | 8080 | +-----------+-----------+-----------+-----------+ Cache | L1I | L1I | L1I | L1I | Size | 32K | 32K | 32K | 32K | +-----------+-----------+-----------+-----------+ Cache | L2 | L2 | L2 | L2 | Size | 256K | 256K | 256K | 256K | +-----------+-----------+-----------+-----------+ Cache | L3 | Size | 8M | CmbMsk| f0f0 | +-----------------------------------------------+
For 32-bit systems two things need to be fixed 1) the mk_32.sh script is not executable and 2) the script has windows CR/LF at end of the second gcc line (this causes an object file named “util_os.o^M” to be created and then file “util_os.o” cannot be found when linking with the main executable).
Clean up the shell script – it then compiles and creates cpu_topology32.out (which is executable)
# chmod 740 mk_32.sh
# ./mk_32.sh
: command not found
: command not found
gcc: util_os.o: No such file or directory
cpu_topo.c: In function ‘DumpCPUIDArray’:
cpu_topo.c:1857: warning: comparison is always false due to limited range of data type
# ll
> ….snip
-rw-r–r– 1 root root 5304 Mar 6 13:00 util_os.c
-rw-r–r– 1 root root 5704 Apr 23 20:39 util_os.o?
# dos2unix mk_32.sh
# ./mk_32.sh
# ./cpu_topology32.out
Aside: this code also (seems to) work on non-Xeon CPU’s. I ran it on a Pentium D and Core 2 Duo and the output all made sense.
Hey Brett,
Thanks for the tips… and here I thought I was thankful for 64bit Linux solely based on address space! I guess I get to sneak by 32bit stuff that just doesn’t work and I get off scot-free!