Setting --mcpu

Hi all,

I’m a bit surprised:

karl@rantanplan:~/src/crystal$ cpuid -1 | grep uarch
    (uarch synth) = AMD Zen 3, 7nm

karl@rantanplan:~/src/crystal$ grep -m1 "cpu family" /proc/cpuinfo
cpu family      : 25

karl@rantanplan:~/src/crystal$ gcc -### -E - -march=native 2>&1 | grep -o "\-march=znver[1-4]\+" 
-march=znver2

25 is Zen 3. But from gcc i get Zen 2. If i didn’t miss something. I wonder what to do. Forget about it and set --mcpu native is perhaps the right option?

What’s the output of crystal eval 'require "llvm"; pp LLVM.host_cpu_name' for you? When you use --mcpu=native, the value of that method is what is provided. So that should make it more clear what LLVM would be using in that context.

1 Like

Big surprise: "znver3" . Thanks. I guess then this should be the value i chose. Or rely on. But where do the different values come from?

Again to be clear, in your specific case there is no difference between --mcpu=znver3 and --mcpu=native. The latter at least makes it so you don’t really have to worry about it.

Not sure, when running that gcc command on my machine, it matches up with what LLVM.host_cpu_name returns so :person_shrugging:.

OK, thanks.