Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qvi_hwloc_bitmap_nbits(). #85

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/quo-vadis.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ enum {
typedef enum qv_scope_create_hint_e {
// TODO(skg) Enumerate all actual values.
// TODO(skg) Add to Fortran interface.
// TODO(skg) Test bitmap operations in Fortran.
QV_SCOPE_CREATE_EXCLUSIVE = 0x00000001,
QV_SCOPE_CREATE_CLOSE = 0x00000002
} qv_scope_create_hint_t;
Expand Down
14 changes: 14 additions & 0 deletions src/qvi-hwloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,20 @@ qvi_hwloc_bitmap_copy(
return QV_SUCCESS;
}

int
qvi_hwloc_bitmap_nbits(
hwloc_const_cpuset_t cpuset,
size_t *nbits
) {
*nbits = 0;

const int inbits = hwloc_bitmap_last(cpuset);
if (inbits == -1) return QV_ERR_HWLOC;

*nbits = (size_t)inbits;
return QV_SUCCESS;
}

static int
topo_fname(
const char *base,
Expand Down
9 changes: 9 additions & 0 deletions src/qvi-hwloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ qvi_hwloc_bitmap_copy(
hwloc_cpuset_t dest
);

/**
* Returns the number of bits required to represent a given cpuset.
*/
int
qvi_hwloc_bitmap_nbits(
hwloc_const_cpuset_t cpuset,
size_t *nbits
);

/**
*
*/
Expand Down
Loading