1. Joseph Poirier
  2. cpu


cpu /

Filename Size Date modified Message
71 B
315 B
1.5 KB
918 B
3.4 KB
4.1 KB
3.9 KB
480 B
1.5 KB

    cpu package reports processor topology

    currently reports (see main.go):
        - if an error was encountered which would invalidate info
        - if the cpuid instruction is present/executable, older 486 or below - always 1 core per package
        - if cpuid execution is restricted, unable to execute cpuid functions
        - if Hyper-Threading Technology is supported, but doesn't necessarily mean it's enabled
        - maximum number of processors supported by the OS
        - number of processors on line
        - Vendor name
        - report total package count
        - report total core count
        - report total thread count
        - report HTT per core count
        - report HTT per package count

    I'm currently working on code to enumerate through packages/cores/threads.
    I do development commits to the bitbucket repo but I'll be sure to make
    incremental tags for working code.

    At some point the package name will probably change to something broader
    like sys with the information items containing more detail, e.g. sys.CpuCnt.

    At this point the code has only been tested on 64-bit OS X.

    For multi-package systems the package count calculation
    probably isn't correct at the moment. It assumes that the
    physical package count can be derived by dividing the maximum
    processor count by the logical processor count of the package
    that the thread is running on, and that the configuration is

    The ideal way to calculate the package/core/thread count
    for multi-package systems is to iterate through the system
    by affinitizing the running thread, I'm working currently
    working on.

    A lot of this information can be derived on nix systems
    (linux?) using sysctl, examples:

    You ccould do this from a bash script or make or call to sysctl
    from within some Go code

    make install - builds and installs the package

    make main - builds and installs the package and creates the example file main

    see main.go

    see main.go

- Package refers to a physical processor that plugs in to a socket
- Core refers to a physical sub-system of a package. A core may contain 1 or more
  logical processors
- A logical processor refers to a hardware resource that can execute a single thread
- Hyperthreading refers to the technology that allows a processor core to provide the
  functionality of more than one logical core
- Simultaneous Multi-Threading refers to multiple logical processors within the same core
- Multi-Core Processor contains more than one physical core
- MultiProcessor Platform contains multiple physical sockets
- Hardware Multithreading refers to any combination of hardware support to allow
  multithreading, which could be any combination of SMT, multi-core, and multi-processor
- Processor Topology is the hierarchical relationship of shared vs dedicated hadrware resources

- add error enumerations
- handle non-windows systems that don't have _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF
- if 64-bit, or newer 32-bit, and the leaf value is less than 4 check IA32_MISC_ENABLES bit 22