@@ -134,13 +134,64 @@ pool_release_cpus_by_cpuset(
134
134
}
135
135
#endif
136
136
137
+ qvi_hwloc_bitmap_s &
138
+ qvi_hwpool_cpu_s::cpuset (void )
139
+ {
140
+ return m_cpuset;
141
+ }
142
+
143
+ const qvi_hwloc_bitmap_s &
144
+ qvi_hwpool_cpu_s::cpuset (void )
145
+ const {
146
+ return m_cpuset;
147
+ }
148
+
149
+ int
150
+ qvi_hwpool_cpu_s::packinto (
151
+ qvi_bbuff_t *buff
152
+ ) const {
153
+ // Pack hints.
154
+ const int rc = qvi_bbuff_rmi_pack_item (buff, m_hints);
155
+ if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
156
+ // Pack cpuset.
157
+ return qvi_bbuff_rmi_pack_item (buff, m_cpuset);
158
+ }
159
+
160
+ int
161
+ qvi_hwpool_cpu_s::unpack (
162
+ byte_t *buffpos,
163
+ size_t *bytes_written,
164
+ qvi_hwpool_cpu_s &cpu
165
+ ) {
166
+ size_t bw = 0 , total_bw = 0 ;
167
+ // Unpack hints.
168
+ int rc = qvi_bbuff_rmi_unpack_item (
169
+ &cpu.m_hints , buffpos, &bw
170
+ );
171
+ if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
172
+ total_bw += bw;
173
+ buffpos += bw;
174
+ // Unpack bitmap.
175
+ rc = qvi_bbuff_rmi_unpack_item (
176
+ cpu.m_cpuset , buffpos, &bw
177
+ );
178
+ if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
179
+ total_bw += bw;
180
+ out:
181
+ if (qvi_unlikely (rc != QV_SUCCESS)) {
182
+ total_bw = 0 ;
183
+ }
184
+ *bytes_written = total_bw;
185
+ return rc;
186
+ }
187
+
137
188
qvi_hwpool_dev_s::qvi_hwpool_dev_s (
138
189
const qvi_hwloc_device_s &dev
139
- ) : type (dev.type)
140
- , affinity (dev.affinity)
190
+ ) : m_type (dev.type)
191
+ , m_affinity (dev.affinity)
141
192
, m_id(dev.id)
142
- , pci_bus_id (dev.pci_bus_id)
143
- , uuid (dev.uuid) { }
193
+ , m_pci_bus_id (dev.pci_bus_id)
194
+ , m_uuid (dev.uuid) { }
144
195
145
196
qvi_hwpool_dev_s::qvi_hwpool_dev_s (
146
197
const std::shared_ptr<qvi_hwloc_device_s> &shdev
150
201
qvi_hwpool_dev_s::operator ==(
151
202
const qvi_hwpool_dev_s &x
152
203
) const {
153
- return uuid == x.uuid ;
204
+ return m_uuid == x.m_uuid ;
154
205
}
155
206
156
207
int
@@ -161,10 +212,10 @@ qvi_hwpool_dev_s::id(
161
212
int rc = QV_SUCCESS, nw = 0 ;
162
213
switch (format) {
163
214
case (QV_DEVICE_ID_UUID):
164
- nw = asprintf (result, " %s" , uuid .c_str ());
215
+ nw = asprintf (result, " %s" , m_uuid .c_str ());
165
216
break ;
166
217
case (QV_DEVICE_ID_PCI_BUS_ID):
167
- nw = asprintf (result, " %s" , pci_bus_id .c_str ());
218
+ nw = asprintf (result, " %s" , m_pci_bus_id .c_str ());
168
219
break ;
169
220
case (QV_DEVICE_ID_ORDINAL):
170
221
nw = asprintf (result, " %d" , m_id);
@@ -181,27 +232,33 @@ qvi_hwpool_dev_s::id(
181
232
return rc;
182
233
}
183
234
235
+ const qvi_hwloc_bitmap_s &
236
+ qvi_hwpool_dev_s::affinity (void )
237
+ const {
238
+ return m_affinity;
239
+ }
240
+
184
241
int
185
242
qvi_hwpool_dev_s::packinto (
186
243
qvi_bbuff_t *buff
187
244
) const {
188
245
// Pack device hints.
189
- int rc = qvi_bbuff_rmi_pack_item (buff, hints );
246
+ int rc = qvi_bbuff_rmi_pack_item (buff, m_hints );
190
247
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
191
248
// Pack device affinity.
192
- rc = qvi_bbuff_rmi_pack_item (buff, affinity );
249
+ rc = qvi_bbuff_rmi_pack_item (buff, m_affinity );
193
250
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
194
251
// Pack device type.
195
- rc = qvi_bbuff_rmi_pack_item (buff, type );
252
+ rc = qvi_bbuff_rmi_pack_item (buff, m_type );
196
253
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
197
254
// Pack device ID.
198
255
rc = qvi_bbuff_rmi_pack_item (buff, m_id);
199
256
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
200
257
// Pack device PCI bus ID.
201
- rc = qvi_bbuff_rmi_pack_item (buff, pci_bus_id );
258
+ rc = qvi_bbuff_rmi_pack_item (buff, m_pci_bus_id );
202
259
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
203
260
// Pack device UUID.
204
- return qvi_bbuff_rmi_pack_item (buff, uuid );
261
+ return qvi_bbuff_rmi_pack_item (buff, m_uuid );
205
262
}
206
263
207
264
int
@@ -213,21 +270,21 @@ qvi_hwpool_dev_s::unpack(
213
270
size_t bw = 0 , total_bw = 0 ;
214
271
215
272
int rc = qvi_bbuff_rmi_unpack_item (
216
- &dev->hints , buffpos, &bw
273
+ &dev->m_hints , buffpos, &bw
217
274
);
218
275
if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
219
276
total_bw += bw;
220
277
buffpos += bw;
221
278
222
279
rc = qvi_bbuff_rmi_unpack_item (
223
- dev->affinity , buffpos, &bw
280
+ dev->m_affinity , buffpos, &bw
224
281
);
225
282
if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
226
283
total_bw += bw;
227
284
buffpos += bw;
228
285
229
286
rc = qvi_bbuff_rmi_unpack_item (
230
- &dev->type , buffpos, &bw
287
+ &dev->m_type , buffpos, &bw
231
288
);
232
289
if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
233
290
total_bw += bw;
@@ -241,14 +298,14 @@ qvi_hwpool_dev_s::unpack(
241
298
buffpos += bw;
242
299
243
300
rc = qvi_bbuff_rmi_unpack_item (
244
- dev->pci_bus_id , buffpos, &bw
301
+ dev->m_pci_bus_id , buffpos, &bw
245
302
);
246
303
if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
247
304
total_bw += bw;
248
305
buffpos += bw;
249
306
250
307
rc = qvi_bbuff_rmi_unpack_item (
251
- dev->uuid , buffpos, &bw
308
+ dev->m_uuid , buffpos, &bw
252
309
);
253
310
if (qvi_unlikely (rc != QV_SUCCESS)) goto out;
254
311
total_bw += bw;
@@ -269,7 +326,7 @@ qvi_hwpool_s::add_devices_with_affinity(
269
326
for (const auto devt : qvi_hwloc_supported_devices ()) {
270
327
qvi_hwloc_dev_list_t devs;
271
328
rc = qvi_hwloc_get_devices_in_bitmap (
272
- hwloc, devt, m_cpu.cpuset , devs
329
+ hwloc, devt, m_cpu.cpuset () , devs
273
330
);
274
331
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
275
332
for (const auto &dev : devs) {
@@ -304,7 +361,7 @@ qvi_hwpool_s::initialize(
304
361
qvi_hwloc_t *hwloc,
305
362
hwloc_const_bitmap_t cpuset
306
363
) {
307
- const int rc = m_cpu.cpuset .set (cpuset);
364
+ const int rc = m_cpu.cpuset () .set (cpuset);
308
365
if (qvi_unlikely (rc != QV_SUCCESS)) return rc;
309
366
// Add devices with affinity to the hardware pool.
310
367
return add_devices_with_affinity (hwloc);
@@ -313,7 +370,7 @@ qvi_hwpool_s::initialize(
313
370
const qvi_hwloc_bitmap_s &
314
371
qvi_hwpool_s::cpuset (void ) const
315
372
{
316
- return m_cpu.cpuset ;
373
+ return m_cpu.cpuset () ;
317
374
}
318
375
319
376
const qvi_hwpool_devs_t &
@@ -330,7 +387,7 @@ qvi_hwpool_s::nobjects(
330
387
) {
331
388
if (qvi_hwloc_obj_type_is_host_resource (obj_type)) {
332
389
return qvi_hwloc_get_nobjs_in_cpuset (
333
- hwloc, obj_type, m_cpu.cpuset .cdata (), result
390
+ hwloc, obj_type, m_cpu.cpuset () .cdata (), result
334
391
);
335
392
}
336
393
*result = m_devs.count (obj_type);
@@ -342,7 +399,7 @@ qvi_hwpool_s::add_device(
342
399
const qvi_hwpool_dev_s &dev
343
400
) {
344
401
auto shdev = std::make_shared<qvi_hwpool_dev_s>(dev);
345
- m_devs.insert ({dev.type , shdev});
402
+ m_devs.insert ({dev.m_type , shdev});
346
403
return QV_SUCCESS;
347
404
}
348
405
@@ -421,6 +478,7 @@ qvi_hwpool_s::unpack(
421
478
return rc;
422
479
}
423
480
481
+ #if 0
424
482
/**
425
483
* Extend namespace std so we can easily add qvi_devinfo_ts to
426
484
* unordered_sets.
@@ -439,6 +497,7 @@ namespace std {
439
497
}
440
498
};
441
499
}
500
+ #endif
442
501
443
502
/*
444
503
* vim: ft=cpp ts=4 sts=4 sw=4 expandtab
0 commit comments