Hwloc.jl
Hwloc.jl copied to clipboard
Numa distance matrix?
What would be necessary to exploit the Hwloc numa distance feature (that is available in the wrapper already)?
I'm interested in implementing it and wanted to follow the templates/models the maintainers recommend to expose the interface in a more friendly manner. The way I've been doing it is through the following code.
using Hwloc
topo = Hwloc.topology_init()
Hwloc.topology_load(topo)
nnuma = Hwloc.num_numa_nodes()
if nnuma == 0
println("No NUMA nodes found on this system.")
else
nr = Ref{Cuint}(0)
distances_ptr = Ref{Ptr{Hwloc.LibHwloc.hwloc_distances_s}}(C_NULL)
kind = 0
flags = 0
numa_type = Hwloc.LibHwloc.HWLOC_OBJ_NUMANODE
ret = Hwloc.LibHwloc.hwloc_distances_get_by_type(topo, numa_type, nr, distances_ptr, kind, flags)
if ret != 0 || nr[] == 0 || distances_ptr[] == C_NULL
println("No NUMA distances found or error occurred.")
else
distances = unsafe_load(distances_ptr[])
n = distances.nbobjs
vals = unsafe_wrap(Array, distances.values, (n, n))
println("NUMA distance matrix:")
println(vals)
Hwloc.LibHwloc.hwloc_distances_release(topo, distances_ptr[])
end
end