Detection#

Note that these functions respect the process’s CPU affinity. For example, if python is run with the following command:

taskset --cpu-list 0 python3

then, in that interpreter, detectCpus(), detectCores(), etc. will return 1, as only a single cpu is available to the process.


FUNCTIONS

hpk.detectArchitecture()#

detectArchitecture() -> hpk.Architecture

Returns the instruction set architecture available to the current process.

hpk.detectCpus()#

detectCpus() -> int

Returns the number of CPUs (i.e., hardware threads) available to the current process.

hpk.detectCores()#

detectCores() -> int

Returns the number of cores available to the current process.

hpk.detectDies()#

detectDies() -> int

Returns the number of dies available to the current process.

hpk.detectPackages()#

detectPackages() -> int

Returns the number of packages available to the current process.

hpk.detectDataCache(int cacheLevel)#

detectDataCache(cacheLevel: int) -> hpk.CacheInfo

Returns information describing the hardware data cache present at the specified level for the CPU running the current process.


CLASS

class hpk.CacheInfo#

Provides processor cache information. {size, sharedCpus, lineSize, sets, ways}

property lineSize#

Size of each cache line in bytes

property sets#

Number of sets (cache lines per way)

property sharedCpus#

Number of CPUs sharing the cache

property size#

Total size of the cache in KiB

property ways#

Associativity (cache lines per set)