pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
990 stars 310 forks source link

Fix armv8 linux build #117

Closed thefacetakt closed 1 year ago

thefacetakt commented 1 year ago

Related to issue 112

To be honest, I am quite new to working with ARM, so here are some links to support my claims:

  1. In ARMv8, AArch32 state supports only conceptual coprocessors CP10, CP11, CP14, and CP15.

This quote is taken from ARM Glossary

  1. AArch64 does not support the concept of coprocessors.

This quote is taken from Porting to A64 page

  1. And clang refuses to compile inline assembly when targeting ARMv8+

Well, I tried (Armv8a both A32 and A64) and it failed.

Interestingly, it fails even if I try to compile for ARMv8 A32 with different coprocessor argument, despite Arm Armv8-A A32/T32 Instruction Set Architecture doc saying MRC instruction should be available


As far as I understand, where could be no wmmx-support in armv8, so this change should be safe. I think so because:

  1. Current cpuinfo code does not check for wmmx if architecture_version is >= 8

  2. I've found that people reffer to iWMMXt as to "coprocessor" (for example in linux kernel code), and there seems to be no coprocessors in armv8, so there is no need to try and read wmmx-info.

  3. Not very strong evidence, but wikipedia page "List of ARM processors" lists no armv8 processor with wmmx support.


Side Note 1:

issue 112 says that

MRC is not available on armv8 and the function may need to use MRS instead

I have not found any info on how to read wmmx-related information using MRS, probably because there is no wmmx in armv8

Side Note 2:

I tried to understand where current wcid handling comes from, and found that the behavior of coprocessor_type handling is the same as pj4_get_iwmmxt_version function in linux kernel. However, linux kernel has another function for checking iwmmxt support, with different logic (e.g. it checks coprocessor 0 instead of 1). My guess that pj4_get_iwmmxt_version is relevant to PJ4 processor and cpu_has_iwmmxt is relevant to xscale processors, so there might be a chance that cpuinfo does incorrect checks for xscale processors.

thefacetakt commented 1 year ago

Side Note 3: It might have been best to hide wmmx-related stuff under __ARM_WMMX macro but based on this libunwind discussion clang does not correctly set this macro.

thefacetakt commented 1 year ago

@Maratyszcza could you take a look?