1
1

Merge pull request #1297 from timattox/use_hwloc_bitmap_weight

Replace a bit counting loop with an efficient population count
Этот коммит содержится в:
rhc54 2016-01-13 09:05:13 -08:00
родитель 26e882c1c3 f2d4a8d266
Коммит eb65b5f97e

Просмотреть файл

@ -579,16 +579,10 @@ unsigned int opal_hwloc_base_get_npus(hwloc_topology_t topo,
* one bit for each available pu. We could just * one bit for each available pu. We could just
* subtract the first and last indices, but there * subtract the first and last indices, but there
* may be "holes" in the bitmap corresponding to * may be "holes" in the bitmap corresponding to
* offline or unallowed cpus - so we have to * offline or unallowed cpus - so we count them with
* search for them * the bitmap "weight" (a.k.a. population count) function
*/ */
for (i=hwloc_bitmap_first(cpuset), cnt=0; cnt = hwloc_bitmap_weight(cpuset);
i <= hwloc_bitmap_last(cpuset);
i++) {
if (hwloc_bitmap_isset(cpuset, i)) {
cnt++;
}
}
} }
/* cache the info */ /* cache the info */
data = (opal_hwloc_obj_data_t*)obj->userdata; // in case it was added data = (opal_hwloc_obj_data_t*)obj->userdata; // in case it was added