Here is some very minimal code I wrote that gets your (x86) processor’s brand name using the cpuid
instruction.
#include <cpuid.h>
#include <cstdio>
#include <cstdint>
int main()
{
uint32_t Name[4];
for( uint32_t i = 2; i < 5; )
{
__cpuid(0x80000000 | i++, Name[0], Name[1], Name[2], Name[3]);
fwrite(Name, 16, 1, stdout);
}
}
main:
push rbp
mov ebp, 2
push rbx
sub rsp, 24
.L2:
mov eax, ebp
mov esi, 16
add ebp, 1
mov rdi, rsp
or eax, -2147483648
>>>> cpuid
mov DWORD PTR [rsp+8], ecx
mov rcx, QWORD PTR stdout[rip]
mov DWORD PTR [rsp+12], edx
mov edx, 1
mov DWORD PTR [rsp], eax
mov DWORD PTR [rsp+4], ebx
call fwrite
cmp ebp, 5
jne .L2
add rsp, 24
xor eax, eax
pop rbx
pop rbp
ret
Sample one-liner output:
% echo "I2luY2x1ZGUgPGNwdWlkLmg+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxjc3RkaW50PgppbnQgbWFpbigpe3VpbnQzMl90IE5bNF07Zm9yKHVpbnQzMl90IGk9MjtpPDU7KXtfX2NwdWlkKDB4ODAwMDAwMDAgfCBpKyssIE5bMF0sIE5bMV0sIE5bMl0sIE5bM10pO2Z3cml0ZShOLCAxNiwgMSwgc3Rkb3V0KTt9fQ==" | base64 -d | g++ -x c
++ - -o cpu-name
% ./cpu-name
Intel(R) Core(TM) i9-7900X CPU @ 3.30GHz
Seems fun enough, but what if we run it on those online compilers like onlinegdb.com?
Cool! onlinegdb.com’s “run code” instance is running off of an AMD EPYC 7501. In some cases, I get an unspecified Intel(R) Xeon(R) CPU @ 2.30GHz
, probably due to it running upon some kind of virtualized instance.
Here’s some others:
cpp.sh is running off of an Intel(R) Xeon(R) CPU W3520 @ 2.67GHz
repl.it is Intel(R) Xeon(R) CPU @ 2.30GHz
(virtualized)
ideone is Intel(R) Xeon(R) CPU E3-1270 V2 @ 3.50GHz
codechef is Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
Wow. This kinda surprised me. An in-the-wild instance of a pretty-recent Xeon with AVX-512 and everything!
Wandbox is Intel Xeon E312xx (Sandy Bridge)
rextester is Intel(R) Xeon(R) CPU E5-2640 v3 @ 2.60GHz
paiza.io is Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz
Another AVX-512 chip out in the wild
tutorialspoint is Intel(R) Xeon(R) CPU E5-2620 v4
jdoodle is Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
coliru is AMD Opteron(tm) Processor 4332 HE
codiva is Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
GeeksForGeeks is Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
First time seeing a Cascade Lake server out in the wild.
TIO - Try It Online is Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
Another AVX-512 chip
Lots of Xeon chips are still out in the wild, and surprisingly some of them even have AVX-512. Reason why I point this out is that AVX-512 code is not very accessible hardware at the moment outside of expensive Xeons, i9s, or their recent push into Laptops/Mobile so you can “““rent””” this remote hardware now to get a feel for the new SIMD ISA and see how it runs on these chips and “benchmark” code for yourself without having to pay $2450
on a chip.