Skip to content

Commit

Permalink
Strengthen class interfaces. (#269)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored Aug 12, 2024
1 parent f5cdfe4 commit 36df5fc
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 101 deletions.
6 changes: 3 additions & 3 deletions src/qvi-bbuff-rmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ template<>
inline void
qvi_bbuff_rmi_pack_type_picture(
std::string &picture,
const qvi_hwloc_bitmap_s &
const qvi_hwloc_bitmap &
) {
picture += "c";
}
Expand Down Expand Up @@ -484,7 +484,7 @@ qvi_bbuff_rmi_pack_item(
inline int
qvi_bbuff_rmi_pack_item(
qvi_bbuff *buff,
const qvi_hwloc_bitmap_s &bitmap
const qvi_hwloc_bitmap &bitmap
) {
return qvi_bbuff_rmi_pack_item_impl(buff, bitmap.cdata());
}
Expand Down Expand Up @@ -781,7 +781,7 @@ qvi_bbuff_rmi_unpack_item(
*/
inline int
qvi_bbuff_rmi_unpack_item(
qvi_hwloc_bitmap_s &bitmap,
qvi_hwloc_bitmap &bitmap,
byte_t *buffpos,
size_t *bytes_written
) {
Expand Down
2 changes: 1 addition & 1 deletion src/qvi-group-omp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "qvi-omp.h"

struct qvi_group_omp : public qvi_group {
protected:
private:
/** Task associated with this group. */
qvi_task *m_task = nullptr;
/** Underlying group instance. */
Expand Down
2 changes: 1 addition & 1 deletion src/qvi-hwloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ int
qvi_hwloc_get_devices_in_bitmap(
qvi_hwloc_t *hwl,
qv_hw_obj_type_t dev_type,
const qvi_hwloc_bitmap_s &bitmap,
const qvi_hwloc_bitmap &bitmap,
qvi_hwloc_dev_list_t &devs
) {
return get_devices_in_cpuset(hwl, dev_type, bitmap.cdata(), devs);
Expand Down
20 changes: 10 additions & 10 deletions src/qvi-hwloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,48 +419,48 @@ qvi_hwloc_supported_devices(void);
/**
* hwloc bitmap object.
*/
struct qvi_hwloc_bitmap_s {
struct qvi_hwloc_bitmap {
private:
/** Internal bitmap. */
hwloc_bitmap_t m_data = nullptr;
public:
/** Default constructor. */
qvi_hwloc_bitmap_s(void)
qvi_hwloc_bitmap(void)
{
const int rc = qvi_hwloc_bitmap_calloc(&m_data);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
}
/** Construct via hwloc_const_bitmap_t. */
explicit qvi_hwloc_bitmap_s(hwloc_const_bitmap_t bitmap)
explicit qvi_hwloc_bitmap(hwloc_const_bitmap_t bitmap)
{
int rc = qvi_hwloc_bitmap_calloc(&m_data);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
rc = set(bitmap);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
}
/** Copy constructor. */
qvi_hwloc_bitmap_s(const qvi_hwloc_bitmap_s &src)
qvi_hwloc_bitmap(const qvi_hwloc_bitmap &src)
{
int rc = qvi_hwloc_bitmap_calloc(&m_data);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
rc = set(src.m_data);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
}
/** Destructor. */
~qvi_hwloc_bitmap_s(void)
~qvi_hwloc_bitmap(void)
{
qvi_hwloc_bitmap_delete(&m_data);
}
/** Equality operator. */
bool
operator==(
const qvi_hwloc_bitmap_s &x
const qvi_hwloc_bitmap &x
) const {
return hwloc_bitmap_compare(cdata(), x.cdata()) == 0;
}
/** Assignment operator. */
void
operator=(const qvi_hwloc_bitmap_s &src)
operator=(const qvi_hwloc_bitmap &src)
{
const int rc = qvi_hwloc_bitmap_copy(src.m_data, m_data);
if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error();
Expand Down Expand Up @@ -494,13 +494,13 @@ struct qvi_hwloc_bitmap_s {
/**
* Vector of cpuset objects.
*/
using qvi_hwloc_cpusets_t = std::vector<qvi_hwloc_bitmap_s>;
using qvi_hwloc_cpusets_t = std::vector<qvi_hwloc_bitmap>;

typedef struct qvi_hwloc_device_s {
/** Device type. */
qv_hw_obj_type_t type = QV_HW_OBJ_LAST;
/** Device affinity. */
qvi_hwloc_bitmap_s affinity;
qvi_hwloc_bitmap affinity;
/** Vendor ID. */
int vendor_id = QVI_HWLOC_DEVICE_INVALID_ID;
/** System Management Interface ID. */
Expand Down Expand Up @@ -531,7 +531,7 @@ int
qvi_hwloc_get_devices_in_bitmap(
qvi_hwloc_t *hwl,
qv_hw_obj_type_t dev_type,
const qvi_hwloc_bitmap_s &bitmap,
const qvi_hwloc_bitmap &bitmap,
qvi_hwloc_dev_list_t &devs
);

Expand Down
6 changes: 3 additions & 3 deletions src/qvi-hwpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ qvi_hwpool_res::hints(void)
return m_hints;
}

qvi_hwloc_bitmap_s &
qvi_hwloc_bitmap &
qvi_hwpool_res::affinity(void)
{
return m_affinity;
}

const qvi_hwloc_bitmap_s &
const qvi_hwloc_bitmap &
qvi_hwpool_res::affinity(void) const
{
return m_affinity;
Expand Down Expand Up @@ -256,7 +256,7 @@ qvi_hwpool::initialize(
return add_devices_with_affinity(hwloc);
}

const qvi_hwloc_bitmap_s &
const qvi_hwloc_bitmap &
qvi_hwpool::cpuset(void) const
{
return m_cpu.affinity();
Expand Down
10 changes: 5 additions & 5 deletions src/qvi-hwpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ struct qvi_hwpool_res {
/** Resource hint flags. */
qv_scope_create_hints_t m_hints = QV_SCOPE_CREATE_HINT_NONE;
/** The resource's affinity encoded as a bitmap. */
qvi_hwloc_bitmap_s m_affinity;
qvi_hwloc_bitmap m_affinity;
public:
/** Returns the resource's create hints. */
qv_scope_create_hints_t
hints(void);
/**
* Returns a reference to the resource's affinity encoded by a bitmap.
*/
qvi_hwloc_bitmap_s &
qvi_hwloc_bitmap &
affinity(void);
/**
* Returns a const reference to the resource's affinity encoded by a bitmap.
*/
const qvi_hwloc_bitmap_s &
const qvi_hwloc_bitmap &
affinity(void) const;
};

Expand Down Expand Up @@ -72,7 +72,7 @@ struct qvi_hwpool_dev : qvi_hwpool_res {
/** Device type. */
qv_hw_obj_type_t m_type = QV_HW_OBJ_LAST;
/** The bitmap encoding CPU affinity. */
qvi_hwloc_bitmap_s m_affinity;
qvi_hwloc_bitmap m_affinity;
/** Device ID (ordinal). */
int m_id = QVI_HWLOC_DEVICE_INVALID_ID;
/** The PCI bus ID. */
Expand Down Expand Up @@ -164,7 +164,7 @@ struct qvi_hwpool {
/**
* Returns a const reference to the hardware pool's cpuset.
*/
const qvi_hwloc_bitmap_s &
const qvi_hwloc_bitmap &
cpuset(void) const;
/**
* Returns a const reference to the hardware pool's devices.
Expand Down
Loading

0 comments on commit 36df5fc

Please sign in to comment.