Skip to content

Commit

Permalink
Add qvi_hwloc_bitmap_nbits(). (#85)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <samuel@lanl.gov>
  • Loading branch information
samuelkgutierrez authored Mar 13, 2024
1 parent 489dd43 commit 2550431
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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

0 comments on commit 2550431

Please sign in to comment.