hwloc 0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/hwloc.gemspec +1 -1
- data/lib/hwloc/Bind.rb +113 -83
- data/lib/hwloc/Edition.rb +60 -33
- data/lib/hwloc/Export.rb +40 -14
- data/lib/hwloc/Hwloc.rb +5 -1
- data/lib/hwloc/Obj.rb +273 -80
- data/lib/hwloc/Topology.rb +147 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '081b8121d7a652135e9b3737780c298fa7344cb6'
|
4
|
+
data.tar.gz: 17d522c1332cda3854e27599c77427c04f2d84e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 425b74b3084abe8c680cdcd8b2179e892a87c3c2b27fa8350107be21e489c68664d87c21838399aeef66297d0e2dce1ce491a156893e3258c8ad92c5a6269ee6
|
7
|
+
data.tar.gz: 48d341cb5425bc74dc089183e476d37335e90255e699d5bbf734a18e261e2b78188dcb545756693d34e7fe7a3e67fd18cf4ec5ef57e4284824f578dbb3f0055b
|
data/README.md
CHANGED
@@ -27,7 +27,11 @@ def print_pointer_location(ptr, t)
|
|
27
27
|
end
|
28
28
|
|
29
29
|
t = Hwloc::Topology::new
|
30
|
-
|
30
|
+
if Hwloc::API_VERSION < Hwloc::API_VERSION_2_0
|
31
|
+
t.flags = Hwloc::Topology::FLAG_ICACHES
|
32
|
+
else
|
33
|
+
t.set_icache_types_filter(:TYPE_FILTER_KEEP_ALL)
|
34
|
+
end
|
31
35
|
t.load
|
32
36
|
|
33
37
|
$page_size = t.machines.first.memory.page_types.first.size
|
@@ -50,7 +54,7 @@ t.depth.times { |d|
|
|
50
54
|
|
51
55
|
# find the number of level of caches on the machine and their size:
|
52
56
|
first_core = t.cores.first
|
53
|
-
caches = first_core.ancestors.take_while{ |o| o.
|
57
|
+
caches = first_core.ancestors.take_while{ |o| o.is_a_cache? }
|
54
58
|
caches.each_with_index { |c,i|
|
55
59
|
puts "#{c.type_name}: #{c.attr.size/1024}KiB"
|
56
60
|
}
|
data/hwloc.gemspec
CHANGED
data/lib/hwloc/Bind.rb
CHANGED
@@ -6,15 +6,26 @@ module Hwloc
|
|
6
6
|
:CPUBIND_NOMEMBIND, 1<<3
|
7
7
|
] )
|
8
8
|
|
9
|
-
|
10
|
-
:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
if API_VERSION < API_VERSION_2_0 then
|
10
|
+
MembindPolicy = enum( :membind_policy, [
|
11
|
+
:MEMBIND_DEFAULT, 0,
|
12
|
+
:MEMBIND_FIRSTTOUCH, 1,
|
13
|
+
:MEMBIND_BIND, 2,
|
14
|
+
:MEMBIND_INTERLEAVE, 3,
|
15
|
+
:MEMBIND_REPLICATE, 4,
|
16
|
+
:MEMBIND_NEXTTOUCH, 5,
|
17
|
+
:MEMBIND_MIXED, -1
|
18
|
+
] )
|
19
|
+
else
|
20
|
+
MembindPolicy = enum( :membind_policy, [
|
21
|
+
:MEMBIND_DEFAULT, 0,
|
22
|
+
:MEMBIND_FIRSTTOUCH, 1,
|
23
|
+
:MEMBIND_BIND, 2,
|
24
|
+
:MEMBIND_INTERLEAVE, 3,
|
25
|
+
:MEMBIND_NEXTTOUCH, 4,
|
26
|
+
:MEMBIND_MIXED, -1
|
27
|
+
] )
|
28
|
+
end
|
18
29
|
|
19
30
|
MembindFlags = enum( :membind_flags, [
|
20
31
|
:MEMBIND_PROCESS, 1<<0,
|
@@ -43,9 +54,16 @@ module Hwloc
|
|
43
54
|
class Topology
|
44
55
|
|
45
56
|
def set_cpubind(cpuset, flags = 0)
|
46
|
-
|
47
|
-
|
48
|
-
|
57
|
+
if block_given? then
|
58
|
+
oldcpuset = get_cpubind(flags)
|
59
|
+
set_cpubind(cpuset, flags)
|
60
|
+
yield
|
61
|
+
set_cpubind(oldcpuset, flags)
|
62
|
+
else
|
63
|
+
err = Hwloc.hwloc_set_cpubind(@ptr, cpuset, flags)
|
64
|
+
raise CpubindError if err == -1
|
65
|
+
return self
|
66
|
+
end
|
49
67
|
end
|
50
68
|
|
51
69
|
def get_cpubind(flags = 0)
|
@@ -100,18 +118,21 @@ module Hwloc
|
|
100
118
|
class MembindError < BindError
|
101
119
|
end
|
102
120
|
|
103
|
-
|
121
|
+
if API_VERSION < API_VERSION_2_0 then
|
122
|
+
attach_function :hwloc_set_membind_nodeset, [:topology, :nodeset, :membind_policy, :int], :int
|
123
|
+
attach_function :hwloc_get_membind_nodeset, [:topology, :nodeset, :pointer, :int], :int
|
124
|
+
attach_function :hwloc_set_proc_membind_nodeset, [:topology, :hwloc_pid_t, :nodeset, :membind_policy, :int], :int
|
125
|
+
attach_function :hwloc_get_proc_membind_nodeset, [:topology, :hwloc_pid_t, :nodeset, :pointer, :int], :int
|
126
|
+
attach_function :hwloc_set_area_membind_nodeset, [:topology, :pointer, :size_t, :nodeset, :membind_policy, :int], :int
|
127
|
+
attach_function :hwloc_get_area_membind_nodeset, [:topology, :pointer, :size_t, :nodeset, :pointer, :int], :int
|
128
|
+
attach_function :hwloc_alloc_membind_nodeset, [:topology, :size_t, :nodeset, :membind_policy, :int], :pointer
|
129
|
+
end
|
104
130
|
attach_function :hwloc_set_membind, [:topology, :bitmap, :membind_policy, :int], :int
|
105
|
-
attach_function :hwloc_get_membind_nodeset, [:topology, :nodeset, :pointer, :int], :int
|
106
131
|
attach_function :hwloc_get_membind, [:topology, :bitmap, :pointer, :int], :int
|
107
|
-
attach_function :hwloc_set_proc_membind_nodeset, [:topology, :hwloc_pid_t, :nodeset, :membind_policy, :int], :int
|
108
132
|
attach_function :hwloc_set_proc_membind, [:topology, :hwloc_pid_t, :bitmap, :membind_policy, :int], :int
|
109
|
-
attach_function :hwloc_get_proc_membind_nodeset, [:topology, :hwloc_pid_t, :nodeset, :pointer, :int], :int
|
110
133
|
attach_function :hwloc_get_proc_membind, [:topology, :hwloc_pid_t, :bitmap, :pointer, :int], :int
|
111
134
|
|
112
|
-
attach_function :hwloc_set_area_membind_nodeset, [:topology, :pointer, :size_t, :nodeset, :membind_policy, :int], :int
|
113
135
|
attach_function :hwloc_set_area_membind, [:topology, :pointer, :size_t, :bitmap, :membind_policy, :int], :int
|
114
|
-
attach_function :hwloc_get_area_membind_nodeset, [:topology, :pointer, :size_t, :nodeset, :pointer, :int], :int
|
115
136
|
attach_function :hwloc_get_area_membind, [:topology, :pointer, :size_t, :bitmap, :pointer, :int], :int
|
116
137
|
|
117
138
|
begin
|
@@ -121,31 +142,88 @@ module Hwloc
|
|
121
142
|
end
|
122
143
|
|
123
144
|
attach_function :hwloc_alloc, [:topology, :size_t], :pointer
|
124
|
-
attach_function :hwloc_alloc_membind_nodeset, [:topology, :size_t, :nodeset, :membind_policy, :int], :pointer
|
125
145
|
attach_function :hwloc_alloc_membind, [:topology, :size_t, :bitmap, :membind_policy, :int], :pointer
|
126
146
|
attach_function :hwloc_free, [:topology, :pointer, :size_t], :int
|
127
147
|
|
128
148
|
class Topology
|
129
149
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
150
|
+
if API_VERSION < API_VERSION_2_0 then
|
151
|
+
def set_membind_nodeset(nodeset, policy, flags=0)
|
152
|
+
err = Hwloc.hwloc_set_membind_nodeset(@ptr, nodeset, policy, flags)
|
153
|
+
raise MembindError if err == -1
|
154
|
+
return self
|
155
|
+
end
|
156
|
+
|
157
|
+
def get_membind_nodeset(flags=0)
|
158
|
+
nodeset = Nodeset::new
|
159
|
+
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
160
|
+
err = Hwloc.hwloc_get_membind_nodeset(@ptr, nodeset, policy_p, flags)
|
161
|
+
raise MembindError if err == -1
|
162
|
+
policy = policy_p.read_int
|
163
|
+
return [nodeset, MembindPolicy[policy]]
|
164
|
+
end
|
165
|
+
|
166
|
+
def set_proc_membind_nodeset(pid, nodeset, policy, flags=0)
|
167
|
+
err = Hwloc.hwloc_set_proc_membind_nodeset(@ptr, pid, nodeset, policy, flags)
|
168
|
+
raise MembindError if err == -1
|
169
|
+
return self
|
170
|
+
end
|
171
|
+
|
172
|
+
def get_proc_membind_nodeset(pid, flags=0)
|
173
|
+
nodeset = Nodeset::new
|
174
|
+
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
175
|
+
err = Hwloc.hwloc_get_proc_membind_nodeset(@ptr, pid, nodeset, policy_p, flags)
|
176
|
+
raise MembindError if err == -1
|
177
|
+
policy = MembindPolicy[policy_p.read_int]
|
178
|
+
return [nodeset, policy]
|
179
|
+
end
|
180
|
+
|
181
|
+
def set_area_membind_nodeset(pointer, nodeset, policy, flags=0)
|
182
|
+
err = Hwloc.hwloc_set_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy, flags)
|
183
|
+
raise MembindError if err == -1
|
184
|
+
return self
|
185
|
+
end
|
186
|
+
|
187
|
+
def get_area_membind_nodeset(pointer, flags=0)
|
188
|
+
nodeset = Nodeset::new
|
189
|
+
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
190
|
+
err = Hwloc.hwloc_get_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy_p, flags)
|
191
|
+
raise MembindError if err == -1
|
192
|
+
policy = MembindPolicy[policy_p.read_int]
|
193
|
+
return [nodeset, policy]
|
194
|
+
end
|
195
|
+
|
196
|
+
def alloc_membind_nodeset(size, nodeset, policy, flags=0)
|
197
|
+
ptr = Hwloc.hwloc_alloc_membind_nodeset(@ptr, size, nodeset, policy, flags)
|
198
|
+
raise MembindError if ptr.null?
|
199
|
+
ptr = ptr.slice(0, size)
|
200
|
+
return FFI::AutoPointer::new(ptr, self.method(:free))
|
201
|
+
end
|
202
|
+
|
203
|
+
def alloc_membind_policy_nodeset(size, nodeset, policy, flags=0)
|
204
|
+
begin
|
205
|
+
return alloc_membind_nodeset(size, nodeset, policy, flags)
|
206
|
+
rescue MembindError
|
207
|
+
set_membind_nodeset(nodeset, policy, flags)
|
208
|
+
ptr = alloc(size)
|
209
|
+
ptr.clear if policy != Hwloc::MEMBIND_FIRSTTOUCH
|
210
|
+
return ptr
|
211
|
+
end
|
212
|
+
end
|
135
213
|
|
136
|
-
def set_membind(set, policy, flags=0)
|
137
|
-
err = Hwloc.hwloc_set_membind(@ptr, set, policy, flags)
|
138
|
-
raise MembindError if err == -1
|
139
|
-
return self
|
140
214
|
end
|
141
215
|
|
142
|
-
def
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
216
|
+
def set_membind(set, policy, flags=0)
|
217
|
+
if block_given? then
|
218
|
+
oldset, oldpolicy = get_membind(flags)
|
219
|
+
set_membind(set, policy, flags)
|
220
|
+
yield
|
221
|
+
set_membind(oldset, oldpolicy, flags)
|
222
|
+
else
|
223
|
+
err = Hwloc.hwloc_set_membind(@ptr, set, policy, flags)
|
224
|
+
raise MembindError if err == -1
|
225
|
+
return self
|
226
|
+
end
|
149
227
|
end
|
150
228
|
|
151
229
|
def get_membind(flags=0)
|
@@ -157,27 +235,12 @@ module Hwloc
|
|
157
235
|
return [set, MembindPolicy[policy]]
|
158
236
|
end
|
159
237
|
|
160
|
-
def set_proc_membind_nodeset(pid, nodeset, policy, flags=0)
|
161
|
-
err = Hwloc.hwloc_set_proc_membind_nodeset(@ptr, pid, nodeset, policy, flags)
|
162
|
-
raise MembindError if err == -1
|
163
|
-
return self
|
164
|
-
end
|
165
|
-
|
166
238
|
def set_proc_membind(pid, set, policy, flags=0)
|
167
239
|
err = Hwloc.hwloc_set_proc_membind(@ptr, pid, set, policy, flags)
|
168
240
|
raise MembindError if err == -1
|
169
241
|
return self
|
170
242
|
end
|
171
243
|
|
172
|
-
def get_proc_membind_nodeset(pid, flags=0)
|
173
|
-
nodeset = Nodeset::new
|
174
|
-
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
175
|
-
err = Hwloc.hwloc_get_proc_membind_nodeset(@ptr, pid, nodeset, policy_p, flags)
|
176
|
-
raise MembindError if err == -1
|
177
|
-
policy = MembindPolicy[policy_p.read_int]
|
178
|
-
return [nodeset, policy]
|
179
|
-
end
|
180
|
-
|
181
244
|
def get_proc_membind(pid, flags=0)
|
182
245
|
set = Bitmap::new
|
183
246
|
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
@@ -187,27 +250,12 @@ module Hwloc
|
|
187
250
|
return [set, policy]
|
188
251
|
end
|
189
252
|
|
190
|
-
def set_area_membind_nodeset(pointer, nodeset, policy, flags=0)
|
191
|
-
err = Hwloc.hwloc_set_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy, flags)
|
192
|
-
raise MembindError if err == -1
|
193
|
-
return self
|
194
|
-
end
|
195
|
-
|
196
253
|
def set_area_membind(pointer, set, policy, flags=0)
|
197
254
|
err = Hwloc.hwloc_set_area_membind(@ptr, pointer, pointer.size, set, policy, flags)
|
198
255
|
raise MembindError if err == -1
|
199
256
|
return self
|
200
257
|
end
|
201
258
|
|
202
|
-
def get_area_membind_nodeset(pointer, flags=0)
|
203
|
-
nodeset = Nodeset::new
|
204
|
-
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
205
|
-
err = Hwloc.hwloc_get_area_membind_nodeset(@ptr, pointer, pointer.size, nodeset, policy_p, flags)
|
206
|
-
raise MembindError if err == -1
|
207
|
-
policy = MembindPolicy[policy_p.read_int]
|
208
|
-
return [nodeset, policy]
|
209
|
-
end
|
210
|
-
|
211
259
|
def get_area_membind(pointer, flags=0)
|
212
260
|
set = Bitmap::new
|
213
261
|
policy_p = FFI::MemoryPointer::new(MembindPolicy.native_type)
|
@@ -233,13 +281,6 @@ module Hwloc
|
|
233
281
|
return FFI::AutoPointer::new(ptr, self.method(:free))
|
234
282
|
end
|
235
283
|
|
236
|
-
def alloc_membind_nodeset(size, nodeset, policy, flags=0)
|
237
|
-
ptr = Hwloc.hwloc_alloc_membind_nodeset(@ptr, size, nodeset, policy, flags)
|
238
|
-
raise MembindError if ptr.null?
|
239
|
-
ptr = ptr.slice(0, size)
|
240
|
-
return FFI::AutoPointer::new(ptr, self.method(:free))
|
241
|
-
end
|
242
|
-
|
243
284
|
def alloc_membind(size, set, policy, flags=0)
|
244
285
|
ptr = Hwloc.hwloc_alloc_membind(@ptr, size, set, policy, flags)
|
245
286
|
raise MembindError if ptr.null?
|
@@ -247,17 +288,6 @@ module Hwloc
|
|
247
288
|
return FFI::AutoPointer::new(ptr, self.method(:free))
|
248
289
|
end
|
249
290
|
|
250
|
-
def alloc_membind_policy_nodeset(size, nodeset, policy, flags=0)
|
251
|
-
begin
|
252
|
-
return alloc_membind_nodeset(size, nodeset, policy, flags)
|
253
|
-
rescue MembindError
|
254
|
-
set_membind_nodeset(nodeset, policy, flags)
|
255
|
-
ptr = alloc(size)
|
256
|
-
ptr.clear if policy != Hwloc::MEMBIND_FIRSTTOUCH
|
257
|
-
return ptr
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
291
|
def alloc_membind_policy(size, set, policy, flags=0)
|
262
292
|
begin
|
263
293
|
return alloc_membind(size, set, policy, flags)
|
data/lib/hwloc/Edition.rb
CHANGED
@@ -1,35 +1,75 @@
|
|
1
1
|
module Hwloc
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
if API_VERSION < API_VERSION_2_0 then
|
4
|
+
attach_function :hwloc_topology_insert_misc_object_by_cpuset, [:topology, :cpuset, :string], Obj.ptr
|
5
|
+
attach_function :hwloc_topology_insert_misc_object_by_parent, [:topology, Obj.ptr, :string], Obj.ptr
|
6
|
+
attach_function :hwloc_custom_insert_topology, [:topology, Obj.ptr, :topology, Obj.ptr,], :int
|
7
|
+
attach_function :hwloc_custom_insert_group_object_by_parent, [:topology, Obj.ptr, :int], Obj.ptr
|
8
|
+
else
|
9
|
+
attach_function :hwloc_topology_insert_misc_object, [:topology, Obj.ptr, :string], Obj.ptr
|
10
|
+
attach_function :hwloc_topology_alloc_group_object, [:topology], Obj.ptr
|
11
|
+
attach_function :hwloc_topology_insert_group_object, [:topology, Obj.ptr], Obj.ptr
|
12
|
+
attach_function :hwloc_obj_add_other_obj_sets, [Obj.ptr, Obj.ptr], :int
|
13
|
+
end
|
5
14
|
|
6
|
-
|
7
|
-
:
|
8
|
-
|
9
|
-
|
10
|
-
|
15
|
+
if API_VERSION < API_VERSION_2_0 then
|
16
|
+
RestrictFlags = enum( FFI::find_type(:ulong), :restrict_flags, [
|
17
|
+
:RESTRICT_FLAG_ADAPT_DISTANCES, 1<<0,
|
18
|
+
:RESTRICT_FLAG_ADAPT_MISC, 1<<1,
|
19
|
+
:RESTRICT_FLAG_ADAPT_IO, 1<<2
|
20
|
+
] )
|
21
|
+
else
|
22
|
+
RestrictFlags = enum( FFI::find_type(:ulong), :restrict_flags, [
|
23
|
+
:RESTRICT_FLAG_REMOVE_CPULESS, 1<<0,
|
24
|
+
:RESTRICT_FLAG_ADAPT_MISC, 1<<1,
|
25
|
+
:RESTRICT_FLAG_ADAPT_IO, 1<<2
|
26
|
+
] )
|
27
|
+
end
|
11
28
|
|
12
29
|
attach_function :hwloc_topology_restrict, [:topology, :cpuset, :ulong], :int
|
13
|
-
attach_function :hwloc_custom_insert_topology, [:topology, Obj.ptr, :topology, Obj.ptr,], :int
|
14
|
-
attach_function :hwloc_custom_insert_group_object_by_parent, [:topology, Obj.ptr, :int], Obj.ptr
|
15
30
|
|
16
31
|
class EditionError < TopologyError
|
17
32
|
end
|
18
33
|
|
19
34
|
class Topology
|
20
35
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
36
|
+
if API_VERSION < API_VERSION_2_0 then
|
37
|
+
def insert_misc_object_by_cpuset(cpuset, name)
|
38
|
+
obj = Hwloc.hwloc_topology_insert_misc_object_by_cpuset(@ptr, cpuset, name)
|
39
|
+
raise EditionError if obj.to_ptr.null?
|
40
|
+
obj.instance_variable_set(:@topology, self)
|
41
|
+
return obj
|
42
|
+
end
|
43
|
+
|
44
|
+
def insert_misc_object_by_parent(parent, name)
|
45
|
+
obj = Hwloc.hwloc_topology_insert_misc_object_by_parent(@ptr, parent, name)
|
46
|
+
raise EditionError if obj.to_ptr.null?
|
47
|
+
obj.instance_variable_set(:@topology, self)
|
48
|
+
return obj
|
49
|
+
end
|
50
|
+
|
51
|
+
alias insert_misc_object insert_misc_object_by_parent
|
52
|
+
|
53
|
+
def custom_insert_topology(newparent, oldtopology, oldroot = nil)
|
54
|
+
err = Hwloc.hwloc_custom_insert_topology(@ptr, newparent, oldtopology.ptr, oldroot)
|
55
|
+
raise EditionError if err == -1
|
56
|
+
return self
|
57
|
+
end
|
58
|
+
|
59
|
+
def custom_insert_group_object_by_parent(parent, groupdepth)
|
60
|
+
obj = Hwloc.hwloc_custom_insert_group_object_by_parent(@ptr, parent, groupdepth)
|
61
|
+
raise EditionError if obj.to_ptr.null?
|
62
|
+
obj.instance_variable_set(:@topology, self)
|
63
|
+
return obj
|
64
|
+
end
|
27
65
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
66
|
+
else
|
67
|
+
def insert_misc_object(parent, name)
|
68
|
+
obj = Hwloc.hwloc_topology_insert_misc_object(@ptr, parent, name)
|
69
|
+
raise EditionError if obj.to_ptr.null?
|
70
|
+
obj.instance_variable_set(:@topology, self)
|
71
|
+
return obj
|
72
|
+
end
|
33
73
|
end
|
34
74
|
|
35
75
|
def restrict(cpuset, flags)
|
@@ -38,19 +78,6 @@ module Hwloc
|
|
38
78
|
return self
|
39
79
|
end
|
40
80
|
|
41
|
-
def custom_insert_topology(newparent, oldtopology, oldroot = nil)
|
42
|
-
err = Hwloc.hwloc_custom_insert_topology(@ptr, newparent, oldtopology.ptr, oldroot)
|
43
|
-
raise EditionError if err == -1
|
44
|
-
return self
|
45
|
-
end
|
46
|
-
|
47
|
-
def custom_insert_group_object_by_parent(parent, groupdepth)
|
48
|
-
obj = Hwloc.hwloc_custom_insert_group_object_by_parent(@ptr, parent, groupdepth)
|
49
|
-
raise EditionError if obj.to_ptr.null?
|
50
|
-
obj.instance_variable_set(:@topology, self)
|
51
|
-
return obj
|
52
|
-
end
|
53
|
-
|
54
81
|
end
|
55
82
|
|
56
83
|
class Obj
|
data/lib/hwloc/Export.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
module Hwloc
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
if API_VERSION < API_VERSION_2_0 then
|
4
|
+
attach_function :hwloc_topology_export_xml, [:topology, :string], :int
|
5
|
+
attach_function :hwloc_topology_export_xmlbuffer, [:topology, :pointer, :pointer], :int
|
6
|
+
else
|
7
|
+
TopologyExportXmlFlags = enum( FFI::find_type(:ulong), :topology_export_xml_flags, [
|
8
|
+
:TOPOLOGY_EXPORT_XML_FLAG_V1, 1<<0
|
9
|
+
] )
|
10
|
+
attach_function :hwloc_topology_export_xml, [:topology, :string, :ulong], :int
|
11
|
+
attach_function :hwloc_topology_export_xmlbuffer, [:topology, :pointer, :pointer, :ulong], :int
|
12
|
+
end
|
13
|
+
|
5
14
|
attach_function :hwloc_free_xmlbuffer, [:topology, :pointer], :void
|
6
15
|
|
7
16
|
callback :hwloc_topology_set_userdata_export_callback_callback, [:pointer, :topology, Obj.ptr], :void
|
@@ -25,19 +34,36 @@ module Hwloc
|
|
25
34
|
|
26
35
|
class Topology
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
if API_VERSION < API_VERSION_2_0 then
|
38
|
+
def export_xml(xmlpath)
|
39
|
+
err = Hwloc.hwloc_topology_export_xml(@ptr, xmlpath)
|
40
|
+
raise ExportError if err == -1
|
41
|
+
return self
|
42
|
+
end
|
33
43
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
def export_xmlbuffer
|
45
|
+
data_p = FFI::MemoryPointer::new(:pointer)
|
46
|
+
count_p = FFI::MemoryPointer::new(:int)
|
47
|
+
err = Hwloc.hwloc_topology_export_xmlbuffer(@ptr, data_p, count_p)
|
48
|
+
raise ExportError if err == -1
|
49
|
+
xmlbuffer_p = data_p.read_pointer.slice(0, count_p.read_int)
|
50
|
+
return FFI::AutoPointer::new(xmlbuffer_p, self.method(:free_xmlbuffer))
|
51
|
+
end
|
52
|
+
else
|
53
|
+
def export_xml(xmlpath, flags=0)
|
54
|
+
err = Hwloc.hwloc_topology_export_xml(@ptr, xmlpath, flags)
|
55
|
+
raise ExportError if err == -1
|
56
|
+
return self
|
57
|
+
end
|
58
|
+
|
59
|
+
def export_xmlbuffer(flags = 0)
|
60
|
+
data_p = FFI::MemoryPointer::new(:pointer)
|
61
|
+
count_p = FFI::MemoryPointer::new(:int)
|
62
|
+
err = Hwloc.hwloc_topology_export_xmlbuffer(@ptr, data_p, count_p, flags)
|
63
|
+
raise ExportError if err == -1
|
64
|
+
xmlbuffer_p = data_p.read_pointer.slice(0, count_p.read_int)
|
65
|
+
return FFI::AutoPointer::new(xmlbuffer_p, self.method(:free_xmlbuffer))
|
66
|
+
end
|
41
67
|
end
|
42
68
|
|
43
69
|
def free_xmlbuffer(pointer)
|
data/lib/hwloc/Hwloc.rb
CHANGED
@@ -6,7 +6,11 @@ module Hwloc
|
|
6
6
|
|
7
7
|
attach_function :hwloc_get_api_version, [], :uint
|
8
8
|
|
9
|
-
|
9
|
+
API_VERSION = Hwloc.hwloc_get_api_version
|
10
|
+
API_VERSION_1_10 = 0x00010a00
|
11
|
+
API_VERSION_2_0 = 0x00020000
|
12
|
+
|
13
|
+
raise RuntimeError, "Wrong hwloc api version (#{API_VERSION.to_s(16)})!" if API_VERSION < 0x00010a00
|
10
14
|
|
11
15
|
attach_function :strerror, [:int], :string
|
12
16
|
|
data/lib/hwloc/Obj.rb
CHANGED
@@ -3,21 +3,39 @@ module Hwloc
|
|
3
3
|
class ObjError < Error
|
4
4
|
end
|
5
5
|
|
6
|
-
|
6
|
+
obj_types = [
|
7
7
|
:OBJ_SYSTEM,
|
8
8
|
:OBJ_MACHINE,
|
9
9
|
:OBJ_NUMANODE,
|
10
|
-
:OBJ_PACKAGE
|
11
|
-
|
10
|
+
:OBJ_PACKAGE
|
11
|
+
]
|
12
|
+
obj_types.push :OBJ_CACHE if API_VERSION < API_VERSION_2_0
|
13
|
+
obj_types += [
|
12
14
|
:OBJ_CORE,
|
13
|
-
:OBJ_PU
|
15
|
+
:OBJ_PU
|
16
|
+
]
|
17
|
+
if API_VERSION >= API_VERSION_2_0 then
|
18
|
+
obj_types += [
|
19
|
+
:OBJ_L1CACHE,
|
20
|
+
:OBJ_L2CACHE,
|
21
|
+
:OBJ_L3CACHE,
|
22
|
+
:OBJ_L4CACHE,
|
23
|
+
:OBJ_L5CACHE,
|
24
|
+
:OBJ_L1ICACHE,
|
25
|
+
:OBJ_L2ICACHE,
|
26
|
+
:OBJ_L3ICACHE
|
27
|
+
]
|
28
|
+
end
|
29
|
+
obj_types += [
|
14
30
|
:OBJ_GROUP,
|
15
31
|
:OBJ_MISC,
|
16
32
|
:OBJ_BRIDGE,
|
17
33
|
:OBJ_PCI_DEVICE,
|
18
34
|
:OBJ_OS_DEVICE,
|
19
35
|
:OBJ_TYPE_MAX
|
20
|
-
]
|
36
|
+
]
|
37
|
+
|
38
|
+
ObjType = enum( :obj_type, obj_types )
|
21
39
|
|
22
40
|
attach_function :hwloc_compare_types, [:obj_type, :obj_type], :int
|
23
41
|
|
@@ -109,12 +127,57 @@ module Hwloc
|
|
109
127
|
|
110
128
|
end
|
111
129
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
130
|
+
if API_VERSION < API_VERSION_2_0 then
|
131
|
+
class Distances < Struct
|
132
|
+
layout :relative_depth, :uint,
|
133
|
+
:nbobjs, :uint,
|
134
|
+
:latency, :pointer,
|
135
|
+
:latency_max, :float,
|
136
|
+
:latency_base, :float
|
137
|
+
end
|
138
|
+
else
|
139
|
+
|
140
|
+
DistancesKind = enum(FFI::find_type(:ulong), :distances_kind, [
|
141
|
+
:DISTANCES_KIND_FROM_OS, 1<<0,
|
142
|
+
:DISTANCES_KIND_FROM_USER, 1<<1,
|
143
|
+
:DISTANCES_KIND_MEANS_LATENCY, 1<<2,
|
144
|
+
:DISTANCES_KIND_MEANS_BANDWIDTH, 1<<3
|
145
|
+
])
|
146
|
+
|
147
|
+
DistancesFlag = enum(FFI::find_type(:ulong), :distances_flag, [
|
148
|
+
:DISTANCES_FLAG_GROUP, 1<<0,
|
149
|
+
:DISTANCES_FLAG_GROUP_INACCURATE, 1<<1
|
150
|
+
])
|
151
|
+
|
152
|
+
class Distances < Struct
|
153
|
+
layout :nbobjs, :uint,
|
154
|
+
:objs, :pointer,
|
155
|
+
:kind, :ulong,
|
156
|
+
:values, :pointer
|
157
|
+
|
158
|
+
def objs
|
159
|
+
arity = self[:nbobjs]
|
160
|
+
if arity == 0 then
|
161
|
+
return []
|
162
|
+
else
|
163
|
+
return self[:objs].read_array_of_pointer(arity).collect { |p|
|
164
|
+
c = Obj::new(p)
|
165
|
+
c.instance_variable_set(:@topology, @topology)
|
166
|
+
c
|
167
|
+
}
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def values
|
172
|
+
arity = self[:nbobjs]
|
173
|
+
arity *= arity
|
174
|
+
if arity == 0 then
|
175
|
+
return []
|
176
|
+
else
|
177
|
+
return self[:values].read_array_of_uint64(arity)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
118
181
|
end
|
119
182
|
|
120
183
|
class ObjInfo < Struct
|
@@ -162,7 +225,14 @@ module Hwloc
|
|
162
225
|
end
|
163
226
|
|
164
227
|
class GroupAttr < Struct
|
165
|
-
|
228
|
+
group_layout = [ :depth, :uint ]
|
229
|
+
if API_VERSION >= API_VERSION_2_0 then
|
230
|
+
group_layout += [
|
231
|
+
:kind, :uint,
|
232
|
+
:subkind, :uint
|
233
|
+
]
|
234
|
+
end
|
235
|
+
layout( *group_layout )
|
166
236
|
end
|
167
237
|
|
168
238
|
class PcidevAttr < Struct
|
@@ -216,43 +286,86 @@ module Hwloc
|
|
216
286
|
class Obj < Struct
|
217
287
|
end
|
218
288
|
|
289
|
+
if API_VERSION < API_VERSION_2_0 then
|
290
|
+
attach_function :hwloc_obj_type_string, [:obj_type], :string
|
291
|
+
else
|
292
|
+
attach_function :hwloc_type_name, [:obj_type], :string
|
293
|
+
end
|
219
294
|
attach_function :hwloc_obj_type_snprintf, [:pointer, :size_t, Obj.ptr, :int], :int
|
220
295
|
attach_function :hwloc_obj_attr_snprintf, [:pointer, :size_t, Obj.ptr, :string, :int], :int
|
221
296
|
|
222
297
|
class Obj
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
:
|
255
|
-
|
298
|
+
if API_VERSION < API_VERSION_2_0 then
|
299
|
+
layout_array = [
|
300
|
+
:type, :obj_type,
|
301
|
+
:os_index, :uint,
|
302
|
+
:name, :string,
|
303
|
+
:memory, ObjMemory,
|
304
|
+
:attr, ObjAttr.ptr,
|
305
|
+
:depth, :uint,
|
306
|
+
:logical_index, :uint,
|
307
|
+
:os_level, :int,
|
308
|
+
:next_cousin, Obj.ptr,
|
309
|
+
:prev_cousin, Obj.ptr,
|
310
|
+
:parent, Obj.ptr,
|
311
|
+
:sibling_rank, :uint,
|
312
|
+
:next_sibling, Obj.ptr,
|
313
|
+
:prev_sibling, Obj.ptr,
|
314
|
+
:arity, :uint,
|
315
|
+
:children, :pointer,
|
316
|
+
:first_child, Obj.ptr,
|
317
|
+
:last_child, Obj.ptr,
|
318
|
+
:user_data, :pointer,
|
319
|
+
:cpuset, :cpuset,
|
320
|
+
:complete_cpuset, :cpuset,
|
321
|
+
:online_cpuset, :cpuset,
|
322
|
+
:allowed_cpuset, :cpuset,
|
323
|
+
:nodeset, :nodeset,
|
324
|
+
:complete_nodeset, :nodeset,
|
325
|
+
:allowed_nodeset, :nodeset,
|
326
|
+
:distances, :pointer,
|
327
|
+
:distances_count, :uint,
|
328
|
+
:infos, :pointer,
|
329
|
+
:infos_count, :uint,
|
330
|
+
:symmetric_subtree,:int
|
331
|
+
]
|
332
|
+
else
|
333
|
+
layout_array = [
|
334
|
+
:type, :obj_type,
|
335
|
+
:subtype, :string,
|
336
|
+
:os_index, :uint,
|
337
|
+
:name, :string,
|
338
|
+
:memory, ObjMemory,
|
339
|
+
:attr, ObjAttr.ptr,
|
340
|
+
:depth, :uint,
|
341
|
+
:logical_index, :uint,
|
342
|
+
:next_cousin, Obj.ptr,
|
343
|
+
:prev_cousin, Obj.ptr,
|
344
|
+
:parent, Obj.ptr,
|
345
|
+
:sibling_rank, :uint,
|
346
|
+
:next_sibling, Obj.ptr,
|
347
|
+
:prev_sibling, Obj.ptr,
|
348
|
+
:arity, :uint,
|
349
|
+
:children, :pointer,
|
350
|
+
:first_child, Obj.ptr,
|
351
|
+
:last_child, Obj.ptr,
|
352
|
+
:symmetric_subtree,:int,
|
353
|
+
:io_arity, :uint,
|
354
|
+
:io_first_child, Obj.ptr,
|
355
|
+
:misc_arity, :uint,
|
356
|
+
:misc_first_child, Obj.ptr,
|
357
|
+
:cpuset, :cpuset,
|
358
|
+
:complete_cpuset, :cpuset,
|
359
|
+
:allowed_cpuset, :cpuset,
|
360
|
+
:nodeset, :nodeset,
|
361
|
+
:complete_nodeset, :nodeset,
|
362
|
+
:allowed_nodeset, :nodeset,
|
363
|
+
:infos, :pointer,
|
364
|
+
:infos_count, :uint,
|
365
|
+
:user_data, :pointer,
|
366
|
+
:gp_index, :uint64
|
367
|
+
]
|
368
|
+
end
|
256
369
|
|
257
370
|
layout *layout_array
|
258
371
|
|
@@ -267,7 +380,16 @@ module Hwloc
|
|
267
380
|
return str_ptr.read_string
|
268
381
|
end
|
269
382
|
|
270
|
-
|
383
|
+
if API_VERSION < API_VERSION_2_0 then
|
384
|
+
def type_string
|
385
|
+
return Hwloc.hwloc_obj_type_string(type)
|
386
|
+
end
|
387
|
+
alias type_name type_string
|
388
|
+
else
|
389
|
+
def type_name
|
390
|
+
return Hwloc.hwloc_type_name(type)
|
391
|
+
end
|
392
|
+
end
|
271
393
|
|
272
394
|
def attr_snprintf(verbose=0, separator=",")
|
273
395
|
sz = Hwloc.hwloc_obj_attr_snprintf(nil, 0, self, separator, verbose) + 1
|
@@ -330,6 +452,83 @@ module Hwloc
|
|
330
452
|
return children.each(*args, &block)
|
331
453
|
end
|
332
454
|
|
455
|
+
if API_VERSION < API_VERSION_2_0 then
|
456
|
+
def each_obj(&block)
|
457
|
+
if block then
|
458
|
+
block.call self
|
459
|
+
children.each { |c|
|
460
|
+
c.each_obj(&block)
|
461
|
+
}
|
462
|
+
return self
|
463
|
+
else
|
464
|
+
to_enum(:each_obj)
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
def each_descendant(&block)
|
469
|
+
if block then
|
470
|
+
children.each { |c|
|
471
|
+
c.each_obj(&block)
|
472
|
+
}
|
473
|
+
else
|
474
|
+
to_enum(:each_descendant)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
else
|
479
|
+
|
480
|
+
def io_children
|
481
|
+
return [] if io_arity == 0
|
482
|
+
c = []
|
483
|
+
c.push( io_first_child )
|
484
|
+
(io_arity-1).times {
|
485
|
+
c.push( c[-1].next_sibling )
|
486
|
+
}
|
487
|
+
return c
|
488
|
+
end
|
489
|
+
|
490
|
+
def each_io_child(*args, &block)
|
491
|
+
return io_children.each(*args, &block)
|
492
|
+
end
|
493
|
+
|
494
|
+
def misc_children
|
495
|
+
return [] if misc_arity == 0
|
496
|
+
c = []
|
497
|
+
c.push( misc_first_child )
|
498
|
+
(misc_arity-1).times {
|
499
|
+
c.push( c[-1].next_sibling )
|
500
|
+
}
|
501
|
+
return c
|
502
|
+
end
|
503
|
+
|
504
|
+
def each_misc_child(*args, &block)
|
505
|
+
return misc_children.each(*args, &block)
|
506
|
+
end
|
507
|
+
|
508
|
+
def each_obj(&block)
|
509
|
+
if block then
|
510
|
+
block.call self
|
511
|
+
(children+io_children+misc_children).each { |c|
|
512
|
+
c.each_obj(&block)
|
513
|
+
}
|
514
|
+
return self
|
515
|
+
else
|
516
|
+
to_enum(:each_obj)
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
def each_descendant(&block)
|
521
|
+
if block then
|
522
|
+
(children+io_children+misc_children).each { |c|
|
523
|
+
c.each_obj(&block)
|
524
|
+
}
|
525
|
+
else
|
526
|
+
to_enum(:each_descendant)
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
end
|
531
|
+
|
333
532
|
def each_parent(&block)
|
334
533
|
if block then
|
335
534
|
if parent then
|
@@ -349,44 +548,24 @@ module Hwloc
|
|
349
548
|
alias ancestors parents
|
350
549
|
alias each_ancestor each_parent
|
351
550
|
|
352
|
-
def each_obj(&block)
|
353
|
-
if block then
|
354
|
-
block.call self
|
355
|
-
children.each { |c|
|
356
|
-
c.each_obj(&block)
|
357
|
-
}
|
358
|
-
return self
|
359
|
-
else
|
360
|
-
to_enum(:each_obj)
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
551
|
alias traverse each_obj
|
365
552
|
|
366
|
-
def each_descendant
|
367
|
-
if block then
|
368
|
-
children.each { |c|
|
369
|
-
c.each_obj(&block)
|
370
|
-
}
|
371
|
-
else
|
372
|
-
to_enum(:each_descendant)
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
553
|
def descendants
|
377
554
|
return each_descendant.to_a
|
378
555
|
end
|
379
556
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
557
|
+
if API_VERSION < API_VERSION_2_0 then
|
558
|
+
def distances
|
559
|
+
distances_count = self[:distances_count]
|
560
|
+
if distances_count == 0 then
|
561
|
+
return []
|
562
|
+
else
|
563
|
+
return self[:distances].read_array_of_pointer(distances_count).collect { |p|
|
564
|
+
d = Distances::new(p)
|
565
|
+
d.instance_variable_set(:@topology, @topology)
|
566
|
+
d
|
567
|
+
}
|
568
|
+
end
|
390
569
|
end
|
391
570
|
end
|
392
571
|
|
@@ -413,8 +592,6 @@ module Hwloc
|
|
413
592
|
return nil if at.to_ptr.null?
|
414
593
|
t = self[:type]
|
415
594
|
case t
|
416
|
-
when :OBJ_CACHE
|
417
|
-
return at[:cache]
|
418
595
|
when :OBJ_GROUP
|
419
596
|
return at[:group]
|
420
597
|
when :OBJ_PCI_DEVICE
|
@@ -423,10 +600,26 @@ module Hwloc
|
|
423
600
|
return at[:bridge]
|
424
601
|
when :OBJ_OS_DEVICE
|
425
602
|
return at[:osdev]
|
603
|
+
else
|
604
|
+
return at[:cache] if self.is_a_cache?
|
426
605
|
end
|
427
606
|
return nil
|
428
607
|
end
|
429
608
|
|
609
|
+
ObjType.symbols[0..-1].each { |sym|
|
610
|
+
suffix = sym.to_s[4..-1].downcase
|
611
|
+
methname = "is_a_#{suffix}?"
|
612
|
+
define_method(methname) {
|
613
|
+
return type == sym
|
614
|
+
}
|
615
|
+
}
|
616
|
+
|
617
|
+
if API_VERSION >= API_VERSION_2_0 then
|
618
|
+
def is_a_cache?
|
619
|
+
(Hwloc::OBJ_L1CACHE..Hwloc::OBJ_L3ICACHE).include?(ObjType[type])
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
430
623
|
end
|
431
624
|
|
432
625
|
end
|
data/lib/hwloc/Topology.rb
CHANGED
@@ -27,22 +27,27 @@ module Hwloc
|
|
27
27
|
end
|
28
28
|
|
29
29
|
class TopologyMemSupport < BoolStruct
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
topology_mem_support_layout = [
|
31
|
+
:set_thisproc_membind, :uchar,
|
32
|
+
:get_thisproc_membind, :uchar,
|
33
|
+
:set_proc_membind, :uchar,
|
34
|
+
:get_proc_membind, :uchar,
|
35
|
+
:set_thisthread_membind, :uchar,
|
36
|
+
:get_thisthread_membind, :uchar,
|
37
|
+
:set_area_membind, :uchar,
|
38
|
+
:get_area_membind, :uchar,
|
39
|
+
:alloc_membind, :uchar,
|
40
|
+
:firsttouch_membind, :uchar,
|
41
|
+
:bind_membind, :uchar,
|
42
|
+
:interleave_membind, :uchar
|
43
|
+
]
|
44
|
+
topology_mem_support_layout.push(:replicate_membind, :uchar) if API_VERSION < API_VERSION_2_0
|
45
|
+
topology_mem_support_layout += [
|
46
|
+
:nexttouch_membind, :uchar,
|
47
|
+
:migrate_membind, :uchar,
|
48
|
+
:get_area_memlocation, :uchar
|
49
|
+
]
|
50
|
+
layout( *topology_mem_support_layout )
|
46
51
|
end
|
47
52
|
|
48
53
|
class TopologySupport < Struct
|
@@ -61,33 +66,46 @@ module Hwloc
|
|
61
66
|
attach_function :hwloc_topology_dup, [:pointer, :topology], :int
|
62
67
|
attach_function :hwloc_topology_check, [:topology], :void
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
:
|
75
|
-
|
69
|
+
if API_VERSION < API_VERSION_2_0 then
|
70
|
+
TopologyFlags = enum( FFI::find_type(:ulong), :topology_flags, [
|
71
|
+
:TOPOLOGY_FLAG_WHOLE_SYSTEM, 1<<0,
|
72
|
+
:TOPOLOGY_FLAG_IS_THISSYSTEM, 1<<1,
|
73
|
+
:TOPOLOGY_FLAG_IO_DEVICES, 1<<2,
|
74
|
+
:TOPOLOGY_FLAG_IO_BRIDGES, 1<<3,
|
75
|
+
:TOPOLOGY_FLAG_WHOLE_IO, 1<<4,
|
76
|
+
:TOPOLOGY_FLAG_ICACHES, 1<<5
|
77
|
+
] )
|
78
|
+
else
|
79
|
+
TopologyFlags = enum( FFI::find_type(:ulong), :topology_flags, [
|
80
|
+
:TOPOLOGY_FLAG_WHOLE_SYSTEM, 1<<0,
|
81
|
+
:TOPOLOGY_FLAG_IS_THISSYSTEM, 1<<1,
|
82
|
+
:TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES, 1<<2
|
83
|
+
] )
|
84
|
+
end
|
76
85
|
|
77
86
|
attach_function :hwloc_topology_set_flags, [:topology, :ulong], :int
|
78
87
|
attach_function :hwloc_topology_get_flags, [:topology], :ulong
|
79
88
|
|
80
89
|
attach_function :hwloc_topology_set_pid, [:topology, :hwloc_pid_t], :int
|
81
|
-
|
90
|
+
if API_VERSION < API_VERSION_2_0 then
|
91
|
+
attach_function :hwloc_topology_set_fsroot, [:topology, :string], :int
|
92
|
+
end
|
82
93
|
attach_function :hwloc_topology_set_synthetic, [:topology, :string], :int
|
83
94
|
attach_function :hwloc_topology_set_xml, [:topology, :string], :int
|
84
95
|
attach_function :hwloc_topology_set_xmlbuffer, [:topology, :pointer, :size_t], :int
|
85
|
-
|
86
|
-
|
96
|
+
if API_VERSION < API_VERSION_2_0 then
|
97
|
+
attach_function :hwloc_topology_set_custom, [:topology], :int
|
98
|
+
attach_function :hwloc_topology_set_distance_matrix, [:topology, :obj_type, :uint, :pointer, :pointer], :int
|
99
|
+
else
|
100
|
+
attach_function :hwloc_distances_get, [:topology, :pointer, :pointer, :ulong, :ulong], :int
|
101
|
+
attach_function :hwloc_distances_get_by_depth, [:topology, :uint, :pointer, :pointer, :ulong, :ulong], :int
|
102
|
+
attach_function :hwloc_distances_release, [:topology, Distances.ptr], :void
|
103
|
+
attach_function :hwloc_distances_add, [:topology, :uint, :pointer, :pointer, :ulong, :ulong], :int
|
104
|
+
attach_function :hwloc_distances_remove, [:topology], :int
|
105
|
+
attach_function :hwloc_distances_remove_by_depth, [:topology, :uint], :int
|
106
|
+
end
|
87
107
|
attach_function :hwloc_topology_is_thissystem, [:topology], :int
|
88
|
-
|
89
108
|
attach_function :hwloc_topology_get_support, [:topology], TopologySupport.ptr
|
90
|
-
|
91
109
|
attach_function :hwloc_topology_get_depth, [:topology], :uint
|
92
110
|
|
93
111
|
GetTypeDepth = enum(:get_type_depth, [
|
@@ -96,7 +114,7 @@ module Hwloc
|
|
96
114
|
:TYPE_DEPTH_BRIDGE, -3,
|
97
115
|
:TYPE_DEPTH_PCI_DEVICE, -4,
|
98
116
|
:TYPE_DEPTH_OS_DEVICE, -5
|
99
|
-
] )
|
117
|
+
] + ( API_VERSION >= API_VERSION_2_0 ? [ :TYPE_DEPTH_MISC, -6 ] : [] ) )
|
100
118
|
|
101
119
|
attach_function :hwloc_get_type_depth, [:topology, :obj_type], :int
|
102
120
|
attach_function :hwloc_get_depth_type, [:topology, :uint], :obj_type
|
@@ -104,6 +122,22 @@ module Hwloc
|
|
104
122
|
|
105
123
|
attach_function :hwloc_get_obj_by_depth, [:topology, :uint, :uint], Obj.ptr
|
106
124
|
|
125
|
+
if API_VERSION < API_VERSION_2_0 then
|
126
|
+
attach_function :hwloc_topology_ignore_type, [:topology, :obj_type], :int
|
127
|
+
attach_function :hwloc_topology_ignore_type_keep_structure, [:topology, :obj_type], :int
|
128
|
+
attach_function :hwloc_topology_ignore_all_keep_structure, [:topology], :int
|
129
|
+
else
|
130
|
+
TypeFilter = enum(:type_filter, [
|
131
|
+
:TYPE_FILTER_KEEP_ALL, 0,
|
132
|
+
:TYPE_FILTER_KEEP_NONE, 1,
|
133
|
+
:TYPE_FILTER_KEEP_STRUCTURE, 2,
|
134
|
+
:TYPE_FILTER_KEEP_IMPORTANT, 3
|
135
|
+
] )
|
136
|
+
attach_function :hwloc_topology_set_type_filter, [:topology, :obj_type, :type_filter], :int
|
137
|
+
attach_function :hwloc_topology_get_type_filter, [:topology, :obj_type, :pointer], :int
|
138
|
+
attach_function :hwloc_topology_set_all_types_filter, [:topology, :type_filter], :int
|
139
|
+
end
|
140
|
+
|
107
141
|
end
|
108
142
|
|
109
143
|
module Hwloc
|
@@ -167,21 +201,76 @@ module Hwloc
|
|
167
201
|
return self
|
168
202
|
end
|
169
203
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
return self
|
174
|
-
end
|
175
|
-
|
176
|
-
def ignore_type_keep_structure(type)
|
177
|
-
if type == :all then
|
178
|
-
err = Hwloc.hwloc_topology_ignore_all_keep_structure(@ptr)
|
204
|
+
if API_VERSION < API_VERSION_2_0 then
|
205
|
+
def ignore_type(type)
|
206
|
+
err = Hwloc.hwloc_topology_ignore_type(@ptr, type)
|
179
207
|
raise TopologyError if err == -1
|
180
|
-
|
181
|
-
|
208
|
+
return self
|
209
|
+
end
|
210
|
+
|
211
|
+
def ignore_type_keep_structure(type)
|
212
|
+
if type == :all then
|
213
|
+
err = Hwloc.hwloc_topology_ignore_all_keep_structure(@ptr)
|
214
|
+
raise TopologyError if err == -1
|
215
|
+
else
|
216
|
+
err = Hwloc.hwloc_topology_ignore_type_keep_structure(@ptr, type)
|
217
|
+
raise TopologyError if err == -1
|
218
|
+
end
|
219
|
+
return self
|
220
|
+
end
|
221
|
+
else
|
222
|
+
def set_type_filter(type, filter)
|
223
|
+
if type == :all then
|
224
|
+
err = Hwloc.hwloc_topology_set_all_types_filter(@ptr, filter)
|
225
|
+
raise TopologyError if err == -1
|
226
|
+
else
|
227
|
+
err = Hwloc.hwloc_topology_set_type_filter(@ptr, type, filter)
|
228
|
+
raise TopologyError if err == -1
|
229
|
+
end
|
230
|
+
return self
|
231
|
+
end
|
232
|
+
|
233
|
+
def set_all_types_filter(filter)
|
234
|
+
return set_type_filter(:all, filter)
|
235
|
+
end
|
236
|
+
|
237
|
+
def get_type_filter(type)
|
238
|
+
filter_p = FFI::MemoryPointer::new(TypeFilter.native_type)
|
239
|
+
err = Hwloc.hwloc_topology_get_type_filter(@ptr, type, filter_p)
|
182
240
|
raise TopologyError if err == -1
|
241
|
+
filter = filter_p.read_int
|
242
|
+
return TypeFilter[filter]
|
243
|
+
end
|
244
|
+
|
245
|
+
def set_cache_types_filter(filter)
|
246
|
+
(Hwloc::OBJ_L1CACHE..Hwloc::OBJ_L3ICACHE).each { |cl|
|
247
|
+
set_type_filter(cl, filter)
|
248
|
+
}
|
249
|
+
return self
|
250
|
+
end
|
251
|
+
|
252
|
+
def set_icache_types_filter(filter)
|
253
|
+
(Hwloc::OBJ_L1ICACHE..Hwloc::OBJ_L3ICACHE).each { |cl|
|
254
|
+
set_type_filter(cl, filter)
|
255
|
+
}
|
256
|
+
return self
|
257
|
+
end
|
258
|
+
|
259
|
+
def set_io_types_filter(filter)
|
260
|
+
set_type_filter(Hwloc::OBJ_MISC, filter)
|
261
|
+
set_type_filter(Hwloc::OBJ_BRIDGE, filter)
|
262
|
+
set_type_filter(Hwloc::OBJ_PCI_DEVICE, filter)
|
263
|
+
set_type_filter(Hwloc::OBJ_OS_DEVICE, filter)
|
264
|
+
return self
|
265
|
+
end
|
266
|
+
|
267
|
+
def ignore_type(type)
|
268
|
+
return set_type_filter(type, Hwloc::TYPE_FILTER_KEEP_NONE)
|
269
|
+
end
|
270
|
+
|
271
|
+
def ignore_type_keep_structure(type)
|
272
|
+
set_type_filter(type, Hwloc::TYPE_FILTER_KEEP_STRUCTURE)
|
183
273
|
end
|
184
|
-
return self
|
185
274
|
end
|
186
275
|
|
187
276
|
def set_flags(flags)
|
@@ -204,10 +293,12 @@ module Hwloc
|
|
204
293
|
return self
|
205
294
|
end
|
206
295
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
296
|
+
if API_VERSION < API_VERSION_2_0 then
|
297
|
+
def set_fsroot(fsroot_path)
|
298
|
+
err = Hwloc.hwloc_topology_set_fsroot(@ptr, fsroot_path)
|
299
|
+
raise TopologyError if err == -1
|
300
|
+
return self
|
301
|
+
end
|
211
302
|
end
|
212
303
|
|
213
304
|
def set_synthetic(description)
|
@@ -228,10 +319,12 @@ module Hwloc
|
|
228
319
|
return self
|
229
320
|
end
|
230
321
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
322
|
+
if API_VERSION < API_VERSION_2_0 then
|
323
|
+
def set_custom
|
324
|
+
err = Hwloc.hwloc_topology_set_custom(@ptr)
|
325
|
+
raise TopologyError if err == -1
|
326
|
+
return self
|
327
|
+
end
|
235
328
|
end
|
236
329
|
|
237
330
|
## Will need some work to define properly...
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hwloc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|