Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:15

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