For now we check if the amx intrinsics used on 64-bits target. This
check is not accurate.
Details
- Reviewers
pengfei craig.topper LuoYuanke MaskRay
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think the precommit CI failures might be relevant here -- can you double-check those?
How does this interact with -march=native -m32. Won't that pick up the amx flag from CPUID?
Yes. This test is only supported on amdgpu-registered-target so I didn't catch this fail on my local machine. Thanks for point out.
clang/lib/Driver/ToolChains/Arch/X86.cpp | ||
---|---|---|
133 | This looks like it would trigger an error with -march=native -m32 on a cpu with amx? Why is that a desirable behavior? The compiler user has done nothing wrong. What are they supposed to do to avoid the error? |
What problem are we trying to solve here? CPUID reports AMX as supported even in 32-bit mode. Why can't the user pass it to the compiler?
I thought AMX is only supported on 64-bit mode. It seems I was wrong. So for now just reporting an error to intrinsics is enough. Thanks.
I have the same impression. I checked ISE says AMX instructions are N.E. on 32-bit mode. And seems Linux Kernel only enables AMX on 64-bit too https://lwn.net/ml/linux-kernel/20210730145957.7927-22-chang.seok.bae@intel.com/#t
Yes AMX is only supported in 64-bit mode but I doubt CPUID checks which mode the program is running in.
I guess HasAMXSave is false on 32-bit mode https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Host.cpp#L1800. But I don't have the environment to check it.
I found it. The XFEATURE_MASK_XTILE in Kernel is the same as HasAMXSave in compiler: https://lwn.net/ml/linux-kernel/20210710130313.5072-20-chang.seok.bae@intel.com/
So these features bits are true only on 64-bit mode.
No, a 32-bit binary gets the same CR0 as 64-bit on a 64-bit kernel. Actually, it's compiler to get the CR0 rather than the binary it builds. It should be rare to run 32-bit compiler on 64-bit kernel.
So you are right. No matter 32 or 64 bits compiler, when it builds a binary with -m32 on 64-bit kernel with -march=native, it always sets AMX features. Maybe we should reset them to false when compile for 32-bit?
This looks like it would trigger an error with -march=native -m32 on a cpu with amx? Why is that a desirable behavior? The compiler user has done nothing wrong. What are they supposed to do to avoid the error?