hlibcpuid-0.2.0: Bindings to https://github.com/anrieff/libcpuid

Copyright(c) Daniel Taskoff 2020
LicenseMIT
Maintainerdaniel.taskoff@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

System.LibCPUID

Contents

Description

Bindings to https://github.com/anrieff/libcpuid.

Currently implemented:

  • getting CPU vendor and brand strings, TSC availability, number of physical, and logical cores
  • measuring CPU clock frequency using a time-stamp counter and time intervals
  • getting CPU clock frequency as reported by the OS
  • measuring CPU clock frequency using a busy-wait cycle
Synopsis

LibCPUID utilities

getTotalLogicalCores :: IO Int Source #

Get the total number of logical cores (even if CPUID is not present). If CPUID is present, the following is true:

clockByOS :: IO Int Source #

Get the CPU clock frequency in MHz, as reported by the OS (which may differ from the true clock). If the OS is not supported, the result will be -1.

clockMeasure :: Int -> ShouldQuadCheck -> IO Int Source #

Get the CPU clock frequency in MHz, after performing a busy-wait cycle for the given time in ms. If RDTSC is not supported, the result will be -1.

newtype ShouldQuadCheck Source #

Should clockMeasure do a more thorough measurement (quadruple checking).

Constructors

ShouldQuadCheck Bool 

clock :: IO Int Source #

Get the CPU clock frequency in MHz, by trying all available methods. If all of them fail, the result will be -1.

Reexports from System.LibCPUID.CPUID

data CPUID Source #

CPU information and features.

Constructors

CPUID 

Fields

Instances
Storable CPUID Source # 
Instance details

Defined in System.LibCPUID.CPUID

Methods

sizeOf :: CPUID -> Int #

alignment :: CPUID -> Int #

peekElemOff :: Ptr CPUID -> Int -> IO CPUID #

pokeElemOff :: Ptr CPUID -> Int -> CPUID -> IO () #

peekByteOff :: Ptr b -> Int -> IO CPUID #

pokeByteOff :: Ptr b -> Int -> CPUID -> IO () #

peek :: Ptr CPUID -> IO CPUID #

poke :: Ptr CPUID -> CPUID -> IO () #

cpuid :: IO (Either String CPUID) Source #

Get CPU information and features, or an error message, if the CPU can't be identified by libcpuid.

Reexports from System.LibCPUID.TSC

mark :: TSCMark -> IO () Source #

Mark a time interval for calculating the CPU clock frequency.

unmark :: TSCMark -> IO () Source #

Unmark a time interval for calculating the CPU clock frequency.

clockBy :: TSCMark -> IO Int Source #

Calculate the CPU clock frequency in MHz, for an interval, marked with mark, and unmark. If the interval is insufficient, the result will be -1.