Skip to content

Commit

Permalink
Add qvi_hwloc_bitmap_s to RMI with cleanups. (#102)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored Mar 21, 2024
1 parent 1dd4b47 commit 449cdba
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
40 changes: 39 additions & 1 deletion src/qvi-bbuff-rmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/qvi-hwpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 449cdba

Please sign in to comment.