class Hwloc::Obj
Public Instance Methods
==(other)
click to toggle source
# File lib/hwloc/Obj.rb, line 397 def ==(other) return other.kind_of?(Obj) && to_ptr == other.to_ptr end
add_infos(**dict)
click to toggle source
# File lib/hwloc/Obj.rb, line 620 def add_infos(**dict) dict.each { |k, v| err = Hwloc.hwloc_obj_add_info(self, k.to_s, v.to_s) raise EditionError if err == -1 } self end
attr()
click to toggle source
# File lib/hwloc/Obj.rb, line 628 def attr at = self[:attr] return nil if at.to_ptr.null? t = self[:type] case t when :OBJ_GROUP return at[:group] when :OBJ_PCI_DEVICE return at[:pcidev] when :OBJ_BRIDGE return at[:bridge] when :OBJ_OS_DEVICE return at[:osdev] else if API_VERSION >= API_VERSION_2_0 then return at[:numanode] if t == :OBJ_NUMANODE end return at[:cache] if self.is_a_cache? end return nil end
attr_snprintf(verbose=0, separator=",")
click to toggle source
# File lib/hwloc/Obj.rb, line 413 def attr_snprintf(verbose=0, separator=",") sz = Hwloc.hwloc_obj_attr_snprintf(nil, 0, self, separator, verbose) + 1 str_ptr = FFI::MemoryPointer::new(:char, sz) Hwloc.hwloc_obj_attr_snprintf(str_ptr, sz, self, separator, verbose) return str_ptr.read_string end
children()
click to toggle source
# File lib/hwloc/Obj.rb, line 457 def children arity = self[:arity] if arity == 0 then return [] else return self[:children].read_array_of_pointer(arity).collect { |p| c = Obj::new(p) c.instance_variable_set(:@topology, @topology) c } end end
descendants()
click to toggle source
# File lib/hwloc/Obj.rb, line 586 def descendants return each_descendant.to_a end
distances()
click to toggle source
# File lib/hwloc/Obj.rb, line 591 def distances distances_count = self[:distances_count] if distances_count == 0 then return [] else return self[:distances].read_array_of_pointer(distances_count).collect { |p| d = Distances::new(p) d.instance_variable_set(:@topology, @topology) d } end end
each_child(*args, &block)
click to toggle source
# File lib/hwloc/Obj.rb, line 470 def each_child(*args, &block) return children.each(*args, &block) end
each_descendant(&block)
click to toggle source
# File lib/hwloc/Obj.rb, line 487 def each_descendant(&block) if block then children.each { |c| c.each_obj(&block) } else to_enum(:each_descendant) end end
each_info(*args, &block)
click to toggle source
# File lib/hwloc/Obj.rb, line 616 def each_info(*args, &block) return infos.each(*args, &block) end
each_io_child(*args, &block)
click to toggle source
# File lib/hwloc/Obj.rb, line 523 def each_io_child(*args, &block) return io_children.each(*args, &block) end
each_memory_child(*args, &block)
click to toggle source
# File lib/hwloc/Obj.rb, line 509 def each_memory_child(*args, &block) return memory_children.each(*args, &block) end
each_misc_child(*args, &block)
click to toggle source
# File lib/hwloc/Obj.rb, line 537 def each_misc_child(*args, &block) return misc_children.each(*args, &block) end
each_obj(&block)
click to toggle source
# File lib/hwloc/Obj.rb, line 475 def each_obj(&block) if block then block.call self children.each { |c| c.each_obj(&block) } return self else to_enum(:each_obj) end end
Also aliased as: traverse
each_parent(&block)
click to toggle source
# File lib/hwloc/Obj.rb, line 565 def each_parent(&block) if block then if parent then block.call parent parent.each_parent(&block) end return self else to_enum(:each_parent) end end
Also aliased as: each_ancestor
infos()
click to toggle source
# File lib/hwloc/Obj.rb, line 605 def infos infos_count = self[:infos_count] return {} if infos_count == 0 inf_array = infos_count.times.collect { |i| o = ObjInfo::new(self[:infos] + i*ObjInfo.size) } inf_h = {} inf_array.each { |e| inf_h[e[:name].to_sym] = e[:value] if e[:name] } return inf_h end
inspect()
click to toggle source
# File lib/hwloc/Obj.rb, line 427 def inspect return to_s(1) end
io_children()
click to toggle source
# File lib/hwloc/Obj.rb, line 513 def io_children return [] if io_arity == 0 c = [] c.push( io_first_child ) (io_arity-1).times { c.push( c[-1].next_sibling ) } return c end
is_a_cache?()
click to toggle source
# File lib/hwloc/Obj.rb, line 659 def is_a_cache? (Hwloc::OBJ_L1CACHE..Hwloc::OBJ_L3ICACHE).include?(ObjType[type]) end
is_cache?()
click to toggle source
# File lib/hwloc/Obj.rb, line 675 def is_cache? Hwloc::hwloc_obj_type_is_cache(ObjType[type]) == 1 end
is_dcache?()
click to toggle source
# File lib/hwloc/Obj.rb, line 683 def is_dcache? Hwloc::hwloc_obj_type_is_dcache(ObjType[type]) == 1 end
is_icache?()
click to toggle source
# File lib/hwloc/Obj.rb, line 679 def is_icache? Hwloc::hwloc_obj_type_is_icache(ObjType[type]) == 1 end
is_io?()
click to toggle source
# File lib/hwloc/Obj.rb, line 667 def is_io? Hwloc::hwloc_obj_type_is_io(ObjType[type]) == 1 end
is_memory?()
click to toggle source
# File lib/hwloc/Obj.rb, line 671 def is_memory? Hwloc::hwloc_obj_type_is_memory(ObjType[type]) == 1 end
is_misc?()
click to toggle source
# File lib/hwloc/Obj.rb, line 687 def is_misc? ObjType[type] == Hwloc::OBJ_MISC end
is_normal?()
click to toggle source
# File lib/hwloc/Obj.rb, line 663 def is_normal? Hwloc::hwloc_obj_type_is_normal(ObjType[type]) == 1 end
memory_children()
click to toggle source
# File lib/hwloc/Obj.rb, line 499 def memory_children return [] if memory_arity == 0 c = [] c.push( memory_first_child ) (memory_arity-1).times { c.push( c[-1].next_sibling ) } return c end
misc_children()
click to toggle source
# File lib/hwloc/Obj.rb, line 527 def misc_children return [] if misc_arity == 0 c = [] c.push( misc_first_child ) (misc_arity-1).times { c.push( c[-1].next_sibling ) } return c end
parents()
click to toggle source
# File lib/hwloc/Obj.rb, line 577 def parents return each_parent.to_a end
Also aliased as: ancestors
to_s(verbose=0)
click to toggle source
# File lib/hwloc/Obj.rb, line 420 def to_s(verbose=0) attr_str = attr_snprintf(verbose) str = "#{type_snprintf(verbose)} L##{logical_index}" str += " (#{attr_str})" if attr_str != "" return str end
to_topo()
click to toggle source
# File lib/hwloc/Edition.rb, line 85 def to_topo new_topo = Topology::new new_topo.set_custom new_topo.custom_insert_topology( new_topo.root_obj , @topology, self) new_topo.load return new_topo end
type_snprintf(verbose=0)
click to toggle source
# File lib/hwloc/Obj.rb, line 401 def type_snprintf(verbose=0) sz = Hwloc.hwloc_obj_type_snprintf(nil, 0, self, verbose) + 1 str_ptr = FFI::MemoryPointer::new(:char, sz) Hwloc.hwloc_obj_type_snprintf(str_ptr, sz, self, verbose) return str_ptr.read_string end
type_string()
click to toggle source
# File lib/hwloc/Obj.rb, line 408 def type_string return Hwloc.hwloc_obj_type_string(type) end
Also aliased as: type_name