|
NAMEhwlocality_membindingSYNOPSISEnumerationsenum hwloc_membind_policy_t { HWLOC_MEMBIND_DEFAULT, HWLOC_MEMBIND_FIRSTTOUCH, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_INTERLEAVE, HWLOC_MEMBIND_REPLICATE, HWLOC_MEMBIND_NEXTTOUCH, HWLOC_MEMBIND_MIXED } enum hwloc_membind_flags_t { HWLOC_MEMBIND_PROCESS, HWLOC_MEMBIND_THREAD, HWLOC_MEMBIND_STRICT, HWLOC_MEMBIND_MIGRATE, HWLOC_MEMBIND_NOCPUBIND, HWLOC_MEMBIND_BYNODESET } Functionsint hwloc_set_membind_nodeset (hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) int hwloc_set_membind (hwloc_topology_t topology, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) int hwloc_get_membind_nodeset (hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t *policy, int flags) int hwloc_get_membind (hwloc_topology_t topology, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags) int hwloc_set_proc_membind_nodeset (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) int hwloc_set_proc_membind (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) int hwloc_get_proc_membind_nodeset (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t *policy, int flags) int hwloc_get_proc_membind (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags) int hwloc_set_area_membind_nodeset (hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) int hwloc_set_area_membind (hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) int hwloc_get_area_membind_nodeset (hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t *policy, int flags) int hwloc_get_area_membind (hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags) int hwloc_get_area_memlocation (hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, int flags) void * hwloc_alloc (hwloc_topology_t topology, size_t len) void * hwloc_alloc_membind_nodeset (hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) void * hwloc_alloc_membind (hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) static void * hwloc_alloc_membind_policy_nodeset (hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) static void * hwloc_alloc_membind_policy (hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) int hwloc_free (hwloc_topology_t topology, void *addr, size_t len) Detailed DescriptionMemory binding can be done three ways:
Not all operating systems support all three ways. hwloc_topology_get_support() may be used to query about the actual memory binding support in the currently used operating system. When the requested binding operation is not available and the HWLOC_MEMBIND_STRICT flag was passed, the function returns -1. errno will be set to ENOSYS when the system does support the specified action or policy (e.g., some systems only allow binding memory on a per-thread basis, whereas other systems only allow binding memory for all threads in a process). errno will be set to EXDEV when the requested set can not be enforced (e.g., some systems only allow binding memory to a single NUMA node). If HWLOC_MEMBIND_STRICT was not passed, the function may fail as well, or the operating system may use a slightly different operation (with side-effects, smaller binding set, etc.) when the requested operation is not exactly supported. The most portable form that should be preferred over the others whenever possible is as follows. It allocates some memory hopefully bound to the specified set. To do so, hwloc will possibly have to change the current memory binding policy in order to actually get the memory bound, if the OS does not provide any other way to simply allocate bound memory without changing the policy for all allocations. That is the difference with hwloc_alloc_membind(), which will never change the current memory binding policy. hwloc_alloc_membind_policy(topology, size, set, HWLOC_MEMBIND_BIND, 0); Each hwloc memory binding function is available in two forms: one that takes a bitmap argument (a CPU set by default, or a NUMA memory node set if the flag HWLOC_MEMBIND_BYNODESET is specified), and another one (whose name ends with _nodeset) that always takes a NUMA memory node set. See Object Sets (hwloc_cpuset_t and hwloc_nodeset_t) and The bitmap API for a discussion of CPU sets and NUMA memory node sets. It is also possible to convert between CPU set and node set using hwloc_cpuset_to_nodeset() or hwloc_cpuset_from_nodeset(). Memory binding by CPU set cannot work for CPU-less NUMA memory nodes. Binding by nodeset should therefore be preferred whenever possible. See also: Some example codes are available under doc/examples/ in
the source tree.
Note: On some operating systems, memory binding affects the CPU
binding; see HWLOC_MEMBIND_NOCPUBIND
Enumeration Type Documentationenum hwloc_membind_flags_tMemory binding flags. These flags can be used to refine the binding policy. All flags can be logically OR'ed together with the exception of HWLOC_MEMBIND_PROCESS and HWLOC_MEMBIND_THREAD; these two flags are mutually exclusive.Not all systems support all kinds of binding. hwloc_topology_get_support() may be used to query about the actual memory binding support in the currently used operating system. See the 'Detailed Description' section of Memory binding for a description of errors that can occur. Enumerator
This flag has slightly different meanings depending on which function it is used with.
Memory binding by CPU set cannot work for CPU-less NUMA memory nodes. Binding by nodeset should therefore be preferred whenever possible. enum hwloc_membind_policy_tMemory binding policy. These constants can be used to choose the binding policy. Only one policy can be used at a time (i.e., the values cannot be OR'ed together).Not all systems support all kinds of binding. hwloc_topology_get_support() may be used to query about the actual memory binding policy support in the currently used operating system. See the 'Detailed Description' section of Memory binding for a description of errors that can occur. Enumerator
Function Documentationvoid* hwloc_alloc (hwloc_topology_t topology, size_t len)Allocate some memory. This is equivalent to malloc(), except that it tries to allocate page-aligned memory from the OS.Note: The allocated memory should be freed with
hwloc_free().
void* hwloc_alloc_membind (hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)Allocate some memory on NUMA memory nodes specified by set.Returns: NULL with errno set to ENOSYS if the action is not
supported and HWLOC_MEMBIND_STRICT is given
NULL with errno set to EXDEV if the binding cannot be enforced and HWLOC_MEMBIND_STRICT is given NULL with errno set to ENOMEM if the memory allocation failed even before trying to bind. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. Note: The allocated memory should be freed with
hwloc_free().
void* hwloc_alloc_membind_nodeset (hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)Allocate some memory on NUMA memory nodes specified by nodeset.Returns: NULL with errno set to ENOSYS if the action is not
supported and HWLOC_MEMBIND_STRICT is given
NULL with errno set to EXDEV if the binding cannot be enforced and HWLOC_MEMBIND_STRICT is given NULL with errno set to ENOMEM if the memory allocation failed even before trying to bind. Note: The allocated memory should be freed with
hwloc_free().
static void* hwloc_alloc_membind_policy (hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) [inline], [static]Allocate some memory on NUMA memory nodes specified by set. This is similar to hwloc_alloc_membind_nodeset() except that it is allowed to change the current memory binding policy, thus providing more binding support, at the expense of changing the current state.If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. static void* hwloc_alloc_membind_policy_nodeset (hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) [inline], [static]Allocate some memory on NUMA memory nodes specified by nodeset. This is similar to hwloc_alloc_membind() except that it is allowed to change the current memory binding policy, thus providing more binding support, at the expense of changing the current state.int hwloc_free (hwloc_topology_t topology, void * addr, size_t len)Free memory that was previously allocated by hwloc_alloc() or hwloc_alloc_membind().int hwloc_get_area_membind (hwloc_topology_t topology, const void * addr, size_t len, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)Query the CPUs near the physical NUMA node(s) and binding policy of the memory identified by (addr, len ). This function has two output parameters: set and policy. The values returned in these parameters depend on both the flags passed in and the memory binding policies and nodesets of the pages in the address range.If HWLOC_MEMBIND_STRICT is specified, the target pages are first checked to see if they all have the same memory binding policy and nodeset. If they do not, -1 is returned and errno is set to EXDEV. If they are identical across all pages, the set and policy are returned in set and policy, respectively. If HWLOC_MEMBIND_STRICT is not specified, the union of all NUMA node(s) containing pages in the address range is calculated. If all pages in the target have the same policy, it is returned in policy. Otherwise, policy is set to HWLOC_MEMBIND_MIXED. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. If len is 0, -1 is returned and errno is set to EINVAL. If any other flags are specified, -1 is returned and errno is set to EINVAL. int hwloc_get_area_membind_nodeset (hwloc_topology_t topology, const void * addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)Query the physical NUMA node(s) and binding policy of the memory identified by (addr, len ). This function has two output parameters: nodeset and policy. The values returned in these parameters depend on both the flags passed in and the memory binding policies and nodesets of the pages in the address range.If HWLOC_MEMBIND_STRICT is specified, the target pages are first checked to see if they all have the same memory binding policy and nodeset. If they do not, -1 is returned and errno is set to EXDEV. If they are identical across all pages, the nodeset and policy are returned in nodeset and policy, respectively. If HWLOC_MEMBIND_STRICT is not specified, nodeset is set to the union of all NUMA node(s) containing pages in the address range. If all pages in the target have the same policy, it is returned in policy. Otherwise, policy is set to HWLOC_MEMBIND_MIXED. If len is 0, -1 is returned and errno is set to EINVAL. If any other flags are specified, -1 is returned and errno is set to EINVAL. int hwloc_get_area_memlocation (hwloc_topology_t topology, const void * addr, size_t len, hwloc_bitmap_t set, int flags)Get the NUMA nodes where memory identified by (addr, len ) is physically allocated. Fills set according to the NUMA nodes where the memory area pages are physically allocated. If no page is actually allocated yet, set may be empty.If pages spread to multiple nodes, it is not specified whether they spread equitably, or whether most of them are on a single node, etc. The operating system may move memory pages from one processor to another at any time according to their binding, so this function may return something that is already outdated. If HWLOC_MEMBIND_BYNODESET is specified in flags, set is considered a nodeset. Otherwise it's a cpuset. If len is 0, set is emptied. int hwloc_get_membind (hwloc_topology_t topology, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)Query the default memory binding policy and physical locality of the current process or thread. This function has two output parameters: set and policy. The values returned in these parameters depend on both the flags passed in and the current memory binding policies and nodesets in the queried target.Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets for all the threads in the current process. Passing HWLOC_MEMBIND_THREAD specifies that the query target is the current policy and nodeset for only the thread invoking this function. If neither of these flags are passed (which is the most portable method), the process is assumed to be single threaded. This allows hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available. HWLOC_MEMBIND_STRICT is only meaningful when HWLOC_MEMBIND_PROCESS is also specified. In this case, hwloc will check the default memory policies and nodesets for all threads in the process. If they are not identical, -1 is returned and errno is set to EXDEV. If they are identical, the values are returned in set and policy. Otherwise, if HWLOC_MEMBIND_PROCESS is specified (and HWLOC_MEMBIND_STRICT is not specified), the default set from each thread is logically OR'ed together. If all threads' default policies are the same, policy is set to that policy. If they are different, policy is set to HWLOC_MEMBIND_MIXED. In the HWLOC_MEMBIND_THREAD case (or when neither HWLOC_MEMBIND_PROCESS or HWLOC_MEMBIND_THREAD is specified), there is only one set and policy; they are returned in set and policy, respectively. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. If any other flags are specified, -1 is returned and errno is set to EINVAL. int hwloc_get_membind_nodeset (hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)Query the default memory binding policy and physical locality of the current process or thread. This function has two output parameters: nodeset and policy. The values returned in these parameters depend on both the flags passed in and the current memory binding policies and nodesets in the queried target.Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets for all the threads in the current process. Passing HWLOC_MEMBIND_THREAD specifies that the query target is the current policy and nodeset for only the thread invoking this function. If neither of these flags are passed (which is the most portable method), the process is assumed to be single threaded. This allows hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available. HWLOC_MEMBIND_STRICT is only meaningful when HWLOC_MEMBIND_PROCESS is also specified. In this case, hwloc will check the default memory policies and nodesets for all threads in the process. If they are not identical, -1 is returned and errno is set to EXDEV. If they are identical, the values are returned in nodeset and policy. Otherwise, if HWLOC_MEMBIND_PROCESS is specified (and HWLOC_MEMBIND_STRICT is not specified), nodeset is set to the logical OR of all threads' default nodeset. If all threads' default policies are the same, policy is set to that policy. If they are different, policy is set to HWLOC_MEMBIND_MIXED. In the HWLOC_MEMBIND_THREAD case (or when neither HWLOC_MEMBIND_PROCESS or HWLOC_MEMBIND_THREAD is specified), there is only one nodeset and policy; they are returned in nodeset and policy, respectively. If any other flags are specified, -1 is returned and errno is set to EINVAL. int hwloc_get_proc_membind (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)Query the default memory binding policy and physical locality of the specified process. This function has two output parameters: set and policy. The values returned in these parameters depend on both the flags passed in and the current memory binding policies and nodesets in the queried target.Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets for all the threads in the specified process. If HWLOC_MEMBIND_PROCESS is not specified (which is the most portable method), the process is assumed to be single threaded. This allows hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available. Note that it does not make sense to pass HWLOC_MEMBIND_THREAD to this function. If HWLOC_MEMBIND_STRICT is specified, hwloc will check the default memory policies and nodesets for all threads in the specified process. If they are not identical, -1 is returned and errno is set to EXDEV. If they are identical, the values are returned in set and policy. Otherwise, set is set to the logical OR of all threads' default set. If all threads' default policies are the same, policy is set to that policy. If they are different, policy is set to HWLOC_MEMBIND_MIXED. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. If any other flags are specified, -1 is returned and errno is set to EINVAL. Note: hwloc_pid_t is pid_t on Unix platforms, and
HANDLE on native Windows platforms.
int hwloc_get_proc_membind_nodeset (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)Query the default memory binding policy and physical locality of the specified process. This function has two output parameters: nodeset and policy. The values returned in these parameters depend on both the flags passed in and the current memory binding policies and nodesets in the queried target.Passing the HWLOC_MEMBIND_PROCESS flag specifies that the query target is the current policies and nodesets for all the threads in the specified process. If HWLOC_MEMBIND_PROCESS is not specified (which is the most portable method), the process is assumed to be single threaded. This allows hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available. Note that it does not make sense to pass HWLOC_MEMBIND_THREAD to this function. If HWLOC_MEMBIND_STRICT is specified, hwloc will check the default memory policies and nodesets for all threads in the specified process. If they are not identical, -1 is returned and errno is set to EXDEV. If they are identical, the values are returned in nodeset and policy. Otherwise, nodeset is set to the logical OR of all threads' default nodeset. If all threads' default policies are the same, policy is set to that policy. If they are different, policy is set to HWLOC_MEMBIND_MIXED. If any other flags are specified, -1 is returned and errno is set to EINVAL. Note: hwloc_pid_t is pid_t on Unix platforms, and
HANDLE on native Windows platforms.
int hwloc_set_area_membind (hwloc_topology_t topology, const void * addr, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)Bind the already-allocated memory identified by (addr, len) to the NUMA node(s) specified by set. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.Returns: 0 if len is 0.
-1 with errno set to ENOSYS if the action is not supported -1 with errno set to EXDEV if the binding cannot be enforced int hwloc_set_area_membind_nodeset (hwloc_topology_t topology, const void * addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)Bind the already-allocated memory identified by (addr, len) to the NUMA node(s) specified by nodeset.Returns: 0 if len is 0.
-1 with errno set to ENOSYS if the action is not supported -1 with errno set to EXDEV if the binding cannot be enforced int hwloc_set_membind (hwloc_topology_t topology, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)Set the default memory binding policy of the current process or thread to prefer the NUMA node(s) specified by set. If neither HWLOC_MEMBIND_PROCESS nor HWLOC_MEMBIND_THREAD is specified, the current process is assumed to be single-threaded. This is the most portable form as it permits hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available.If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset. Returns: -1 with errno set to ENOSYS if the action is not
supported
-1 with errno set to EXDEV if the binding cannot be enforced int hwloc_set_membind_nodeset (hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)Set the default memory binding policy of the current process or thread to prefer the NUMA node(s) specified by nodeset. If neither HWLOC_MEMBIND_PROCESS nor HWLOC_MEMBIND_THREAD is specified, the current process is assumed to be single-threaded. This is the most portable form as it permits hwloc to use either process-based OS functions or thread-based OS functions, depending on which are available.Returns: -1 with errno set to ENOSYS if the action is not
supported
-1 with errno set to EXDEV if the binding cannot be enforced int hwloc_set_proc_membind (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)Set the default memory binding policy of the specified process to prefer the NUMA node(s) specified by set. If HWLOC_MEMBIND_BYNODESET is specified, set is considered a nodeset. Otherwise it's a cpuset.Returns: -1 with errno set to ENOSYS if the action is not
supported
-1 with errno set to EXDEV if the binding cannot be enforced Note: hwloc_pid_t is pid_t on Unix platforms, and
HANDLE on native Windows platforms.
int hwloc_set_proc_membind_nodeset (hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)Set the default memory binding policy of the specified process to prefer the NUMA node(s) specified by nodeset.Returns: -1 with errno set to ENOSYS if the action is not
supported
-1 with errno set to EXDEV if the binding cannot be enforced Note: hwloc_pid_t is pid_t on Unix platforms, and
HANDLE on native Windows platforms.
AuthorGenerated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
Visit the GSP FreeBSD Man Page Interface. |