deprecated.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Copyright © 2009 CNRS
  3. * Copyright © 2009-2022 Inria. All rights reserved.
  4. * Copyright © 2009-2012 Université Bordeaux
  5. * Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
  6. * See COPYING in top-level directory.
  7. */
  8. /**
  9. * This file contains the inline code of functions declared in hwloc.h
  10. */
  11. #ifndef HWLOC_DEPRECATED_H
  12. #define HWLOC_DEPRECATED_H
  13. #ifndef HWLOC_H
  14. #error Please include the main hwloc.h instead
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /* backward compat with v2.0 before WHOLE_SYSTEM renaming */
  20. #define HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED
  21. /* backward compat with v1.11 before System removal */
  22. #define HWLOC_OBJ_SYSTEM HWLOC_OBJ_MACHINE
  23. /* backward compat with v1.10 before Socket->Package renaming */
  24. #define HWLOC_OBJ_SOCKET HWLOC_OBJ_PACKAGE
  25. /* backward compat with v1.10 before Node->NUMANode clarification */
  26. #define HWLOC_OBJ_NODE HWLOC_OBJ_NUMANODE
  27. /** \brief Add a distances structure.
  28. *
  29. * Superseded by hwloc_distances_add_create()+hwloc_distances_add_values()+hwloc_distances_add_commit()
  30. * in v2.5.
  31. */
  32. HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology,
  33. unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
  34. unsigned long kind, unsigned long flags) __hwloc_attribute_deprecated;
  35. /** \brief Insert a misc object by parent.
  36. *
  37. * Identical to hwloc_topology_insert_misc_object().
  38. */
  39. static __hwloc_inline hwloc_obj_t
  40. hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name) __hwloc_attribute_deprecated;
  41. static __hwloc_inline hwloc_obj_t
  42. hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name)
  43. {
  44. return hwloc_topology_insert_misc_object(topology, parent, name);
  45. }
  46. /** \brief Stringify the cpuset containing a set of objects.
  47. *
  48. * If \p size is 0, \p string may safely be \c NULL.
  49. *
  50. * \return the number of characters that were actually written if not truncating,
  51. * or that would have been written (not including the ending \\0).
  52. */
  53. static __hwloc_inline int
  54. hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs) __hwloc_attribute_deprecated;
  55. static __hwloc_inline int
  56. hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs)
  57. {
  58. hwloc_bitmap_t set = hwloc_bitmap_alloc();
  59. int res;
  60. unsigned i;
  61. hwloc_bitmap_zero(set);
  62. for(i=0; i<nobj; i++)
  63. if (objs[i]->cpuset)
  64. hwloc_bitmap_or(set, set, objs[i]->cpuset);
  65. res = hwloc_bitmap_snprintf(str, size, set);
  66. hwloc_bitmap_free(set);
  67. return res;
  68. }
  69. /** \brief Convert a type string into a type and some attributes.
  70. *
  71. * Deprecated by hwloc_type_sscanf()
  72. */
  73. static __hwloc_inline int
  74. hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize) __hwloc_attribute_deprecated;
  75. static __hwloc_inline int
  76. hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize)
  77. {
  78. union hwloc_obj_attr_u attr;
  79. int err = hwloc_type_sscanf(string, typep, &attr, sizeof(attr));
  80. if (err < 0)
  81. return err;
  82. if (hwloc_obj_type_is_cache(*typep)) {
  83. if (depthattrp)
  84. *depthattrp = (int) attr.cache.depth;
  85. if (typeattrp && typeattrsize >= sizeof(hwloc_obj_cache_type_t))
  86. memcpy(typeattrp, &attr.cache.type, sizeof(hwloc_obj_cache_type_t));
  87. } else if (*typep == HWLOC_OBJ_GROUP) {
  88. if (depthattrp)
  89. *depthattrp = (int) attr.group.depth;
  90. }
  91. return 0;
  92. }
  93. /** \brief Set the default memory binding policy of the current
  94. * process or thread to prefer the NUMA node(s) specified by physical \p nodeset
  95. */
  96. static __hwloc_inline int
  97. hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_deprecated;
  98. static __hwloc_inline int
  99. hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
  100. {
  101. return hwloc_set_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  102. }
  103. /** \brief Query the default memory binding policy and physical locality of the
  104. * current process or thread.
  105. */
  106. static __hwloc_inline int
  107. hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
  108. static __hwloc_inline int
  109. hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
  110. {
  111. return hwloc_get_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  112. }
  113. /** \brief Set the default memory binding policy of the specified
  114. * process to prefer the NUMA node(s) specified by physical \p nodeset
  115. */
  116. static __hwloc_inline int
  117. 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;
  118. static __hwloc_inline int
  119. 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)
  120. {
  121. return hwloc_set_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  122. }
  123. /** \brief Query the default memory binding policy and physical locality of the
  124. * specified process.
  125. */
  126. static __hwloc_inline int
  127. 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;
  128. static __hwloc_inline int
  129. hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
  130. {
  131. return hwloc_get_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  132. }
  133. /** \brief Bind the already-allocated memory identified by (addr, len)
  134. * to the NUMA node(s) in physical \p nodeset.
  135. */
  136. static __hwloc_inline int
  137. 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;
  138. static __hwloc_inline int
  139. 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)
  140. {
  141. return hwloc_set_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  142. }
  143. /** \brief Query the physical NUMA node(s) and binding policy of the memory
  144. * identified by (\p addr, \p len ).
  145. */
  146. static __hwloc_inline int
  147. 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;
  148. static __hwloc_inline int
  149. 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)
  150. {
  151. return hwloc_get_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  152. }
  153. /** \brief Allocate some memory on the given physical nodeset \p nodeset
  154. */
  155. static __hwloc_inline void *
  156. 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;
  157. static __hwloc_inline void *
  158. hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
  159. {
  160. return hwloc_alloc_membind(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  161. }
  162. /** \brief Allocate some memory on the given nodeset \p nodeset.
  163. */
  164. static __hwloc_inline void *
  165. 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;
  166. static __hwloc_inline void *
  167. hwloc_alloc_membind_policy_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
  168. {
  169. return hwloc_alloc_membind_policy(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
  170. }
  171. /** \brief Convert a CPU set into a NUMA node set and handle non-NUMA cases
  172. */
  173. static __hwloc_inline void
  174. hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset) __hwloc_attribute_deprecated;
  175. static __hwloc_inline void
  176. hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
  177. {
  178. hwloc_cpuset_to_nodeset(topology, _cpuset, nodeset);
  179. }
  180. /** \brief Convert a NUMA node set into a CPU set and handle non-NUMA cases
  181. */
  182. static __hwloc_inline void
  183. hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset) __hwloc_attribute_deprecated;
  184. static __hwloc_inline void
  185. hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
  186. {
  187. hwloc_cpuset_from_nodeset(topology, _cpuset, nodeset);
  188. }
  189. #ifdef __cplusplus
  190. } /* extern "C" */
  191. #endif
  192. #endif /* HWLOC_DEPRECATED_H */