Skip to content

Commit 2550431

Browse files
Add qvi_hwloc_bitmap_nbits(). (#85)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent 489dd43 commit 2550431

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

include/quo-vadis.h

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ enum {
134134
typedef enum qv_scope_create_hint_e {
135135
// TODO(skg) Enumerate all actual values.
136136
// TODO(skg) Add to Fortran interface.
137-
// TODO(skg) Test bitmap operations in Fortran.
138137
QV_SCOPE_CREATE_EXCLUSIVE = 0x00000001,
139138
QV_SCOPE_CREATE_CLOSE = 0x00000002
140139
} qv_scope_create_hint_t;

src/qvi-hwloc.cc

+14
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,20 @@ qvi_hwloc_bitmap_copy(
794794
return QV_SUCCESS;
795795
}
796796

797+
int
798+
qvi_hwloc_bitmap_nbits(
799+
hwloc_const_cpuset_t cpuset,
800+
size_t *nbits
801+
) {
802+
*nbits = 0;
803+
804+
const int inbits = hwloc_bitmap_last(cpuset);
805+
if (inbits == -1) return QV_ERR_HWLOC;
806+
807+
*nbits = (size_t)inbits;
808+
return QV_SUCCESS;
809+
}
810+
797811
static int
798812
topo_fname(
799813
const char *base,

src/qvi-hwloc.h

+9
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ qvi_hwloc_bitmap_copy(
150150
hwloc_cpuset_t dest
151151
);
152152

153+
/**
154+
* Returns the number of bits required to represent a given cpuset.
155+
*/
156+
int
157+
qvi_hwloc_bitmap_nbits(
158+
hwloc_const_cpuset_t cpuset,
159+
size_t *nbits
160+
);
161+
153162
/**
154163
*
155164
*/

0 commit comments

Comments
 (0)