2011-12-26 21:35:57 +00:00
|
|
|
/*
|
|
|
|
htop - AffinityPanel.c
|
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2011-12-26 21:35:57 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
2007-12-17 05:50:00 +00:00
|
|
|
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "config.h"
|
2007-12-17 05:50:00 +00:00
|
|
|
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "AffinityPanel.h"
|
2011-12-26 21:35:57 +00:00
|
|
|
|
2007-12-17 05:50:00 +00:00
|
|
|
#include <assert.h>
|
2011-12-26 21:35:57 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "CRT.h"
|
|
|
|
#include "StringUtils.h"
|
|
|
|
#include "Vector.h"
|
|
|
|
|
2020-08-26 00:15:00 +00:00
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
#include <hwloc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct MaskItem_ {
|
|
|
|
Object super;
|
2020-09-23 12:15:51 +00:00
|
|
|
char* text;
|
|
|
|
char* indent; /* used also as an condition whether this is a tree node */
|
2020-08-26 00:15:00 +00:00
|
|
|
int value; /* tri-state: 0 - off, 1 - some set, 2 - all set */
|
|
|
|
int sub_tree; /* tri-state: 0 - no sub-tree, 1 - open sub-tree, 2 - closed sub-tree */
|
|
|
|
Vector *children;
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
bool ownCpuset;
|
|
|
|
hwloc_bitmap_t cpuset;
|
|
|
|
#else
|
|
|
|
int cpu;
|
|
|
|
#endif
|
|
|
|
} MaskItem;
|
|
|
|
|
|
|
|
static void MaskItem_delete(Object* cast) {
|
|
|
|
MaskItem* this = (MaskItem*) cast;
|
2020-09-23 12:15:51 +00:00
|
|
|
free(this->text);
|
|
|
|
free(this->indent);
|
2020-08-26 00:15:00 +00:00
|
|
|
Vector_delete(this->children);
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
if (this->ownCpuset)
|
|
|
|
hwloc_bitmap_free(this->cpuset);
|
|
|
|
#endif
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2020-10-06 10:28:11 +00:00
|
|
|
static void MaskItem_display(const Object* cast, RichString* out) {
|
|
|
|
const MaskItem* this = (const MaskItem*)cast;
|
2020-08-26 00:15:00 +00:00
|
|
|
assert (this != NULL);
|
2020-08-31 20:08:35 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_BOX], "[");
|
2020-08-26 00:15:00 +00:00
|
|
|
if (this->value == 2)
|
2020-08-31 20:08:35 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_MARK], "x");
|
2020-08-26 00:15:00 +00:00
|
|
|
else if (this->value == 1)
|
2020-08-31 20:08:35 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_MARK], "o");
|
2020-08-26 00:15:00 +00:00
|
|
|
else
|
2020-08-31 20:08:35 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_MARK], " ");
|
|
|
|
RichString_append(out, CRT_colors[CHECK_BOX], "]");
|
2020-08-26 00:15:00 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
|
2020-08-31 20:22:22 +00:00
|
|
|
if (this->indent) {
|
2020-08-26 00:15:00 +00:00
|
|
|
RichString_append(out, CRT_colors[PROCESS_TREE], this->indent);
|
2020-08-31 20:22:22 +00:00
|
|
|
RichString_append(out, CRT_colors[PROCESS_TREE],
|
|
|
|
this->sub_tree == 2
|
|
|
|
? CRT_treeStr[TREE_STR_OPEN]
|
|
|
|
: CRT_treeStr[TREE_STR_SHUT]);
|
2020-08-26 00:15:00 +00:00
|
|
|
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
|
|
|
|
}
|
|
|
|
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
|
|
|
|
}
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
static const ObjectClass MaskItem_class = {
|
2020-08-26 00:15:00 +00:00
|
|
|
.display = MaskItem_display,
|
|
|
|
.delete = MaskItem_delete
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
|
|
|
|
static MaskItem* MaskItem_newMask(const char* text, const char* indent, hwloc_bitmap_t cpuset, bool owner) {
|
|
|
|
MaskItem* this = AllocThis(MaskItem);
|
|
|
|
this->text = xStrdup(text);
|
2020-08-31 20:22:22 +00:00
|
|
|
this->indent = xStrdup(indent); /* nonnull for tree node */
|
2020-08-26 00:15:00 +00:00
|
|
|
this->value = 0;
|
|
|
|
this->ownCpuset = owner;
|
|
|
|
this->cpuset = cpuset;
|
|
|
|
this->sub_tree = hwloc_bitmap_weight(cpuset) > 1 ? 1 : 0;
|
|
|
|
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static MaskItem* MaskItem_newSingleton(const char* text, int cpu, bool isSet) {
|
|
|
|
MaskItem* this = AllocThis(MaskItem);
|
|
|
|
this->text = xStrdup(text);
|
2020-08-31 20:22:22 +00:00
|
|
|
this->indent = NULL; /* not a tree node */
|
2020-08-26 00:15:00 +00:00
|
|
|
this->sub_tree = 0;
|
|
|
|
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
this->ownCpuset = true;
|
|
|
|
this->cpuset = hwloc_bitmap_alloc();
|
|
|
|
hwloc_bitmap_set(this->cpuset, cpu);
|
|
|
|
#else
|
|
|
|
this->cpu = cpu;
|
|
|
|
#endif
|
2020-09-23 15:58:11 +00:00
|
|
|
this->value = isSet ? 2 : 0;
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct AffinityPanel_ {
|
|
|
|
Panel super;
|
|
|
|
ProcessList* pl;
|
|
|
|
bool topoView;
|
|
|
|
Vector *cpuids;
|
|
|
|
unsigned width;
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
MaskItem *topoRoot;
|
|
|
|
hwloc_const_cpuset_t allCpuset;
|
|
|
|
hwloc_bitmap_t workCpuset;
|
|
|
|
#endif
|
|
|
|
} AffinityPanel;
|
|
|
|
|
|
|
|
static void AffinityPanel_delete(Object* cast) {
|
|
|
|
AffinityPanel* this = (AffinityPanel*) cast;
|
|
|
|
Panel* super = (Panel*) this;
|
|
|
|
Panel_done(super);
|
|
|
|
Vector_delete(this->cpuids);
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
hwloc_bitmap_free(this->workCpuset);
|
|
|
|
MaskItem_delete((Object*) this->topoRoot);
|
|
|
|
#endif
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
|
|
|
|
static void AffinityPanel_updateItem(AffinityPanel* this, MaskItem* item) {
|
|
|
|
Panel* super = (Panel*) this;
|
|
|
|
|
|
|
|
item->value = hwloc_bitmap_isincluded(item->cpuset, this->workCpuset) ? 2 :
|
|
|
|
hwloc_bitmap_intersects(item->cpuset, this->workCpuset) ? 1 : 0;
|
|
|
|
|
|
|
|
Panel_add(super, (Object*) item);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AffinityPanel_updateTopo(AffinityPanel* this, MaskItem* item) {
|
|
|
|
AffinityPanel_updateItem(this, item);
|
|
|
|
|
|
|
|
if (item->sub_tree == 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 0; i < Vector_size(item->children); i++)
|
|
|
|
AffinityPanel_updateTopo(this, (MaskItem*) Vector_get(item->children, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void AffinityPanel_update(AffinityPanel* this, bool keepSelected) {
|
|
|
|
Panel* super = (Panel*) this;
|
|
|
|
|
|
|
|
FunctionBar_setLabel(super->currentBar, KEY_F(3), this->topoView ? "Collapse/Expand" : "");
|
2020-10-05 13:14:54 +00:00
|
|
|
FunctionBar_draw(super->currentBar);
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
int oldSelected = Panel_getSelectedIndex(super);
|
|
|
|
Panel_prune(super);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
if (this->topoView)
|
|
|
|
AffinityPanel_updateTopo(this, this->topoRoot);
|
|
|
|
else {
|
|
|
|
for (int i = 0; i < Vector_size(this->cpuids); i++)
|
|
|
|
AffinityPanel_updateItem(this, (MaskItem*) Vector_get(this->cpuids, i));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
Panel_splice(super, this->cpuids);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (keepSelected)
|
|
|
|
Panel_setSelected(super, oldSelected);
|
|
|
|
|
|
|
|
super->needsRedraw = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
|
|
|
|
AffinityPanel* this = (AffinityPanel*) super;
|
|
|
|
HandlerResult result = IGNORED;
|
|
|
|
MaskItem* selected = (MaskItem*) Panel_getSelected(super);
|
|
|
|
bool keepSelected = true;
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
switch(ch) {
|
2008-05-07 23:01:45 +00:00
|
|
|
case KEY_MOUSE:
|
2015-08-27 21:42:35 +00:00
|
|
|
case KEY_RECLICK:
|
2008-03-09 08:58:38 +00:00
|
|
|
case ' ':
|
2020-08-26 00:15:00 +00:00
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
if (selected->value == 2) {
|
|
|
|
/* Item was selected, so remove this mask from the top cpuset. */
|
|
|
|
hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
|
|
|
|
selected->value = 0;
|
|
|
|
} else {
|
|
|
|
/* Item was not or only partial selected, so set all bits from this object
|
|
|
|
in the top cpuset. */
|
|
|
|
hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
|
|
|
|
selected->value = 2;
|
|
|
|
}
|
|
|
|
#else
|
2020-09-23 15:58:11 +00:00
|
|
|
selected->value = selected->value ? 0 : 2; /* toggle between 0 and 2 */
|
2020-08-26 00:15:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
|
|
|
|
case KEY_F(1):
|
|
|
|
hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_F(2):
|
|
|
|
this->topoView = !this->topoView;
|
|
|
|
keepSelected = false;
|
|
|
|
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_F(3):
|
|
|
|
case '-':
|
|
|
|
case '+':
|
|
|
|
if (selected->sub_tree)
|
|
|
|
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
|
|
|
|
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
case 0x0a:
|
|
|
|
case 0x0d:
|
|
|
|
case KEY_ENTER:
|
2020-08-26 00:15:00 +00:00
|
|
|
result = BREAK_LOOP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HANDLED == result)
|
|
|
|
AffinityPanel_update(this, keepSelected);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
|
|
|
|
static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
|
|
|
|
const char* type_name = hwloc_obj_type_string(obj->type);
|
2020-08-31 20:05:01 +00:00
|
|
|
const char* index_prefix = "#";
|
2020-08-26 00:15:00 +00:00
|
|
|
unsigned depth = obj->depth;
|
|
|
|
unsigned index = obj->logical_index;
|
|
|
|
size_t off = 0, left = 10 * depth;
|
|
|
|
char buf[64], indent_buf[left + 1];
|
|
|
|
|
|
|
|
if (obj->type == HWLOC_OBJ_PU) {
|
|
|
|
index = Settings_cpuId(this->pl->settings, obj->os_index);
|
|
|
|
type_name = "CPU";
|
|
|
|
index_prefix = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
indent_buf[0] = '\0';
|
|
|
|
if (depth > 0) {
|
|
|
|
for (unsigned i = 1; i < depth; i++) {
|
|
|
|
xSnprintf(&indent_buf[off], left, "%s ", (indent & (1u << i)) ? CRT_treeStr[TREE_STR_VERT] : " ");
|
|
|
|
size_t len = strlen(&indent_buf[off]);
|
2020-09-23 11:47:20 +00:00
|
|
|
off += len;
|
|
|
|
left -= len;
|
2020-08-26 00:15:00 +00:00
|
|
|
}
|
2020-08-31 20:22:22 +00:00
|
|
|
xSnprintf(&indent_buf[off], left, "%s",
|
|
|
|
obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
|
2020-09-21 13:06:19 +00:00
|
|
|
// Uncomment when further appending to indent_buf
|
|
|
|
//size_t len = strlen(&indent_buf[off]);
|
|
|
|
//off += len;
|
|
|
|
//left -= len;
|
2020-08-26 00:15:00 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 20:05:01 +00:00
|
|
|
xSnprintf(buf, 64, "%s %s%u", type_name, index_prefix, index);
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
MaskItem *item = MaskItem_newMask(buf, indent_buf, obj->complete_cpuset, false);
|
|
|
|
if (parent)
|
|
|
|
Vector_add(parent->children, item);
|
|
|
|
|
|
|
|
if (item->sub_tree && parent && parent->sub_tree == 1) {
|
|
|
|
/* if obj is fully included or fully excluded, collapse the item */
|
|
|
|
hwloc_bitmap_t result = hwloc_bitmap_alloc();
|
|
|
|
hwloc_bitmap_and(result, obj->complete_cpuset, this->workCpuset);
|
|
|
|
int weight = hwloc_bitmap_weight(result);
|
|
|
|
hwloc_bitmap_free(result);
|
|
|
|
if (weight == 0 || weight == (hwloc_bitmap_weight(this->workCpuset) + hwloc_bitmap_weight(obj->complete_cpuset)))
|
|
|
|
item->sub_tree = 2;
|
|
|
|
}
|
|
|
|
|
2020-08-31 20:22:22 +00:00
|
|
|
/* "[x] " + "|- " * depth + ("- ")?(if root node) + name */
|
|
|
|
unsigned width = 4 + 3 * depth + (2 * !depth) + strlen(buf);
|
2020-08-26 00:15:00 +00:00
|
|
|
if (width > this->width)
|
|
|
|
this->width = width;
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MaskItem *AffinityPanel_buildTopology(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
|
|
|
|
MaskItem *item = AffinityPanel_addObject(this, obj, indent, parent);
|
|
|
|
if (obj->next_sibling) {
|
|
|
|
indent |= (1u << obj->depth);
|
|
|
|
} else {
|
|
|
|
indent &= ~(1u << obj->depth);
|
2008-03-09 08:58:38 +00:00
|
|
|
}
|
2020-08-26 00:15:00 +00:00
|
|
|
for (unsigned i = 0; i < obj->arity; i++)
|
|
|
|
AffinityPanel_buildTopology(this, obj->children[i], indent, item);
|
|
|
|
|
|
|
|
return parent == NULL ? item : NULL;
|
2008-03-09 08:58:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 00:15:00 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const PanelClass AffinityPanel_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Panel),
|
2020-08-26 00:15:00 +00:00
|
|
|
.delete = AffinityPanel_delete
|
2012-12-05 15:12:20 +00:00
|
|
|
},
|
|
|
|
.eventHandler = AffinityPanel_eventHandler
|
|
|
|
};
|
|
|
|
|
2020-08-26 00:15:00 +00:00
|
|
|
static const char* const AffinityPanelFunctions[] = {
|
|
|
|
"Set ",
|
|
|
|
"Cancel ",
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
"All",
|
|
|
|
"Topology",
|
|
|
|
" ",
|
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static const char* const AffinityPanelKeys[] = {"Enter", "Esc", "F1", "F2", "F3"};
|
|
|
|
static const int AffinityPanelEvents[] = {13, 27, KEY_F(1), KEY_F(2), KEY_F(3)};
|
|
|
|
|
|
|
|
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) {
|
|
|
|
AffinityPanel* this = AllocThis(AffinityPanel);
|
|
|
|
Panel* super = (Panel*) this;
|
|
|
|
Panel_init(super, 1, 1, 1, 1, Class(MaskItem), false, FunctionBar_new(AffinityPanelFunctions, AffinityPanelKeys, AffinityPanelEvents));
|
|
|
|
|
|
|
|
this->pl = pl;
|
2020-08-26 20:03:04 +00:00
|
|
|
/* defaults to 15, this also includes the gap between the panels,
|
|
|
|
* but this will be added by the caller */
|
|
|
|
this->width = 14;
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
this->cpuids = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
this->topoView = pl->settings->topologyAffinity;
|
|
|
|
#else
|
|
|
|
this->topoView = false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
this->allCpuset = hwloc_topology_get_complete_cpuset(pl->topology);
|
|
|
|
this->workCpuset = hwloc_bitmap_alloc();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Panel_setHeader(super, "Use CPUs:");
|
2007-12-17 05:50:00 +00:00
|
|
|
|
2011-09-24 00:30:47 +00:00
|
|
|
int curCpu = 0;
|
2011-03-22 20:37:08 +00:00
|
|
|
for (int i = 0; i < pl->cpuCount; i++) {
|
2020-08-26 00:15:00 +00:00
|
|
|
char number[16];
|
|
|
|
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
|
2020-09-07 07:42:48 +00:00
|
|
|
unsigned cpu_width = 4 + strlen(number);
|
|
|
|
if (cpu_width > this->width)
|
|
|
|
this->width = cpu_width;
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
bool isSet = false;
|
2011-09-24 00:30:47 +00:00
|
|
|
if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
|
2020-08-26 00:15:00 +00:00
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
hwloc_bitmap_set(this->workCpuset, i);
|
|
|
|
#endif
|
|
|
|
isSet = true;
|
2011-09-24 00:30:47 +00:00
|
|
|
curCpu++;
|
|
|
|
}
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
MaskItem* cpuItem = MaskItem_newSingleton(number, i, isSet);
|
|
|
|
Vector_add(this->cpuids, (Object*) cpuItem);
|
2007-12-17 05:50:00 +00:00
|
|
|
}
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
this->topoRoot = AffinityPanel_buildTopology(this, hwloc_get_root_obj(pl->topology), 0, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (width)
|
|
|
|
*width = this->width;
|
|
|
|
|
|
|
|
AffinityPanel_update(this, false);
|
|
|
|
|
|
|
|
return super;
|
2007-12-17 05:50:00 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 00:15:00 +00:00
|
|
|
Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
|
|
|
|
AffinityPanel* this = (AffinityPanel*) super;
|
2015-01-22 01:27:31 +00:00
|
|
|
Affinity* affinity = Affinity_new(pl);
|
2020-08-26 00:15:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBHWLOC
|
|
|
|
int i;
|
|
|
|
hwloc_bitmap_foreach_begin(i, this->workCpuset)
|
|
|
|
Affinity_add(affinity, i);
|
|
|
|
hwloc_bitmap_foreach_end();
|
|
|
|
#else
|
|
|
|
for (int i = 0; i < this->pl->cpuCount; i++) {
|
|
|
|
MaskItem* item = (MaskItem*)Vector_get(this->cpuids, i);
|
|
|
|
if (item->value)
|
|
|
|
Affinity_add(affinity, item->cpu);
|
2007-12-17 05:50:00 +00:00
|
|
|
}
|
2020-08-26 00:15:00 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-24 00:30:47 +00:00
|
|
|
return affinity;
|
2007-12-17 05:50:00 +00:00
|
|
|
}
|