Class: Hwloc::Topology

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hwloc/Bind.rb,
lib/hwloc/Bind.rb,
lib/hwloc/Export.rb,
lib/hwloc/Edition.rb,
lib/hwloc/Topology.rb

Constant Summary collapse

Flags =
TopologyFlags

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Topology

Returns a new instance of Topology.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/hwloc/Topology.rb', line 172

def initialize( *args )
  if args.length == 0 then
    ptr = FFI::MemoryPointer::new( :pointer )
    err = Hwloc.hwloc_topology_init(ptr)
    raise TopologyError if err == -1
    @ptr = FFI::AutoPointer::new( ptr.read_pointer, Hwloc.method(:hwloc_topology_destroy) )
  elsif args.length == 1 then
    arg = args[0]
    if arg.kind_of?( Topology ) then
      ptr = FFI::MemoryPointer::new( :pointer )
      err = Hwloc.hwloc_topology_dup(ptr, arg.ptr)
      raise TopologyError if err == -1
      @ptr = FFI::AutoPointer::new( ptr.read_pointer, Hwloc.method(:hwloc_topology_destroy) )
    elsif arg.kind_of?( String ) then
      ptr = FFI::MemoryPointer::new( :pointer )
      err = Hwloc.hwloc_topology_init(ptr)
      raise TopologyError if err == -1
      @ptr = FFI::AutoPointer::new( ptr.read_pointer, Hwloc.method(:hwloc_topology_destroy) )
      @xml_buffer = FFI::MemoryPointer::from_string(arg)
      set_xmlbuffer(@xml_buffer)
    else
      raise TopologyError, "Invalid argument"
    end
  else
    raise TopologyError, "Invalid argument"
  end
end

Instance Attribute Details

#ptrObject (readonly)

Returns the value of attribute ptr.



166
167
168
# File 'lib/hwloc/Topology.rb', line 166

def ptr
  @ptr
end

Class Method Details

.const_missing(sym) ⇒ Object



155
156
157
158
159
160
161
162
# File 'lib/hwloc/Topology.rb', line 155

def self.const_missing( sym )
  begin
    value = Hwloc.const_get( "TOPOLOGY_#{sym}".to_sym )
    return value
  rescue
  end
  super
end

Instance Method Details

#alloc(size) ⇒ Object

Raises:



322
323
324
325
326
327
# File 'lib/hwloc/Bind.rb', line 322

def alloc(size)
  ptr = Hwloc.hwloc_alloc(@ptr, size)
  raise MembindError if ptr.null?
  ptr = ptr.slice(0, size)
  return FFI::AutoPointer::new(ptr, self.method(:free))
end

#alloc_membind(size, set, policy, *flags) ⇒ Object

Raises:



329
330
331
332
333
334
# File 'lib/hwloc/Bind.rb', line 329

def alloc_membind(size, set, policy, *flags)
  ptr = Hwloc.hwloc_alloc_membind(@ptr, size, set, policy, flags)
  raise MembindError if ptr.null?
  ptr = ptr.slice(0, size)
  return FFI::AutoPointer::new(ptr, self.method(:free))
end

#alloc_membind_nodeset(size, nodeset, policy, *flags) ⇒ Object

Raises:



196
197
198
199
200
201
# File 'lib/hwloc/Bind.rb', line 196

def alloc_membind_nodeset(size, nodeset, policy, *flags)
  ptr = Hwloc.hwloc_alloc_membind_nodeset(@ptr, size, nodeset, policy, flags)
  raise MembindError if ptr.null?
  ptr = ptr.slice(0, size)
  return FFI::AutoPointer::new(ptr, self.method(:free))
end

#alloc_membind_policy(size, set, policy, *flags) ⇒ Object



336
337
338
339
340
341
342
343
344
345
# File 'lib/hwloc/Bind.rb', line 336

def alloc_membind_policy(size, set, policy, *flags)
  begin
    return alloc_membind(size, set, policy, flags)
  rescue MembindError
    set_membind(set, policy, flags)
    ptr = alloc(size)
    ptr.clear if policy != Hwloc::MEMBIND_FIRSTTOUCH
    return ptr
  end
end

#alloc_membind_policy_nodeset(size, nodeset, policy, *flags) ⇒ Object



203
204
205
206
207
208
209
210
211
212
# File 'lib/hwloc/Bind.rb', line 203

def alloc_membind_policy_nodeset(size, nodeset, policy, *flags)
  begin
    return alloc_membind_nodeset(size, nodeset, policy, flags)
  rescue MembindError
    set_membind_nodeset(nodeset, policy, flags)
    ptr = alloc(size)
    ptr.clear if policy != Hwloc::MEMBIND_FIRSTTOUCH
    return ptr
  end
end

#checkObject



211
212
213
214
# File 'lib/hwloc/Topology.rb', line 211

def check
  Hwloc.hwloc_topology_check(@ptr)
  return self
end

#custom_insert_group_object_by_parent(parent, groupdepth) ⇒ Object

Raises:



59
60
61
62
63
64
# File 'lib/hwloc/Edition.rb', line 59

def custom_insert_group_object_by_parent(parent, groupdepth)
  obj = Hwloc.hwloc_custom_insert_group_object_by_parent(@ptr, parent, groupdepth)
  raise EditionError if obj.to_ptr.null?
  obj.instance_variable_set(:@topology, self)
  return obj
end

#custom_insert_topology(newparent, oldtopology, oldroot = nil) ⇒ Object

Raises:



53
54
55
56
57
# File 'lib/hwloc/Edition.rb', line 53

def custom_insert_topology(newparent, oldtopology, oldroot = nil)
  err = Hwloc.hwloc_custom_insert_topology(@ptr, newparent, oldtopology.ptr, oldroot)
  raise EditionError if err == -1
  return self
end

#distances(*kind) ⇒ Object

Raises:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/hwloc/Topology.rb', line 512

def distances(*kind)
  num_d = distances_number(*kind)
  return [] if num_d == 0
  nr = FFI::MemoryPointer::new(:uint)
  nr.write_uint num_d
  dis = FFI::MemoryPointer::new(:pointer, num_d)
  err = Hwloc.hwloc_distances_get(@ptr, nr, dis, kind, 0);
  raise TopologyError if err == -1
  return dis.read_array_of_pointer(nr.read_uint).collect { |p|
    d = Distances::new(p)
    d.instance_variable_set(:@topology, self)
    d
  }
end

#distances_add(objs, values, *kind, flags: []) ⇒ Object

Raises:



555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/hwloc/Topology.rb', line 555

def distances_add(objs, values, *kind, flags: [])
  nbobjs = objs.size
  vals = values.flatten
  raise TopologyError if vals.length != nbobjs * nbobjs
  vals_p = FFI::MemoryPointer::new(:uint64, vals.length)
  vals_p.write_array_of_uint64(vals)
  objs_p = FFI::MemoryPointer::new(:pointer, objs.length)
  objs_p.write_array_of_pointer(objs.collect(&:to_ptr))
  err = Hwloc.hwloc_distances_add(@ptr, nbobjs, objs_p, vals_p, kind, flags)
  raise TopologyError if err == -1
  self
end

#distances_by_depth(depth, *kind) ⇒ Object

Raises:



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/hwloc/Topology.rb', line 527

def distances_by_depth(depth, *kind)
  nr = FFI::MemoryPointer::new(:uint)
  nr.write_uint 0
  err = Hwloc.hwloc_distances_get_by_depth(@ptr, depth, nr, nil, kind, 0);
  raise TopologyError if err == -1
  num_d = nr.read_uint
  return [] if num_d == 0
  dis = FFI::MemoryPointer::new(:pointer, num_d)
  err = Hwloc.hwloc_distances_get_by_depth(@ptr, depth, nr, dis, kind, 0);
  return dis.read_array_of_pointer(nr.read_uint).collect { |p|
    d = Distances::new(p)
    d.instance_variable_set(:@topology, self)
    d
  }
end

#distances_by_type(type, *kind) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
# File 'lib/hwloc/Topology.rb', line 543

def distances_by_type(type, *kind)
  depth = get_type_depth(type)
  return [] if depth == Hwloc::TYPE_DEPTH_UNKNOWN
  if depth == Hwloc::TYPE_DEPTH_MULTIPLE then
    depth_list = each_obj.select{ |e| e.type == type }.collect{ |e| e.depth }.uniq
    res = depth_list.collect { |d| distances_by_depth(d, *kind) }.reduce(:+)
    return [] unless res
    return res
  end
  return distances_by_depth(depth, *kind)
end

#distances_number(*kind) ⇒ Object

Raises:



502
503
504
505
506
507
508
509
510
# File 'lib/hwloc/Topology.rb', line 502

def distances_number(*kind)
  res = nil
  nr = FFI::MemoryPointer::new(:uint)
  nr.write_uint 0
  err = Hwloc.hwloc_distances_get(@ptr, nr, nil, kind, 0);
  raise TopologyError if err == -1
  res = nr.read_uint
  res
end

#distances_removeObject

Raises:



568
569
570
571
572
# File 'lib/hwloc/Topology.rb', line 568

def distances_remove
  err = Hwloc.hwloc_distances_remove(@ptr)
  raise TopologyError if err == -1
  self
end

#distances_remove_by_depth(depth) ⇒ Object

Raises:



574
575
576
577
578
# File 'lib/hwloc/Topology.rb', line 574

def distances_remove_by_depth(depth)
  err = Hwloc.hwloc_distances_remove_by_depth(@ptr, depth)
  raise TopologyError if err == -1
  self
end

#distances_remove_by_type(type) ⇒ Object



580
581
582
583
584
585
586
587
588
589
# File 'lib/hwloc/Topology.rb', line 580

def distances_remove_by_type(type)
  depth = get_type_depth(type)
  return self if depth == Hwloc::TYPE_DEPTH_UNKNOWN
  if depth == Hwloc::TYPE_DEPTH_MULTIPLE then
    depth_list = each_obj.select{ |e| e.type == type }.collect{ |e| e.depth }.uniq
    depth_list.each { |d| distances_remove_by_depth(d) }
    return self
  end
  return distances_remove_by_depth(depth)
end

#dupObject



207
208
209
# File 'lib/hwloc/Topology.rb', line 207

def dup
  return Topology::new( self )
end

#each_by_depth(depth) ⇒ Object



448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/hwloc/Topology.rb', line 448

def each_by_depth(depth)
  if block_given? then
    idx = 0
    while o = get_obj_by_depth(depth, idx) do
      yield o
      idx += 1
    end
    return self
  else
    to_enum(:each_by_depth, depth)
  end
end

#each_by_type(type, &block) ⇒ Object



461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/hwloc/Topology.rb', line 461

def each_by_type(type, &block)
  if block_given? then
    depth = get_type_depth(type)
    if depth == Hwloc::TYPE_DEPTH_MULTIPLE
      each_obj.select{ |e| e.type == type }.each(&block)
      return self
    else
      return each_by_depth(depth, &block)
    end
  else
    to_enum(:each_by_type, type)
  end
end

#each_obj(&block) ⇒ Object Also known as: traverse, each



487
488
489
490
491
492
493
494
495
# File 'lib/hwloc/Topology.rb', line 487

def each_obj(&block)
  if block then
    obj = get_root_obj
    obj.each_obj(&block)
    return self
  else
    to_enum(:each_obj)
  end
end

#export_synthetic(flags = 0) ⇒ Object

Raises:



86
87
88
89
90
91
# File 'lib/hwloc/Export.rb', line 86

def export_synthetic(flags = 0)
  str_ptr = FFI::MemoryPointer::new(:char, 2048)
  err = Hwloc.hwloc_topology_export_synthetic(@ptr, str_ptr, str_ptr.size, flags)
  raise ExportError, "Topology not symetric" if err == -1
  return str_ptr.read_string
end

#export_xml(xmlpath, flags = 0) ⇒ Object

Raises:



40
41
42
43
44
# File 'lib/hwloc/Export.rb', line 40

def export_xml(xmlpath)
  err = Hwloc.hwloc_topology_export_xml(@ptr, xmlpath)
  raise ExportError if err == -1
  return self
end

#export_xmlbuffer(flags = 0) ⇒ Object

Raises:



46
47
48
49
50
51
52
53
# File 'lib/hwloc/Export.rb', line 46

def export_xmlbuffer
  data_p = FFI::MemoryPointer::new(:pointer)
  count_p = FFI::MemoryPointer::new(:int)
  err = Hwloc.hwloc_topology_export_xmlbuffer(@ptr, data_p, count_p)
  raise ExportError if err == -1
  xmlbuffer_p = data_p.read_pointer.slice(0, count_p.read_int)
  return FFI::AutoPointer::new(xmlbuffer_p, self.method(:free_xmlbuffer))
end

#get_area_membind(pointer, *flags) ⇒ Object

Raises:



304
305
306
307
308
309
310
311
# File 'lib/hwloc/Bind.rb', line 304

def get_area_membind(pointer, *flags)
  set = Bitmap::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_area_membind(@ptr, pointer, pointer.size, set, policy_p, flags)
  raise MembindError if err == -1
  policy = MembindPolicy[policy_p.read_int]
  return [set, policy]
end

#get_area_membind_nodeset(pointer, *flags) ⇒ Object

Raises:



187
188
189
190
191
192
193
194
# File 'lib/hwloc/Bind.rb', line 187

def get_area_membind_nodeset(pointer, *flags)
  nodeset = Nodeset::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy_p, flags)
  raise MembindError if err == -1
  policy = MembindPolicy[policy_p.read_int]
  return [nodeset, policy]
end

#get_area_memlocation(pointer, *flags) ⇒ Object

Raises:



314
315
316
317
318
319
# File 'lib/hwloc/Bind.rb', line 314

def get_area_memlocation(pointer, *flags)
  set = Bitmap::new
  err = Hwloc.hwloc_get_area_memlocation(@ptr, pointer, pointer.size, set, flags)
  raise MembindError if err == -1
  return set
end

#get_cpubind(*flags) ⇒ Object

Raises:



69
70
71
72
73
74
# File 'lib/hwloc/Bind.rb', line 69

def get_cpubind(*flags)
  cpuset = Cpuset::new
  err = Hwloc.hwloc_get_cpubind(@ptr, cpuset, flags)
  raise CpubindError if err == -1
  return cpuset
end

#get_depthObject Also known as: depth



363
364
365
# File 'lib/hwloc/Topology.rb', line 363

def get_depth
  Hwloc.hwloc_topology_get_depth(@ptr)
end

#get_depth_type(depth) ⇒ Object

Raises:



373
374
375
376
377
# File 'lib/hwloc/Topology.rb', line 373

def get_depth_type(depth)
  type = Hwloc.hwloc_get_depth_type(@ptr, depth)
  raise TopologyError, "Invalid argument" if type == -1
  return type
end

#get_flagsObject Also known as: flags



296
297
298
# File 'lib/hwloc/Topology.rb', line 296

def get_flags
  Hwloc.hwloc_topology_get_flags(@ptr)
end

#get_last_cpu_location(*flags) ⇒ Object

Raises:



102
103
104
105
106
107
# File 'lib/hwloc/Bind.rb', line 102

def get_last_cpu_location(*flags)
  cpuset = Cpuset::new
  err = Hwloc.hwloc_get_last_cpu_location(@ptr, cpuset, flags)
  raise CpubindError if err == -1
  return cpuset
end

#get_membind(*flags) ⇒ Object

Raises:



274
275
276
277
278
279
280
281
# File 'lib/hwloc/Bind.rb', line 274

def get_membind(*flags)
  set = Bitmap::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_membind(@ptr, set, policy_p, flags)
  raise MembindError if err == -1
  policy = policy_p.read_int
  return [set, MembindPolicy[policy]]
end

#get_membind_nodeset(*flags) ⇒ Object

Raises:



157
158
159
160
161
162
163
164
# File 'lib/hwloc/Bind.rb', line 157

def get_membind_nodeset(*flags)
  nodeset = Nodeset::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_membind_nodeset(@ptr, nodeset, policy_p, flags)
  raise MembindError if err == -1
  policy = policy_p.read_int
  return [nodeset, MembindPolicy[policy]]
end

#get_nbobjs_by_depth(depth) ⇒ Object



401
402
403
# File 'lib/hwloc/Topology.rb', line 401

def get_nbobjs_by_depth(depth)
  return Hwloc.hwloc_get_nbobjs_by_depth(@ptr, depth)
end

#get_nbobjs_by_type(type) ⇒ Object



405
406
407
408
409
410
# File 'lib/hwloc/Topology.rb', line 405

def get_nbobjs_by_type(type)
  depth = get_type_depth(type)
  return 0 if depth == Hwloc::TYPE_DEPTH_UNKNOWN
  return each_obj.select{ |e| e.type == type }.count if depth == Hwloc::TYPE_DEPTH_MULTIPLE
  return Hwloc.hwloc_get_nbobjs_by_depth(@ptr, depth)
end

#get_next_obj_by_depth(depth, prev) ⇒ Object



432
433
434
435
436
# File 'lib/hwloc/Topology.rb', line 432

def get_next_obj_by_depth(depth, prev)
  return get_obj_by_depth(depth, 0) if prev.nil?
  return nil if prev.depth != depth
  return prev.next_cousin
end

#get_next_obj_by_type(type, prev) ⇒ Object



438
439
440
441
442
443
444
445
446
# File 'lib/hwloc/Topology.rb', line 438

def get_next_obj_by_type(type, prev)
  depth = get_type_depth(type)
  return nil if depth == Hwloc::TYPE_DEPTH_UNKNOWN
  if depth == Hwloc::TYPE_DEPTH_MULTIPLE then
    list = each_obj.select{ |e| e.type == type }
    return list[list.find_index { |e| e.to_ptr == e.to_ptr } + 1]
  end
  return get_next_obj_by_depth(depth, prev)
end

#get_obj_by_depth(depth, idx) ⇒ Object



412
413
414
415
416
417
# File 'lib/hwloc/Topology.rb', line 412

def get_obj_by_depth(depth, idx)
  p = Hwloc.hwloc_get_obj_by_depth(@ptr, depth, idx)
  return nil if p.to_ptr.null?
  p.instance_variable_set(:@topology, self)
  return p
end

#get_obj_by_type(type, idx) ⇒ Object



425
426
427
428
429
430
# File 'lib/hwloc/Topology.rb', line 425

def get_obj_by_type(type, idx)
  depth = get_type_depth(type)
  return nil if depth == Hwloc::TYPE_DEPTH_UNKNOWN
  return each_obj.select{ |e| e.type == type }[idx] if depth == Hwloc::TYPE_DEPTH_MULTIPLE
  return get_obj_by_depth(depth, idx)
end

#get_proc_cpubind(pid, *flags) ⇒ Object

Raises:



82
83
84
85
86
87
# File 'lib/hwloc/Bind.rb', line 82

def get_proc_cpubind(pid, *flags)
  cpuset = Cpuset::new
  err = Hwloc.hwloc_get_proc_cpubind(@ptr, pid, cpuset, flags)
  raise CpubindError if err == -1
  return cpuset
end

#get_proc_last_cpu_location(pid, *flags) ⇒ Object

Raises:



109
110
111
112
113
114
# File 'lib/hwloc/Bind.rb', line 109

def get_proc_last_cpu_location(pid, *flags)
  cpuset = Cpuset::new
  err = Hwloc.hwloc_get_proc_last_cpu_location(@ptr, pid, cpuset, flags)
  raise CpubindError if err == -1
  return cpuset
end

#get_proc_membind(pid, *flags) ⇒ Object

Raises:



289
290
291
292
293
294
295
296
# File 'lib/hwloc/Bind.rb', line 289

def get_proc_membind(pid, *flags)
  set = Bitmap::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_proc_membind(@ptr, pid, set, policy_p, flags)
  raise MembindError if err == -1
  policy = MembindPolicy[policy_p.read_int]
  return [set, policy]
end

#get_proc_membind_nodeset(pid, *flags) ⇒ Object

Raises:



172
173
174
175
176
177
178
179
# File 'lib/hwloc/Bind.rb', line 172

def get_proc_membind_nodeset(pid, *flags)
  nodeset = Nodeset::new
  policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
  err = Hwloc.hwloc_get_proc_membind_nodeset(@ptr, pid, nodeset, policy_p, flags)
  raise MembindError if err == -1
  policy = MembindPolicy[policy_p.read_int]
  return [nodeset, policy]
end

#get_root_objObject Also known as: root_obj



419
420
421
# File 'lib/hwloc/Topology.rb', line 419

def get_root_obj
  return get_obj_by_depth(0, 0)
end

#get_supportObject Also known as: support



355
356
357
358
359
# File 'lib/hwloc/Topology.rb', line 355

def get_support
  p = Hwloc.hwloc_topology_get_support(@ptr)
  p.instance_variable_set(:@topology, self)
  return p
end

#get_thread_cpubind(thread, *flags) ⇒ Object

Raises:



95
96
97
98
99
100
# File 'lib/hwloc/Bind.rb', line 95

def get_thread_cpubind(thread, *flags)
  cpuset = Cpuset::new
  err = Hwloc.hwloc_get_thread_cpubind(@ptr, thread, cpuset, flags)
  raise CpubindError if err == -1
  return cpuset
end

#get_type_depth(type) ⇒ Object



369
370
371
# File 'lib/hwloc/Topology.rb', line 369

def get_type_depth(type)
  Hwloc.hwloc_get_type_depth(@ptr, type)
end

#get_type_filter(type) ⇒ Object

Raises:



249
250
251
252
253
254
255
# File 'lib/hwloc/Topology.rb', line 249

def get_type_filter(type)
  filter_p = FFI::MemoryPointer::new(TypeFilter.native_type)
  err = Hwloc.hwloc_topology_get_type_filter(@ptr, type, filter_p)
  raise TopologyError if err == -1
  filter = filter_p.read_int
  return TypeFilter[filter]
end

#get_type_or_above_depth(type) ⇒ Object

Raises:



390
391
392
393
394
395
396
397
398
399
# File 'lib/hwloc/Topology.rb', line 390

def get_type_or_above_depth(type)
  depth = get_type_depth(type)
  return depth if depth != Hwloc::TYPE_DEPTH_UNKNOWN
  depth = 0
  while depth <= get_type_depth(Hwloc::OBJ_PU) do
    return depth - 1 if Hwloc.compare_types(get_depth_type(depth), type) > 0
    depth += 1
  end
  raise TopologyError
end

#get_type_or_below_depth(type) ⇒ Object

Raises:



379
380
381
382
383
384
385
386
387
388
# File 'lib/hwloc/Topology.rb', line 379

def get_type_or_below_depth(type)
  depth = get_type_depth(type)
  return depth if depth != Hwloc::TYPE_DEPTH_UNKNOWN
  depth = get_type_depth(Hwloc::OBJ_PU)
  while depth >= 0 do
    return depth + 1 if Hwloc.compare_types(get_depth_type(depth), type) < 0
    depth -= 1
  end
  raise TopologyError
end

#ignore_type(type) ⇒ Object

Raises:



217
218
219
220
221
# File 'lib/hwloc/Topology.rb', line 217

def ignore_type(type)
  err = Hwloc.hwloc_topology_ignore_type(@ptr, type)
  raise TopologyError if err == -1
  return self
end

#ignore_type_keep_structure(type) ⇒ Object



223
224
225
226
227
228
229
230
231
232
# File 'lib/hwloc/Topology.rb', line 223

def ignore_type_keep_structure(type)
  if type == :all then
    err = Hwloc.hwloc_topology_ignore_all_keep_structure(@ptr)
    raise TopologyError if err == -1
  else
    err = Hwloc.hwloc_topology_ignore_type_keep_structure(@ptr, type)
    raise TopologyError if err == -1
  end
  return self
end

#insert_misc_object_by_cpuset(cpuset, name) ⇒ Object

Raises:



37
38
39
40
41
42
# File 'lib/hwloc/Edition.rb', line 37

def insert_misc_object_by_cpuset(cpuset, name)
  obj = Hwloc.hwloc_topology_insert_misc_object_by_cpuset(@ptr, cpuset, name)
  raise EditionError if obj.to_ptr.null?
  obj.instance_variable_set(:@topology, self)
  return obj
end

#insert_misc_object_by_parent(parent, name) ⇒ Object Also known as: insert_misc_object

Raises:



44
45
46
47
48
49
# File 'lib/hwloc/Edition.rb', line 44

def insert_misc_object_by_parent(parent, name)
  obj = Hwloc.hwloc_topology_insert_misc_object_by_parent(@ptr, parent, name)
  raise EditionError if obj.to_ptr.null?
  obj.instance_variable_set(:@topology, self)
  return obj
end

#inspectObject



168
169
170
# File 'lib/hwloc/Topology.rb', line 168

def inspect
  return "#<#{self.class}:#{"0x00%x" % (object_id << 1)}>"
end

#is_thissystemObject Also known as: thissystem?

Will need some work to define properly…

def set_distance_matrix(type, nbobjs, os_index, distances)
  err = Hwloc.hwloc_topology_set_distance_matrix(@ptr, type, nbobjs, os_index, distances)
  raise TopologyError if err == -1
  return self
end


349
350
351
# File 'lib/hwloc/Topology.rb', line 349

def is_thissystem
  return Hwloc.hwloc_topology_is_thissystem(@ptr) == 1
end

#loadObject

Raises:



200
201
202
203
204
205
# File 'lib/hwloc/Topology.rb', line 200

def load
  err = Hwloc.hwloc_topology_load(@ptr)
  raise TopologyError if err == -1
  @xml_buffer = nil if @xml_buffer
  return self
end

#restrict(cpuset, flags) ⇒ Object

Raises:



75
76
77
78
79
# File 'lib/hwloc/Edition.rb', line 75

def restrict(cpuset, flags)
  err = Hwloc.hwloc_topology_restrict(@ptr, cpuset, flags)
  raise EditionError if err == -1
  return self
end

#set_all_types_filter(filter) ⇒ Object



245
246
247
# File 'lib/hwloc/Topology.rb', line 245

def set_all_types_filter(filter)
  return set_type_filter(:all, filter)
end

#set_area_membind(pointer, set, policy, *flags) ⇒ Object

Raises:



298
299
300
301
302
# File 'lib/hwloc/Bind.rb', line 298

def set_area_membind(pointer, set, policy, *flags)
  err = Hwloc.hwloc_set_area_membind(@ptr, pointer, pointer.size, set, policy, flags)
  raise MembindError if err == -1
  return self
end

#set_area_membind_nodeset(pointer, nodeset, policy, *flags) ⇒ Object

Raises:



181
182
183
184
185
# File 'lib/hwloc/Bind.rb', line 181

def set_area_membind_nodeset(pointer, nodeset, policy, *flags)
  err = Hwloc.hwloc_set_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy, flags)
  raise MembindError if err == -1
  return self
end

#set_cache_types_filter(filter) ⇒ Object



257
258
259
260
261
262
# File 'lib/hwloc/Topology.rb', line 257

def set_cache_types_filter(filter)
  (Hwloc::OBJ_L1CACHE..Hwloc::OBJ_L3ICACHE).each { |cl|
    set_type_filter(cl, filter)
  }
  return self
end

#set_cpubind(cpuset, *flags) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/hwloc/Bind.rb', line 56

def set_cpubind(cpuset, *flags)
  if block_given? then
    oldcpuset = get_cpubind(flags)
    set_cpubind(cpuset, flags)
    yield
    set_cpubind(oldcpuset, flags)
  else
    err = Hwloc.hwloc_set_cpubind(@ptr, cpuset, flags)
    raise CpubindError if err == -1
    return self
  end
end

#set_customObject

Raises:



335
336
337
338
339
# File 'lib/hwloc/Topology.rb', line 335

def set_custom
  err = Hwloc.hwloc_topology_set_custom(@ptr)
  raise TopologyError if err == -1
  return self
end

#set_flags(flags) ⇒ Object Also known as: flags=

Raises:



288
289
290
291
292
# File 'lib/hwloc/Topology.rb', line 288

def set_flags(flags)
  err = Hwloc.hwloc_topology_set_flags(@ptr, flags)
  raise TopologyError if err == -1
  return self
end

#set_fsroot(fsroot_path) ⇒ Object

Raises:



309
310
311
312
313
# File 'lib/hwloc/Topology.rb', line 309

def set_fsroot(fsroot_path)
  err = Hwloc.hwloc_topology_set_fsroot(@ptr, fsroot_path)
  raise TopologyError if err == -1
  return self
end

#set_icache_types_filter(filter) ⇒ Object



264
265
266
267
268
269
# File 'lib/hwloc/Topology.rb', line 264

def set_icache_types_filter(filter)
  (Hwloc::OBJ_L1ICACHE..Hwloc::OBJ_L3ICACHE).each { |cl|
    set_type_filter(cl, filter)
  }
  return self
end

#set_io_types_filter(filter) ⇒ Object



271
272
273
274
275
276
277
# File 'lib/hwloc/Topology.rb', line 271

def set_io_types_filter(filter)
  set_type_filter(Hwloc::OBJ_MISC, filter)
  set_type_filter(Hwloc::OBJ_BRIDGE, filter)
  set_type_filter(Hwloc::OBJ_PCI_DEVICE, filter)
  set_type_filter(Hwloc::OBJ_OS_DEVICE, filter)
  return self
end

#set_membind(set, policy, *flags) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/hwloc/Bind.rb', line 261

def set_membind(set, policy, *flags)
  if block_given? then
    oldset, oldpolicy = get_membind(flags)
    set_membind(set, policy, flags)
    yield
    set_membind(oldset, oldpolicy, flags)
  else
    err = Hwloc.hwloc_set_membind(@ptr, set, policy, flags)
    raise MembindError if err == -1
    return self
  end
end

#set_membind_nodeset(nodeset, policy, *flags) ⇒ Object

Raises:



151
152
153
154
155
# File 'lib/hwloc/Bind.rb', line 151

def set_membind_nodeset(nodeset, policy, *flags)
  err = Hwloc.hwloc_set_membind_nodeset(@ptr, nodeset, policy, flags)
  raise MembindError if err == -1
  return self
end

#set_pid(pid) ⇒ Object

Raises:



302
303
304
305
306
# File 'lib/hwloc/Topology.rb', line 302

def set_pid(pid)
  err = Hwloc.hwloc_topology_set_pid(@ptr, pid)
  raise TopologyError if err == -1
  return self
end

#set_proc_cpubind(pid, cpuset, *flags) ⇒ Object

Raises:



76
77
78
79
80
# File 'lib/hwloc/Bind.rb', line 76

def set_proc_cpubind(pid, cpuset, *flags)
  err = Hwloc.hwloc_set_proc_cpubind(@ptr, pid, cpuset, flags)
  raise CpubindError if err == -1
  return self
end

#set_proc_membind(pid, set, policy, *flags) ⇒ Object

Raises:



283
284
285
286
287
# File 'lib/hwloc/Bind.rb', line 283

def set_proc_membind(pid, set, policy, *flags)
  err = Hwloc.hwloc_set_proc_membind(@ptr, pid, set, policy, flags)
  raise MembindError if err == -1
  return self
end

#set_proc_membind_nodeset(pid, nodeset, policy, *flags) ⇒ Object

Raises:



166
167
168
169
170
# File 'lib/hwloc/Bind.rb', line 166

def set_proc_membind_nodeset(pid, nodeset, policy, *flags)
  err = Hwloc.hwloc_set_proc_membind_nodeset(@ptr, pid, nodeset, policy, flags)
  raise MembindError if err == -1
  return self
end

#set_synthetic(description) ⇒ Object

Raises:



316
317
318
319
320
# File 'lib/hwloc/Topology.rb', line 316

def set_synthetic(description)
  err = Hwloc.hwloc_topology_set_synthetic(@ptr, description)
  raise TopologyError if err == -1
  return self
end

#set_thread_cpubind(thread, cpuset, *flags) ⇒ Object

Raises:



89
90
91
92
93
# File 'lib/hwloc/Bind.rb', line 89

def set_thread_cpubind(thread, cpuset, *flags)
  err = Hwloc.hwloc_set_thread_cpubind(@ptr, thread, cpuset, flags)
  raise CpubindError if err == -1
  return self
end

#set_type_filter(type, filter) ⇒ Object



234
235
236
237
238
239
240
241
242
243
# File 'lib/hwloc/Topology.rb', line 234

def set_type_filter(type, filter)
  if type == :all then
    err = Hwloc.hwloc_topology_set_all_types_filter(@ptr, filter)
    raise TopologyError if err == -1
  else
    err = Hwloc.hwloc_topology_set_type_filter(@ptr, type, filter)
    raise TopologyError if err == -1
  end
  return self
end

#set_xml(xmlpath) ⇒ Object

Raises:



322
323
324
325
326
# File 'lib/hwloc/Topology.rb', line 322

def set_xml(xmlpath)
  err = Hwloc.hwloc_topology_set_xml(@ptr, xmlpath)
  raise TopologyError if err == -1
  return self
end

#set_xmlbuffer(pointer) ⇒ Object

Raises:



328
329
330
331
332
# File 'lib/hwloc/Topology.rb', line 328

def set_xmlbuffer(pointer)
  err = Hwloc.hwloc_topology_set_xmlbuffer(@ptr, pointer, pointer.size)
  raise TopologyError if err == -1
  return self
end

#to_sObject



93
94
95
96
97
98
99
# File 'lib/hwloc/Export.rb', line 93

def to_s
  begin
    return export_synthetic
  rescue ExportError
    return super
  end
end

#to_xml(flags = 0) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/hwloc/Export.rb', line 71

def to_xml(flags = 0)
  a = if API_VERSION >= API_VERSION_2_0
    export_xmlbuffer(flags)
  else
    export_xmlbuffer
  end
  a.read_string
end