m-j-w/CpuId.jl

Number of cores not detected on AMD cpus.

Closed this issue · 6 comments

I'm using CpuId v0.1.9 and it doesn't seem to be able to detect the number of cores of my AMD A10-8700P laptop.
It says 0 physical cores and 0 logical cores.

m-j-w commented

I don't have access to any AMD cpus; thus, I would need your assistance here to make a first attempt in properly recognising the cpu features. First, I assume this page accurately describes your cpu?

Then, please run and post here the results of

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

This should give a dump of the raw cpuid tables as listed in test/mockdb.jl. No serial numbers involved.

Dump of all cpuid leafs, used for mocking 'cpuid'...

AMD A10-8700P Radeon R6, 10 Compute Cores 4C+6G without hypervisor

push!( _mockdb, Dict(
((0x00000000, 0x00000000) => (0x0000000d, 0x68747541, 0x444d4163, 0x69746e65)),
((0x00000001, 0x00000000) => (0x00660f01, 0x02040800, 0x3ed8320b, 0x178bfbff)),
((0x00000002, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x00000003, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x00000004, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x00000005, 0x00000000) => (0x00000040, 0x00000040, 0x00000003, 0x00000000)),
((0x00000006, 0x00000000) => (0x00000004, 0x00000000, 0x00000001, 0x00000000)),
((0x00000007, 0x00000000) => (0x00000000, 0x000001a9, 0x00000000, 0x00000000)),
((0x00000008, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x00000009, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x0000000a, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x0000000b, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x0000000c, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x0000000d, 0x00000000) => (0x00000007, 0x00000340, 0x000003c0, 0x40000000)),
((0x80000000, 0x00000000) => (0x8000001e, 0x68747541, 0x444d4163, 0x69746e65)),
((0x80000001, 0x00000000) => (0x00660f01, 0x00000000, 0x2febbfff, 0x2fd3fbff)),
((0x80000002, 0x00000000) => (0x20444d41, 0x2d303141, 0x30303738, 0x61522050)),
((0x80000003, 0x00000000) => (0x6e6f6564, 0x2c365220, 0x20303120, 0x706d6f43)),
((0x80000004, 0x00000000) => (0x20657475, 0x65726f43, 0x43342073, 0x0047362b)),
((0x80000005, 0x00000000) => (0xff40ff18, 0xff40ff30, 0x20080140, 0x60030140)),
((0x80000006, 0x00000000) => (0x64006400, 0x64004200, 0x04008140, 0x00000000)),
((0x80000007, 0x00000000) => (0x00000000, 0x00000005, 0x00000400, 0x000037d9)),
((0x80000008, 0x00000000) => (0x00003030, 0x00000000, 0x00004003, 0x00000000)),
((0x80000009, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x8000000a, 0x00000000) => (0x00000001, 0x00008000, 0x00000000, 0x0001bcff)),
((0x8000000b, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x8000000c, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x8000000d, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x8000000e, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x8000000f, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000010, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000011, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000012, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000013, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000014, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000015, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000016, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000017, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000018, 0x00000000) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x80000019, 0x00000000) => (0xf040f018, 0x64006400, 0x00000000, 0x00000000)),
((0x8000001a, 0x00000000) => (0x00000003, 0x00000000, 0x00000000, 0x00000000)),
((0x8000001b, 0x00000000) => (0x000007ff, 0x00000000, 0x00000000, 0x00000000)),
((0x8000001c, 0x00000000) => (0x00000000, 0x80032013, 0x00010200, 0xe000000f)),
((0x8000001d, 0x00000000) => (0x00000121, 0x01c0003f, 0x0000003f, 0x00000000)),
((0x8000001e, 0x00000000) => (0x00000010, 0x00000100, 0x00000000, 0x00000000)),
((0x00000004, 0x00000001) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
((0x0000000b, 0x00000001) => (0x00000000, 0x00000000, 0x00000000, 0x00000000)),
))

m-j-w commented

For reference, the following documents describe AMD CPUs, and how to retrieve core count via cpuid:

Thus, the following successfully retrieves the physical core count:

# physical core count
Int((cpuid(0x8000_0008)[3] % 8)+1)
# logical core count
Int((cpuid(0x0000_0001)[2] >> 16) % 8)

This gives the correct (phys,logical) = (4,4) for the above cpuid table.

Furthermore, from the AMD manual above:

When HTT = 0, LogicalProcessorCount is reserved and the processor contains one core.
When HTT = 1 and CmpLegacy = 1, LogicalProcessorCount represents the number of cores per processor (c).

This appears to be the Intel legacy feature detection...

Also, since cache size detection doesn't work here, the provided feature leaf is 0x8000_001d, which is in fact available...

m-j-w commented

And here's a great resource with lots of additional cpuid table dumps: http://users.atw.hu/instlatx64/

m-j-w commented

See PR #26 for work in progress.

m-j-w commented

fixed by #26
at least for everything that's not threadripper/ryzen (family 0x17)