m-j-w / CpuId.jl

Ask the CPU for cache sizes, SIMD feature support, a running hypervisor, and more.
Other
54 stars 10 forks source link

JuliaParallel / Hwloc.jl M1 Mac Improvements fail #55

Open m-j-w opened 2 years ago

m-j-w commented 2 years ago

Issue discribed here: https://github.com/JuliaParallel/Hwloc.jl/pull/61

This CPU does not provide information on cpuid leaf 0x00000004.

Root cause to be identified.

@carstenbauer

m-j-w commented 2 years ago

@cartenbauer As mentioned in the original CI issue, do you have the means to dump the text from cpuinfo() provided by CpuId.jl ?

For me, this looks something like this:

julia> cpuinfo()
  Cpu Property       Value
  –––––––––––––––––– ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  Brand              Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Vendor             :Intel
  Architecture       :Kabylake
  Model              Family: 0x06, Model: 0x8e, Stepping: 0x0a, Type: 0x00
  Cores              4 physical cores, 8 logical cores (on executing CPU)
                     Hyperthreading hardware capability detected
  Clock Frequencies  2000 / 4000 MHz (base/max), 100 MHz bus
  Data Cache         Level 1:3 : (32, 256, 8192) kbytes
                     64 byte cache line size
  Address Size       48 bits virtual, 39 bits physical
  SIMD               256 bit = 32 byte max. SIMD vector size
  Time Stamp Counter TSC is accessible via `rdtsc`
                     TSC runs at constant rate (invariant from clock frequency)
  Perf. Monitoring   Performance Monitoring Counters (PMC) revision 4
                     Available hardware counters per logical core:
                     3 fixed-function counters of 48 bit width
                     4 general-purpose counters of 48 bit width
  Hypervisor         No

If that function actually does show (some) correct output, then possibly the CPU is not yet supported since too new/old. I'd then ask you for a full cpuid dump to add that specific hardware.

This is done with the following commands in Julia:

using Pkg
Pkg.add("CpuId")
using CpuId
include(joinpath(Pkg.dir("CpuId"),"test","mock.jl"))
dump_cpuid_table()

Thank you!

carstenbauer commented 2 years ago

Note that I don't have direct access to an x86 system. I'm only noticing it on the x86 GitHub CI runners (virtual machines I guess).

Anyhow, I've put

display(cpuinfo())
include(joinpath(dirname(pathof(CpuId)), "..", "test", "mock.jl"))
dump_cpuid_table()

at the beginning of the runtests.jl in this PR. For Julia 1.6 / CpuId 0.3.0 I get

Cpu Property       Value                                                  
  –––––––––––––––––– –––––––––––––––––––––––––––––––––––––––––––––––––––––––
  Brand              Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz          
  Vendor             :Intel                                                 
  Architecture       :UnknownIntel                                          
  Model              Family: 0x06, Model: 0x6a, Stepping: 0x06, Type: 0x00  
  Cores              2 physical cores, 2 logical cores (on executing CPU)   
                     No Hyperthreading hardware capability detected         
  Clock Frequencies  Not supported by CPU                                   
  Data Cache         Level 1:3 : (48, 1280, 49152) kbytes                   
                     64 byte cache line size                                
  Address Size       48 bits virtual, 46 bits physical                      
  SIMD               512 bit = 64 byte max. SIMD vector size                
  Time Stamp Counter TSC is accessible via `rdtsc`                          
                     TSC increased at every clock cycle (non-invariant TSC) 
  Perf. Monitoring   Performance Monitoring Counters (PMC) are not supported
  Hypervisor         Yes, Microsoft                                         Dump of all cpuid leafs, used for mocking 'cpuid'...

# Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz with Microsoft hypervisor
push!( _mockdb, (Dict(
    ((0x00000000, 0x00000000) => (0x00000015, 0x756e6547, 0x6c65746e, 0x49656e69)),
    ((0x00000001, 0x00000000) => (0x000606a6, 0x01020800, 0xfeda3203, 0x1f8bfbff)),
    ((0x00000002, 0x00000000) => (0x00feff01, 0x000000f0, 0x00000000, 0x00000000)),
    ((0x00000003, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000004, 0x00000000) => (0x04000121, 0x02c0003f, 0x0000003f, 0x00000000)),
    ((0x00000005, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000006, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000007, 0x00000000) => (0x00000000, 0xd09f2fb9, 0x00000000, 0x00000400)),
    ((0x00000008, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000009, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x0000000a, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x0000000b, 0x00000000) => (0x00000000, 0x00000001, 0x00000100, 0x00000001)),
    ((0x0000000c, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x0000000d, 0x00000000) => (0x000000e7, 0x00000a80, 0x00000a80, 0x00000000)),
    ((0x0000000e, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x0000000f, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000010, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000011, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000012, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000013, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000014, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000015, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x40000000, 0x00000000) => (0x40000006, 0x7263694d, 0x666f736f, 0x76482074)),
    ((0x40000001, 0x00000000) => (0x31237648, 0x00000000, 0x00000000, 0x00000000)),
    ((0x40000002, 0x00000000) => (0x00004f7c, 0x000a0000, 0x00000001, 0x000004d0)),
    ((0x40000003, 0x00000000) => (0x00002e7f, 0x00388030, 0x00000002, 0x000ed7b2)),
    ((0x40000004, 0x00000000) => (0x00060e24, 0x00000fff, 0x0000002e, 0x00000000)),
    ((0x40000005, 0x00000000) => (0x000000f0, 0x00000400, 0x00005d00, 0x00000000)),
    ((0x40000006, 0x00000000) => (0x0000000f, 0x00000000, 0x00000000, 0x00000000)),
    ((0x80000000, 0x00000000) => (0x80000008, 0x00000000, 0x00000000, 0x00000000)),
    ((0x80000001, 0x00000000) => (0x00000000, 0x00000000, 0x00000121, 0x2c100800)),
    ((0x80000002, 0x00000000) => (0x65746e49, 0x2952286c, 0x6f655820, 0x2952286e)),
    ((0x80000003, 0x00000000) => (0x616c5020, 0x756e6974, 0x3338206d, 0x20433037)),
    ((0x80000004, 0x00000000) => (0x20555043, 0x2e322040, 0x4[84](https://github.com/JuliaParallel/Hwloc.jl/runs/7894581911?check_suite_focus=true#step:6:87)73038, 0x0000007a)),
    ((0x80000005, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x80000006, 0x00000000) => (0x00000000, 0x00000000, 0x01006040, 0x00000000)),
    ((0x80000007, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x80000008, 0x00000000) => (0x0000302e, 0x00000000, 0x00000000, 0x00000000)),
    ((0x00000004, 0x00000001) => (0x04000122, 0x01c0003f, 0x0000003f, 0x00000000)),
    ((0x00000004, 0x00000002) => (0x04000143, 0x04c0003f, 0x000003ff, 0x00000000)),
    ((0x00000004, 0x00000003) => (0x04004163, 0x02c0003f, 0x0000ffff, 0x00000000)),
    ((0x00000004, 0x00000004) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
    ((0x0000000b, 0x00000001) => (0x00000001, 0x00000002, 0x00000201, 0x00000001)),
    ((0x0000000b, 0x00000002) => (0x00000000, 0x00000000, 0x00000002, 0x00000001)),
  ) => Dict{Symbol,Any}(
ERROR: LoadError: UndefVarError: cpuvendor not defined
Stacktrace:
 [1] dump_cpuid_table()
   @ Main ~/.julia/packages/CpuId/Dx104/test/mock.jl:[94](https://github.com/JuliaParallel/Hwloc.jl/runs/7894581911?check_suite_focus=true#step:6:97)
 [2] top-level scope
   @ ~/work/Hwloc.jl/Hwloc.jl/test/runtests.jl:8
 [3] include(fname::String)
   @ Base.MainInclude ./client.jl:444
 [4] top-level scope
   @ none:6
in expression starting at /home/runner/work/Hwloc.jl/Hwloc.jl/test/runtests.jl:8

For Julia 1.7 / CpuId 0.3.1 I get

ERROR: LoadError: This CPU does not provide information on cpuid leaf 0x00000004.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] _throw_unsupported_leaf(leaf::UInt32)
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:38
 [3] cachesize()
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:737
 [4] cpuinfo()
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:1036
 [5] top-level scope
   @ ~/work/Hwloc.jl/Hwloc.jl/test/runtests.jl:6
 [6] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [7] top-level scope
   @ none:6
in expression starting at /home/runner/work/Hwloc.jl/Hwloc.jl/test/runtests.jl:6
plessl commented 2 years ago

I can reproduce the problem on an M1 Mac for Julia 1.8.0-rc4 and CpuId 0.3.1

julia> versioninfo()
Julia Version 1.8.0-rc4
Commit 7853436ccd7 (2022-08-08 07:55 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.5.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores

julia> using CpuId

julia> CpuId.cpuinfo()
ERROR: This CPU does not provide information on cpuid leaf 0x00000004.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] _throw_unsupported_leaf(leaf::UInt32)
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:38
 [3] cachesize()
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:737
 [4] cpuinfo()
   @ CpuId ~/.julia/packages/CpuId/n7zKC/src/CpuId.jl:1036
 [5] top-level scope
   @ REPL[9]:1