Commit 4da861f5 authored by Philippe SWARTVAGHER's avatar Philippe SWARTVAGHER
Browse files

Report the core id instead of the hyperthread id of OpenMP threads

parent 4fee25b1
......@@ -53,10 +53,26 @@ void get_worker_binding_ids(hwloc_topology_t topo, int nb_threads, int* _thread_
for (int i = 0; i < nb_threads; i++)
{
int core_os = sched_getcpu();
int logical_core = (topo == NULL) ? core_os : hwloc_get_pu_obj_by_os_index(topo, core_os)->logical_index;
thread_binding[i] = logical_core;
if (topo == NULL)
{
thread_binding[i] = core_os;
}
else
{
/* sched_getcpu() returns the OS index of the PU (hyperthread)
* where the thread is running. Since we execute only one thread
* per core, we want the logical index of the core, not of the PU. */
hwloc_obj_t pu_obj = hwloc_get_pu_obj_by_os_index(topo, core_os);
assert(pu_obj->type == HWLOC_OBJ_PU);
hwloc_obj_t core_obj = pu_obj->parent;
assert(core_obj-> type == HWLOC_OBJ_CORE);
thread_binding[i] = core_obj->logical_index;
}
}
// Check two threads are not bound on the same core:
for (int i = 0; i < nb_threads-1; i++)
{
for (int j = i+1; j < nb_threads; j++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment