Skip to content

Commit

Permalink
Restrict HWLOC's interference with Windows process affninity (#1457)
Browse files Browse the repository at this point in the history
On Windows systems with multiple processor groups, HWLOC x86 backend might interfere with process affinity mask leading applications trying to set process affinity mask to fail.

---------

Signed-off-by: Isaev, Ilya <[email protected]>
  • Loading branch information
isaevil authored Jul 29, 2024
1 parent 2360b48 commit 4d0dc6a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/tbbbind/tbb_bind.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2023 Intel Corporation
Copyright (c) 2019-2024 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,12 +88,15 @@ class system_topology {
if ( hwloc_topology_init( &topology ) == 0 ) {
initialization_state = topology_allocated;
#if __TBBBIND_HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING_PRESENT
if ( groups_num == 1 &&
hwloc_topology_set_flags(topology,
HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING
) != 0
) {
unsigned long flags = 0;
if (groups_num > 1) {
// HWLOC x86 backend might interfere with process affinity mask on
// Windows systems with multiple processor groups.
flags = HWLOC_TOPOLOGY_FLAG_DONT_CHANGE_BINDING;
} else {
flags = HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM | HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING;
}
if (hwloc_topology_set_flags(topology, flags) != 0) {
return;
}
#endif
Expand Down

0 comments on commit 4d0dc6a

Please sign in to comment.