Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:14:23

0001 /*
0002  * SPDX-License-Identifier: BSD-3-Clause
0003  * Copyright © 2009 CNRS
0004  * Copyright © 2009-2022 Inria.  All rights reserved.
0005  * Copyright © 2009-2012 Université Bordeaux
0006  * Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
0007  * See COPYING in top-level directory.
0008  */
0009 
0010 /**
0011  * This file contains the inline code of functions declared in hwloc.h
0012  */
0013 
0014 #ifndef HWLOC_DEPRECATED_H
0015 #define HWLOC_DEPRECATED_H
0016 
0017 #ifndef HWLOC_H
0018 #error Please include the main hwloc.h instead
0019 #endif
0020 
0021 #ifdef __cplusplus
0022 extern "C" {
0023 #endif
0024 
0025 /* backward compat with v2.0 before WHOLE_SYSTEM renaming */
0026 #define HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED
0027 /* backward compat with v1.11 before System removal */
0028 #define HWLOC_OBJ_SYSTEM HWLOC_OBJ_MACHINE
0029 /* backward compat with v1.10 before Socket->Package renaming */
0030 #define HWLOC_OBJ_SOCKET HWLOC_OBJ_PACKAGE
0031 /* backward compat with v1.10 before Node->NUMANode clarification */
0032 #define HWLOC_OBJ_NODE HWLOC_OBJ_NUMANODE
0033 
0034 /** \brief Add a distances structure.
0035  *
0036  * Superseded by hwloc_distances_add_create()+hwloc_distances_add_values()+hwloc_distances_add_commit()
0037  * in v2.5.
0038  */
0039 HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology,
0040                        unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
0041                        unsigned long kind, unsigned long flags) __hwloc_attribute_deprecated;
0042 
0043 /** \brief Insert a misc object by parent.
0044  *
0045  * Identical to hwloc_topology_insert_misc_object().
0046  */
0047 static __hwloc_inline hwloc_obj_t
0048 hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name) __hwloc_attribute_deprecated;
0049 static __hwloc_inline hwloc_obj_t
0050 hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name)
0051 {
0052   return hwloc_topology_insert_misc_object(topology, parent, name);
0053 }
0054 
0055 /** \brief Stringify the cpuset containing a set of objects.
0056  *
0057  * If \p size is 0, \p string may safely be \c NULL.
0058  *
0059  * \return the number of characters that were actually written if not truncating,
0060  * or that would have been written (not including the ending \\0).
0061  */
0062 static __hwloc_inline int
0063 hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs) __hwloc_attribute_deprecated;
0064 static __hwloc_inline int
0065 hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs)
0066 {
0067   hwloc_bitmap_t set = hwloc_bitmap_alloc();
0068   int res;
0069   unsigned i;
0070 
0071   hwloc_bitmap_zero(set);
0072   for(i=0; i<nobj; i++)
0073     if (objs[i]->cpuset)
0074       hwloc_bitmap_or(set, set, objs[i]->cpuset);
0075 
0076   res = hwloc_bitmap_snprintf(str, size, set);
0077   hwloc_bitmap_free(set);
0078   return res;
0079 }
0080 
0081 /** \brief Convert a type string into a type and some attributes.
0082  *
0083  * Deprecated by hwloc_type_sscanf()
0084  */
0085 static __hwloc_inline int
0086 hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize) __hwloc_attribute_deprecated;
0087 static __hwloc_inline int
0088 hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize)
0089 {
0090   union hwloc_obj_attr_u attr;
0091   int err = hwloc_type_sscanf(string, typep, &attr, sizeof(attr));
0092   if (err < 0)
0093     return err;
0094   if (hwloc_obj_type_is_cache(*typep)) {
0095     if (depthattrp)
0096       *depthattrp = (int) attr.cache.depth;
0097     if (typeattrp && typeattrsize >= sizeof(hwloc_obj_cache_type_t))
0098       memcpy(typeattrp, &attr.cache.type, sizeof(hwloc_obj_cache_type_t));
0099   } else if (*typep == HWLOC_OBJ_GROUP) {
0100     if (depthattrp)
0101       *depthattrp = (int) attr.group.depth;
0102   }
0103   return 0;
0104 }
0105 
0106 /** \brief Set the default memory binding policy of the current
0107  * process or thread to prefer the NUMA node(s) specified by physical \p nodeset
0108  */
0109 static __hwloc_inline int
0110 hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_deprecated;
0111 static __hwloc_inline int
0112 hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
0113 {
0114   return hwloc_set_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0115 }
0116 
0117 /** \brief Query the default memory binding policy and physical locality of the
0118  * current process or thread.
0119  */
0120 static __hwloc_inline int
0121 hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
0122 static __hwloc_inline int
0123 hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
0124 {
0125   return hwloc_get_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0126 }
0127 
0128 /** \brief Set the default memory binding policy of the specified
0129  * process to prefer the NUMA node(s) specified by physical \p nodeset
0130  */
0131 static __hwloc_inline int
0132 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) __hwloc_attribute_deprecated;
0133 static __hwloc_inline int
0134 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)
0135 {
0136   return hwloc_set_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0137 }
0138 
0139 /** \brief Query the default memory binding policy and physical locality of the
0140  * specified process.
0141  */
0142 static __hwloc_inline int
0143 hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
0144 static __hwloc_inline int
0145 hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
0146 {
0147   return hwloc_get_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0148 }
0149 
0150 /** \brief Bind the already-allocated memory identified by (addr, len)
0151  * to the NUMA node(s) in physical \p nodeset.
0152  */
0153 static __hwloc_inline int
0154 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) __hwloc_attribute_deprecated;
0155 static __hwloc_inline int
0156 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)
0157 {
0158   return hwloc_set_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0159 }
0160 
0161 /** \brief Query the physical NUMA node(s) and binding policy of the memory
0162  * identified by (\p addr, \p len ).
0163  */
0164 static __hwloc_inline int
0165 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) __hwloc_attribute_deprecated;
0166 static __hwloc_inline int
0167 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)
0168 {
0169   return hwloc_get_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0170 }
0171 
0172 /** \brief Allocate some memory on the given physical nodeset \p nodeset
0173  */
0174 static __hwloc_inline void *
0175 hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc __hwloc_attribute_deprecated;
0176 static __hwloc_inline void *
0177 hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
0178 {
0179   return hwloc_alloc_membind(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0180 }
0181 
0182 /** \brief Allocate some memory on the given nodeset \p nodeset.
0183  */
0184 static __hwloc_inline void *
0185 hwloc_alloc_membind_policy_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc __hwloc_attribute_deprecated;
0186 static __hwloc_inline void *
0187 hwloc_alloc_membind_policy_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
0188 {
0189   return hwloc_alloc_membind_policy(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
0190 }
0191 
0192 /** \brief Convert a CPU set into a NUMA node set and handle non-NUMA cases
0193  */
0194 static __hwloc_inline void
0195 hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset) __hwloc_attribute_deprecated;
0196 static __hwloc_inline void
0197 hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
0198 {
0199   hwloc_cpuset_to_nodeset(topology, _cpuset, nodeset);
0200 }
0201 
0202 /** \brief Convert a NUMA node set into a CPU set and handle non-NUMA cases
0203  */
0204 static __hwloc_inline void
0205 hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset) __hwloc_attribute_deprecated;
0206 static __hwloc_inline void
0207 hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
0208 {
0209   hwloc_cpuset_from_nodeset(topology, _cpuset, nodeset);
0210 }
0211 
0212 
0213 #ifdef __cplusplus
0214 } /* extern "C" */
0215 #endif
0216 
0217 
0218 #endif /* HWLOC_DEPRECATED_H */