From 449cdba50a0ec0cc8580daa978253e6133cbe35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20K=2E=20Guti=C3=A9rrez?= Date: Thu, 21 Mar 2024 12:26:36 -0600 Subject: [PATCH] Add qvi_hwloc_bitmap_s to RMI with cleanups. (#102) Signed-off-by: Samuel K. Gutierrez --- src/qvi-bbuff-rmi.h | 40 +++++++++++++++++++++++++++++++++++++++- src/qvi-hwpool.cc | 14 +++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/qvi-bbuff-rmi.h b/src/qvi-bbuff-rmi.h index ff45bbd3..02b5581f 100644 --- a/src/qvi-bbuff-rmi.h +++ b/src/qvi-bbuff-rmi.h @@ -15,6 +15,7 @@ * Picture Reference: * b = qvi_bbuff_rmi_bytes_in_t, qvi_bbuff_rmi_bytes_out_t * c = hwloc_cpuset_t + * c = qvi_hwloc_bitmap_s * h = qvi_hwpool_t * (conversion to qvi_line_hwpool_t * done internally) * h = qvi_line_hwpool_t * * i = int @@ -89,6 +90,15 @@ qvi_bbuff_rmi_pack_type_picture( picture += "c"; } +template<> +inline void +qvi_bbuff_rmi_pack_type_picture( + std::string &picture, + const qvi_hwloc_bitmap_s & +) { + picture += "c"; +} + template<> inline void qvi_bbuff_rmi_pack_type_picture( @@ -466,6 +476,17 @@ qvi_bbuff_rmi_pack_item( return qvi_bbuff_rmi_pack_item_impl(buff, data); } +/** + * Packs qvi_hwloc_bitmap_s + */ +inline int +qvi_bbuff_rmi_pack_item( + qvi_bbuff_t *buff, + const qvi_hwloc_bitmap_s &bitmap +) { + return qvi_bbuff_rmi_pack_item_impl(buff, bitmap.data); +} + /** * Packs hwloc_const_cpuset_t */ @@ -772,11 +793,28 @@ qvi_bbuff_rmi_unpack_item( *bytes_written = strlen(cpusets) + 1; out: if (rc != QV_SUCCESS) { - hwloc_bitmap_free(*cpuset); + qvi_hwloc_bitmap_free(cpuset); } return rc; } +inline int +qvi_bbuff_rmi_unpack_item( + qvi_hwloc_bitmap_s &bitmap, + byte_t *buffpos, + size_t *bytes_written +) { + hwloc_cpuset_t raw_cpuset = nullptr; + int rc = qvi_bbuff_rmi_unpack_item( + &raw_cpuset, buffpos, bytes_written + ); + if (rc != QV_SUCCESS) return rc; + + rc = qvi_hwloc_bitmap_copy(raw_cpuset, bitmap.data); + qvi_hwloc_bitmap_free(&raw_cpuset); + return rc; +} + inline int qvi_bbuff_rmi_unpack_item( qvi_bbuff_rmi_zero_msg_t, diff --git a/src/qvi-hwpool.cc b/src/qvi-hwpool.cc index b393a99d..c2026441 100644 --- a/src/qvi-hwpool.cc +++ b/src/qvi-hwpool.cc @@ -87,6 +87,13 @@ qvi_hwpool_new( return qvi_new_rc(rpool); } +void +qvi_hwpool_free( + qvi_hwpool_t **rpool +) { + qvi_delete(rpool); +} + int qvi_hwpool_new_from_line( qvi_line_hwpool_t *line, @@ -177,13 +184,6 @@ qvi_hwpool_new_line_from_hwpool( return rc; } -void -qvi_hwpool_free( - qvi_hwpool_t **rpool -) { - qvi_delete(rpool); -} - int qvi_hwpool_init( qvi_hwpool_t *rpool,