Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hwloc: Add weighted interleave support #662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions hwloc/topology-linux.c
Expand Up @@ -178,6 +178,9 @@ struct hwloc_linux_backend_data_s {
#ifndef MPOL_PREFERRED_MANY
# define MPOL_PREFERRED_MANY 5
#endif
#ifndef MPOL_WEIGHTED_INTERLEAVE
# define MPOL_WEIGHTED_INTERLEAVE 6
#endif
#ifndef MPOL_F_ADDR
# define MPOL_F_ADDR (1<<1)
#endif
Expand Down Expand Up @@ -1674,6 +1677,9 @@ hwloc_linux_membind_policy_from_hwloc(int *linuxpolicy, hwloc_membind_policy_t p
case HWLOC_MEMBIND_INTERLEAVE:
*linuxpolicy = MPOL_INTERLEAVE;
break;
case HWLOC_MEMBIND_WEIGHTED_INTERLEAVE:
*linuxpolicy = MPOL_WEIGHTED_INTERLEAVE;
break;
/* TODO: next-touch when (if?) patch applied upstream */
default:
errno = ENOSYS;
Expand Down Expand Up @@ -1973,6 +1979,9 @@ hwloc_linux_membind_policy_to_hwloc(int linuxpolicy, hwloc_membind_policy_t *pol
case MPOL_INTERLEAVE:
*policy = HWLOC_MEMBIND_INTERLEAVE;
return 0;
case MPOL_WEIGHTED_INTERLEAVE:
*policy = HWLOC_MEMBIND_WEIGHTED_INTERLEAVE;
return 0;
default:
errno = EINVAL;
return -1;
Expand Down
10 changes: 10 additions & 0 deletions include/hwloc.h
Expand Up @@ -1705,6 +1705,16 @@ typedef enum {
* \hideinitializer */
HWLOC_MEMBIND_NEXTTOUCH = 4,

/** \brief Allocate memory on the given nodes in an interleaved
* / weighted manner. The precise layout of the memory across
* multiple NUMA nodes is OS/system specific. Weighted interleaving
* can be useful when threads distributed across the specified NUMA
* nodes with different bandwidth capabilities will all be accessing
* the whole memory range concurrently, since the interleave will then
* balance the memory references.
* \hideinitializer */
HWLOC_MEMBIND_WEIGHTED_INTERLEAVE = 5,

/** \brief Returned by get_membind() functions when multiple
* threads or parts of a memory area have differing memory binding
* policies.
Expand Down