Python CPU Feature Detection
Project description
cpufeature
Prototype of replacement for cpuinfo.py
for high-performance Python modules. Detects CPU features such as:
- SIMD instruction support
- Number of cores (both virtual and physical)
- Cache sizes
It is fast, with an import+execution time of ~1 ms
It is written in C99. It supports Windows with MSVC and Linux with GCC/LLVM compilers. MacOSX should also work with GCC/LLVM but has not been tested.
It is licensed under Creative Commons Zero, so it may be freely incorporated as a submodule into your own projects.
It needs to be tested on a variety of machines.
Example
The module generates a dict
called CPUFeature
on import which contains useful information regarding optimization and compilation for the host. For my Intel i7-7820X Skylake CPU, it generates the following info:
> python -c "import cpufeature; cpufeature.print_features()"
=== CPU FEATURES === VendorId : GenuineIntel num_virtual_cores : 16 num_physical_cores : 8 num_threads_per_core : 2 num_cpus : 1 cache_line_size : 64 cache_L1_size : 32768 cache_L2_size : 1048576 cache_L3_size : 11534336 OS_x64 : True OS_AVX : True OS_AVX512 : True MMX : True x64 : True ABM : True RDRAND : True BMI1 : True BMI2 : True ADX : True PREFETCHWT1 : False MPX : True SSE : True SSE2 : True SSE3 : True SSSE3 : True SSE4.1 : True SSE4.2 : True SSE4.a : False AES : True SHA : False AVX : True XOP : False FMA3 : True FMA4 : False AVX2 : True AVX512f : True AVX512pf : False AVX512er : False AVX512cd : True AVX512vl : True AVX512bw : True AVX512dq : True AVX512ifma : False AVX512vbmi : False
Notes on Fields
- If
num_threads_per_core > 1
likely Intel Hyperthreading (or equivalent architecture) is present. The physical core count may be unreliable in virtual environments. - Cache sizes are in bytes.
- For AVX2, check
AVX2
andOS_AVX2
. - For AVX512, check
AVX512f
andOS_AVX512
. Python support for AVX512 instructions is highly limited outside of compilation with ICC. MSVC does not have AVX512 support until MSVC2017.
Authors
- Based on FeatureDetector by Alexander Yee (https://github.com/Mysticial/FeatureDetector).
- Ported to Python by Robert A. McLeod, who added detection of cores, and cache sizes.
drfinkus
contributed to AMD support.WidgetA
contributed support for compilation with Clang.
Release Notes
0.2.0
- Added support for AMD processors.
- Added a script for
valgrind
to more easier locate problems when the module crashes.
0.1.1
- Fixes for compilation with
clang
.
0.1.0
- Added detection of processors, cores, and cache sizes
- Created Python wrapper around FeatureDetector
- Reduced FeatureDetector to C99 for better cross-platform compatibility
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for cpufeature-0.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6cbcf4e5f018236d73e087245cabedc1f79a816597be2600cb4ac877611ff6d |
|
MD5 | 348e62cf4704e7e14a45f9601c055afb |
|
BLAKE2b-256 | 7668ed554537da337af4f5834d54f6080c52be1e2ca13db0f650ac8efedbe535 |
Hashes for cpufeature-0.2.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73e004658b076445735cb01ce1d7fbcac88d5084c031eb0560ec33aa46b8e6b |
|
MD5 | bc7120ec539c65e2d5d822c603106ab4 |
|
BLAKE2b-256 | f5904b32bf7da7cbd69f07a3eaf7b6b5e3a3ed437be7cd3c036cd0e6453c5f9a |
Hashes for cpufeature-0.2.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6de1c1f857e19285e7835d36ebc4ed96cf468b904c675be26913ed3a3181422 |
|
MD5 | be4efa17d9a5550cc93d372c3b4fb2e5 |
|
BLAKE2b-256 | 50cb7a45c162b7f4fe6254be90fadf21cb9ada31dfe1cfb4b9f2da4fec8b5405 |
Hashes for cpufeature-0.2.0-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bb4166fc6fa03eb7d867210559f500e4a5772b729ae0f7aaa8c57776ab7501e |
|
MD5 | 6b8433b9439f9f143947191910824e9f |
|
BLAKE2b-256 | 7c281e887b5b2ff28ab20012fdcf0e1232b417dfc27f6f332d5f7d8e49de73a8 |
Hashes for cpufeature-0.2.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91ef011f345229c7abaa5c3df15b20adcae937f4eec1dce824fb39099fce9ebd |
|
MD5 | 168c458da041edb39c3e6c3894d5c851 |
|
BLAKE2b-256 | ba5d3afd48d6761bd3db2710ade600ed32d944c9aa1d325a3223511af386e490 |
Hashes for cpufeature-0.2.0-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7907d0fac7f194d3b2c4b1dfa738a1f4ca38ea5a1aafbcaefe589cd96a2a358 |
|
MD5 | 2a6ed7da8563034aaf473a41871b7057 |
|
BLAKE2b-256 | 8ee14deb2d8ee772920822a3e841f2ab4eee7014f39a20737c57d76e61cc645a |
Hashes for cpufeature-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad4d345673c8c13400dbef8067322f4683ff62ad604ff51f45238e520630ab5d |
|
MD5 | 4f50606e08984ee0569d0e324fc36a2e |
|
BLAKE2b-256 | 8088fc85e41eb60647b72acf9142c1099ebcf345bb75086162044ae515eb90c0 |
Hashes for cpufeature-0.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d470158d434377bf7ade7ef53331afb53b7f1b6176fc27491b1757e49ee9675e |
|
MD5 | 845fa0d8823ebb6c72fa18fc0caabc6e |
|
BLAKE2b-256 | 6660787f85505f49860748e190e3b7faf185512dc953e3292f17822936a47a17 |
Hashes for cpufeature-0.2.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9a0829a0ae5159dbd79e283c729d49bfa12cdb18b035e08a05a4217eaa93a51 |
|
MD5 | b46446fd9d0c1e6fe3902e61e470252a |
|
BLAKE2b-256 | a5d6d927025e540c6dcba789b4206ce69df05756e742b2cc856a90624d444256 |
Hashes for cpufeature-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b449f6a9ae715b223bfdb3adb46f3ac610985714ab1b893c90cc97bb196780a |
|
MD5 | 84be857aba142801c94f5e21cef07c60 |
|
BLAKE2b-256 | 0b7511738a3a39871b23ae4dc097aa9dc2e797f0688feceef867fa3305bcf687 |
Hashes for cpufeature-0.2.0-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb0db8315a722cd04ba1c2c2c51e28c550f04961bfb60eebe3e19fb32d585bad |
|
MD5 | 4ff59d0bd172c62dbc1de087d5f67ed4 |
|
BLAKE2b-256 | 92bad4b1ea5ffb716f8e8e93362ddadb5b2b2e389f259fe7c7d5604bef3a0a61 |
Hashes for cpufeature-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f4c80ee645b4d60071677af2ad452bd082ce4f883ef80e0731e35f6737ce14 |
|
MD5 | a49a54812fd50eb9b8628a2b9d54b21e |
|
BLAKE2b-256 | 69f1fc6ccdba30e46a5152ab491f52414391d880b08dba1ea9f74d432d3951f6 |
Hashes for cpufeature-0.2.0-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3e8f253ea5cc211725cd45a4d9c5866be7f9aaec372c1cef07e840056d70e2e |
|
MD5 | 69342f3819b500c50032f3942a23d62a |
|
BLAKE2b-256 | 06cfedcbe7b2cdccbeb9e3276dbec316236b02db59fad9d811b527dd78277ab4 |
Hashes for cpufeature-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4b0b48a7ace3041edba741fb54782d7a211ec07a04272616dcfea3be0ed14c7 |
|
MD5 | 9a8f14caa2f258007fd41f4c8c79f11f |
|
BLAKE2b-256 | bfae15d9e7ca697b40b117cd881f33de845a010ad6d1c44df374abbbb9593838 |
Hashes for cpufeature-0.2.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e500d733ab1d28c9a68fb954ae84c6f2a12f98819a25c947fc6332655b028150 |
|
MD5 | 286951023bf761c0dbc7b38cec8e2366 |
|
BLAKE2b-256 | 2e6c16465d488743809de8910849af8be4fd8f46c0bae45bbde93bc574e5ba2e |
Hashes for cpufeature-0.2.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a30511f8cfc1fcfc113cf409040bf34d7615cb725a5ace3982ed372b65653351 |
|
MD5 | 83b898018f229168e54cce922d9e2673 |
|
BLAKE2b-256 | 17fbe646f7242774fd4877a5744781492d94de8e35c6da542b6f275c85340da3 |
Hashes for cpufeature-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa981746875e175b06027d34fe09b8d049fb2b4ffedd62ea8bbb2b8f27acbdb7 |
|
MD5 | 0153058baa4e730a77ccde4913c8cdfd |
|
BLAKE2b-256 | 787ead2c48300508047935a06c6ae09e30504626aad2b75b17bebfbcf08546b5 |
Hashes for cpufeature-0.2.0-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 018ab626936bbfd323a86e111a9ebe77f4e2daf39889f96b6a8868ff2c7e2b19 |
|
MD5 | a7456d3b608a9c5366c593b3daf8fb7d |
|
BLAKE2b-256 | e3b9bccaf764508f6364de77a2ddd6a3e84b4d33fc051019f646aa8ec1bfe5c9 |
Hashes for cpufeature-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de62a5c4ab2db42cd22a8aba24c71d5b9fc8c038e8c18bb1108a5afbcfe6ab78 |
|
MD5 | a3cd158c42969254a6a08c003eb9fe6b |
|
BLAKE2b-256 | 9ed0527d231ef4dbb61bd5a04ea05b9618df6e2f2027434faaf3cc9e817e4a85 |
Hashes for cpufeature-0.2.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bcf3099819ef5e2ba4a1a3036ba6e94a914b5bc5248f5a289e257e1ce13d0a4 |
|
MD5 | aba740489e99f85d4f7774baa8ba239b |
|
BLAKE2b-256 | 81b812307a9a039610fb262071ec4a0153030f8e301ded02f3d8625b98007106 |
Hashes for cpufeature-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d9e47082beba2f7ab70c078ea072bd88dd342b396ffdbc985d49b50c7727788 |
|
MD5 | 119d5b80375fc52ae67114fc43bb2ce7 |
|
BLAKE2b-256 | 546cdca64f94dd8cebc3493123306ec379272ad08a48ab49a2eaa207a971fdab |
Hashes for cpufeature-0.2.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b37f261cac8e97f5c18aeb3718031401b89b7c8ace6a9344a1528986e6b821 |
|
MD5 | 956200f19394470a12859476f463cef1 |
|
BLAKE2b-256 | 7345526367133d5cca73fdb753a59362715be3bc456d2d4b04d8340c277975ad |
Hashes for cpufeature-0.2.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34876c943014d0c1cad800de2b8286f6e5163d79b72d661102a687cc683bb0a8 |
|
MD5 | 5196c43e6ce30e42000fe3d9a14baea2 |
|
BLAKE2b-256 | 6f00ab0332e7542a96aa7e90cb0bc3802550b5c37fe7efc3099aac9a3b3d7a52 |
Hashes for cpufeature-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b159a7c299c1c951022cdf465e08b5d1423943e8f96b20b9214139b83a6d7a85 |
|
MD5 | 9f1afbfe64ad06a019097dfb3199be1e |
|
BLAKE2b-256 | 76cef619bd5d3b3b01d8c00c7c6a664f6d37de951ef96dcaf7602e51acdb6c3a |
Hashes for cpufeature-0.2.0-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a2cc3c94594f1cb5f637cf4068b680c54209906263cd175a47e24b38fcab7b5 |
|
MD5 | e52b65923408a7dc8ebc11c809f58069 |
|
BLAKE2b-256 | 062b60ea9524fa728eea40ecc9d42c4c62c9cb9cc3b0802d51a9af64fe4bbd72 |
Hashes for cpufeature-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57147fdcdf701f4ea2c155661eb4d84f9ebb3487907cdad194c71177d63b882f |
|
MD5 | 0cb54ca3d76245adc3f143bd1fc12313 |
|
BLAKE2b-256 | b1193e974b3f098139a05339b6c89e89efd4f4c1bfbc76aa2d2e483c0e5371dc |
Hashes for cpufeature-0.2.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d15edd4a2da19119dd6decb2519864bfb26c0c1d1f452e0f51642c97101f41 |
|
MD5 | 5d81bc314aeffa8051afbc083ff28fe6 |
|
BLAKE2b-256 | 4f7fb98cae6db96a32a4ccff4294e6b8d6f3f21afbd395fafb64c22aaa0993a9 |
Hashes for cpufeature-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f8af87246724a30571f23fd7efa7d6f4fcdeea62457a3a5a0e71d3eb509f0de |
|
MD5 | 237a77f3cb4841bd54e5d30026511852 |
|
BLAKE2b-256 | 12798bb733fb319e6a9a052ed031d2ef56dd4bb99712064f7f83402947aba4df |