Skip to content

Commit

Permalink
wip on inserting process information
Browse files Browse the repository at this point in the history
  • Loading branch information
JBlaschke committed Jul 21, 2023
1 parent c95c25d commit f54ee3e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
18 changes: 14 additions & 4 deletions src/highlevel_api.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ..LibHwloc: hwloc_get_api_version
using ..LibHwloc: hwloc_get_api_version, HWLOC_OBJ_BRIDGE_HOST


"""
Expand All @@ -21,20 +21,30 @@ Prints the topology of the given `obj` as a tree to `io`.
"""
function print_topology(io::IO = stdout, obj::Object = gettopology(); indent = "", newline = false, prefix = "")
t = hwloc_typeof(obj)

# println("t=$(t) name=$(obj.name)")

idxstr = t in (:Package, :Core, :PU) ? "L#$(obj.logical_index) P#$(obj.os_index) " : ""
attrstr = string(obj.attr)

if t in (:L1Cache, :L2Cache, :L3Cache, :L1ICache)
tstr = first(string(t), 2)
attrstr = "("*_bytes2string(obj.attr.size)*")"
elseif t == :Bridge
if obj.attr.upstream_type == HWLOC_OBJ_BRIDGE_HOST
tstr = "HostBridge"
else
tstr = "PCIBridge"
end
else
tstr = string(t)
end

newline && print(io, "\n", indent)
print(io, prefix, tstr, " ",
idxstr,
attrstr, obj.mem > 0 ? "("*_bytes2string(obj.mem)*")" : "")
print(
io, prefix, tstr, " ", idxstr, attrstr,
obj.mem > 0 ? "("*_bytes2string(obj.mem)*")" : ""
)

for memchild in obj.memory_children
memstr = "("*_bytes2string(memchild.mem)*")"
Expand Down
28 changes: 18 additions & 10 deletions src/lowlevel_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ end
function show(io::IO, a::PCIDevAttr)
print(
io,
"PCIDev(domain=$(a.domain), " *
"bus=$(a.bus), " *
"func=$(a.func), " *
"class_id=$(hwloc_pci_class_string(a.class_id)), " *
"vendor_id=$(a.vendor_id), " *
"device_id=$(a.device_id), " *
"subvendor_id=$(a.subvendor_id), " *
"subdevice_id=$(a.subdevice_id), " *
"revision=$(a.revision), " *
"PCIDev(domain=$(a.domain), " *
"bus=$(a.bus), " *
"func=$(a.func), " *
"class_id=$(hwloc_pci_class_string(a.class_id)), " *
"vendor_id=$(a.vendor_id), " *
"device_id=$(a.device_id), " *
"subvendor_id=$(a.subvendor_id), " *
"subdevice_id=$(a.subdevice_id), " *
"revision=$(a.revision), " *
"linkspeed=$(a.linkspeed))"
)
end
Expand Down Expand Up @@ -262,7 +262,6 @@ function load(hobj::hwloc_obj_t)
os_index = mod(obj.os_index, Cint)

name = obj.name == C_NULL ? "" : unsafe_string(obj.name)
println(name)

attr = load_attr(obj.attr, type_)

Expand Down Expand Up @@ -298,6 +297,15 @@ function load(hobj::hwloc_obj_t)
end
end

misc_children = Object[]
if obj.misc_arity != 0
misc_child = obj.misc_first_child
while misc_child != C_NULL
push!(misc_children, load(misc_child))
misc_child = unsafe_load(misc_child).next_sibling
end
end

topo = Object(
type_, os_index, name, attr, mem, depth, logical_index, children,
memory_children, io_children
Expand Down

0 comments on commit f54ee3e

Please sign in to comment.