pytorch / cpuinfo

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

Use sysctls available in macOS 12/iOS 15 for Apple silicon #65

Closed Developer-Ecosystem-Engineering closed 2 years ago

Developer-Ecosystem-Engineering commented 3 years ago

The patch applies to ARM and should not change any behavior for x86_64 / Intel. In general, it'll use newer sysctls when they're available, but fallback to previous implementations when they're not present. Newer sysctls are available in iOS 15 and macOS Monterey 12.

Example output:

Previous cpu-info running on macOS / M1:

Packages:
        0:
Microarchitectures:
        4x Firestorm
        4x Icestorm
Cores:
        0: 1 processor (0), Apple Firestorm
        1: 1 processor (1), Apple Firestorm
        2: 1 processor (2), Apple Firestorm
        3: 1 processor (3), Apple Firestorm
        4: 1 processor (4), Apple Icestorm
        5: 1 processor (5), Apple Icestorm
        6: 1 processor (6), Apple Icestorm
        7: 1 processor (7), Apple Icestorm
Logical processors:
        0
        1
        2
        3
        4
        5
        6
        7

cpu-info running on macOS / M1 after patch:

Packages:
        0: Apple M1
Microarchitectures:
        4x Firestorm
        4x Icestorm
Cores:
        0: 1 processor (0), Apple Firestorm
        1: 1 processor (1), Apple Firestorm
        2: 1 processor (2), Apple Firestorm
        3: 1 processor (3), Apple Firestorm
        4: 1 processor (4), Apple Icestorm
        5: 1 processor (5), Apple Icestorm
        6: 1 processor (6), Apple Icestorm
        7: 1 processor (7), Apple Icestorm
Logical processors:
        0
        1
        2
        3
        4
        5
        6
        7

Previous isa-info running on macOS / M1:

Instruction sets:
        ARM v8.1 atomics: yes
        ARM v8.1 SQRDMLxH: no
        ARM v8.2 FP16 arithmetics: yes
        ARM v8.3 dot product: yes
        ARM v8.3 JS conversion: no
        ARM v8.3 complex: no
SIMD extensions:
        ARM SVE: no
        ARM SVE 2: no
Cryptography extensions:
        AES: yes
        SHA1: yes
        SHA2: yes
        PMULL: yes
        CRC32: yes

isa-info running on macOS Monterey 12 / M1 after patch:

Instruction sets:
        ARM v8.1 atomics: yes
        ARM v8.1 SQRDMLxH: yes
        ARM v8.2 FP16 arithmetics: yes
        ARM v8.2 FHM: yes
        ARM v8.3 dot product: yes
        ARM v8.3 JS conversion: yes
        ARM v8.3 complex: yes
SIMD extensions:
        ARM SVE: no
        ARM SVE 2: no
Cryptography extensions:
        AES: yes
        SHA1: yes
        SHA2: yes
        PMULL: yes
        CRC32: yes

Previous cache-info running on macOS / M1:

Max cache size (upper bound): 4194304 bytes
L1 instruction cache: 8 x 128 KB, 4-way set associative (256 sets), 128 byte lines, shared by 1 processors
L1 data cache: 8 x 64 KB, 4-way set associative (128 sets), 128 byte lines, shared by 1 processors
L2 data cache: 4 MB (exclusive), 8-way set associative (4096 sets), 128 byte lines, shared by 8 processors

cache-info running on macOS Monterey 12 / M1 after patch:

Max cache size (upper bound): 12582912 bytes
L1 instruction cache: 4 x 192 KB, 4-way set associative (384 sets), 128 byte lines, shared by 1 processors
L1 instruction cache: 4 x 128 KB, 4-way set associative (256 sets), 128 byte lines, shared by 1 processors
L1 data cache: 4 x 128 KB, 4-way set associative (256 sets), 128 byte lines, shared by 1 processors
L1 data cache: 4 x 64 KB, 4-way set associative (128 sets), 128 byte lines, shared by 1 processors
L2 data cache: 12 MB (exclusive), 8-way set associative (12288 sets), 128 byte lines, shared by 4 processors
L2 data cache: 4 MB (exclusive), 8-way set associative (4096 sets), 128 byte lines, shared by 4 processors
facebook-github-bot commented 3 years ago

Hi @Developer-Ecosystem-Engineering!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

malfet commented 2 years ago

Closing as duplicated in #96

dlenski commented 3 months ago

The description of this PR mentions:

Updated package.name to also query machdep.cpu.brand_string if decode of hw.machine fails

But then that functionality was omitted (inadvertently?) in its refactoring in #100. I've added it back in #246.