Git Product home page Git Product logo

hwloc.jl's Introduction

Portable Hardware Locality (Hwloc)

Build Status Build status Coverage Status

This Julia package wraps the hwloc library.

The Portable Hardware Locality (hwloc) software package provides a portable abstraction (across OS, versions, architectures, ...) of the hierarchical topology of modern architectures, including NUMA memory nodes, sockets, shared caches, cores and simultaneous multithreading. It also gathers various system attributes such as cache and memory information as well as the locality of I/O devices such as network interfaces, InfiniBand HCAs or GPUs. It primarily aims at helping applications with gathering information about modern computing hardware so as to exploit it accordingly and efficiently.

http://www.open-mpi.org/projects/hwloc/

Usage

The Julia module Hwloc provides a high-level wrapper of the hwloc library; that is, hwloc's data structure are translated into Julia types that contain the same information, but are modified to look "natural" in Julia. Low-level administrative tasks are hidden.

The most important function is Hwloc.topology_load, which examines the current node's hardware topology (memories, caches, cores, etc.), and returns a tree structure describing this topology. This corresponds to the output of the lstopo program.

import Hwloc
topology = Hwloc.topology_load()
println("Machine topology:")
print(topology)

This outputs the full information, such as:

D0: L0 P0 Machine  
    D1: L0 P0 Node  
        D2: L0 P0 Cache  Cache{size=8388608,depth=3,linesize=64,associativity=0,type=Unified}
            D3: L0 P0 Cache  Cache{size=262144,depth=2,linesize=64,associativity=8,type=Unified}
                D4: L0 P0 Cache  Cache{size=32768,depth=1,linesize=64,associativity=0,type=Data}
                    D5: L0 P0 Core  
                        D6: L0 P0 PU  
                        D6: L1 P1 PU  
            D3: L1 P1 Cache  Cache{size=262144,depth=2,linesize=64,associativity=8,type=Unified}
                D4: L1 P1 Cache  Cache{size=32768,depth=1,linesize=64,associativity=0,type=Data}
                    D5: L1 P1 Core  
                        D6: L2 P2 PU  
                        D6: L3 P3 PU  
            D3: L2 P2 Cache  Cache{size=262144,depth=2,linesize=64,associativity=8,type=Unified}
                D4: L2 P2 Cache  Cache{size=32768,depth=1,linesize=64,associativity=0,type=Data}
                    D5: L2 P2 Core  
                        D6: L4 P4 PU  
                        D6: L5 P5 PU  
            D3: L3 P3 Cache  Cache{size=262144,depth=2,linesize=64,associativity=8,type=Unified}
                D4: L3 P3 Cache  Cache{size=32768,depth=1,linesize=64,associativity=0,type=Data}
                    D5: L3 P3 Core  
                        D6: L6 P6 PU  
                        D6: L7 P7 PU  

Often, one only wants an overview of the topology, omitting details. The function Hwloc.getinfo does this, similar to the output of the hwloc-info program.

import Hwloc
topology = Hwloc.topology_load()
summary = Hwloc.getinfo(topology)
println("Machine overview:")
for obj in summary
    obj_type = obj[1]
    count = obj[2]
    println("$count $obj_type")
end

This may output:

1 Machine
1 Node
1 Cache
4 Cache
4 Cache
4 Core
8 PU

Obtaining particular information:

The number of (physical) cores and virtual cores (PUs):

import Hwloc
topology = Hwloc.topology_load()
counts = Hwloc.histmap(topology)
ncores = counts[:Core]
npus = counts[:PU]
println("This machine has $ncores cores and $npus PUs (processing units)")

This may print:

This machine has 4 cores and 8 PUs (processing units)

A shortcut is also provided for the number of (physical) cores:

import Hwloc
ncores = Hwloc.num_physical_cores()

The L1 cache properties:

import Hwloc
topology = Hwloc.topology_load()
l1cache = first(filter(t->t.type_==:Cache && t.attr.depth==1, topology)).attr
println("L1 cache information: $l1cache")

This may print:

L1 cache information: Cache{size=32768,depth=1,linesize=64,associativity=0,type=Data}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.