hwlocality_bitmap.3 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. .TH "hwlocality_bitmap" 3 "Thu Sep 7 2023" "Version 2.9.3" "Hardware Locality (hwloc)" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. hwlocality_bitmap \- The bitmap API
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Macros"
  10. .in +1c
  11. .ti -1c
  12. .RI "#define \fBhwloc_bitmap_foreach_begin\fP(id, bitmap)"
  13. .br
  14. .ti -1c
  15. .RI "#define \fBhwloc_bitmap_foreach_end\fP()"
  16. .br
  17. .in -1c
  18. .SS "Typedefs"
  19. .in +1c
  20. .ti -1c
  21. .RI "typedef struct hwloc_bitmap_s * \fBhwloc_bitmap_t\fP"
  22. .br
  23. .ti -1c
  24. .RI "typedef const struct hwloc_bitmap_s * \fBhwloc_const_bitmap_t\fP"
  25. .br
  26. .in -1c
  27. .SS "Functions"
  28. .in +1c
  29. .ti -1c
  30. .RI "\fBhwloc_bitmap_t\fP \fBhwloc_bitmap_alloc\fP (void)"
  31. .br
  32. .ti -1c
  33. .RI "\fBhwloc_bitmap_t\fP \fBhwloc_bitmap_alloc_full\fP (void)"
  34. .br
  35. .ti -1c
  36. .RI "void \fBhwloc_bitmap_free\fP (\fBhwloc_bitmap_t\fP bitmap)"
  37. .br
  38. .ti -1c
  39. .RI "\fBhwloc_bitmap_t\fP \fBhwloc_bitmap_dup\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  40. .br
  41. .ti -1c
  42. .RI "int \fBhwloc_bitmap_copy\fP (\fBhwloc_bitmap_t\fP dst, \fBhwloc_const_bitmap_t\fP src)"
  43. .br
  44. .ti -1c
  45. .RI "int \fBhwloc_bitmap_snprintf\fP (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  46. .br
  47. .ti -1c
  48. .RI "int \fBhwloc_bitmap_asprintf\fP (char **strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  49. .br
  50. .ti -1c
  51. .RI "int \fBhwloc_bitmap_sscanf\fP (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  52. .br
  53. .ti -1c
  54. .RI "int \fBhwloc_bitmap_list_snprintf\fP (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  55. .br
  56. .ti -1c
  57. .RI "int \fBhwloc_bitmap_list_asprintf\fP (char **strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  58. .br
  59. .ti -1c
  60. .RI "int \fBhwloc_bitmap_list_sscanf\fP (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  61. .br
  62. .ti -1c
  63. .RI "int \fBhwloc_bitmap_taskset_snprintf\fP (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  64. .br
  65. .ti -1c
  66. .RI "int \fBhwloc_bitmap_taskset_asprintf\fP (char **strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  67. .br
  68. .ti -1c
  69. .RI "int \fBhwloc_bitmap_taskset_sscanf\fP (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  70. .br
  71. .ti -1c
  72. .RI "void \fBhwloc_bitmap_zero\fP (\fBhwloc_bitmap_t\fP bitmap)"
  73. .br
  74. .ti -1c
  75. .RI "void \fBhwloc_bitmap_fill\fP (\fBhwloc_bitmap_t\fP bitmap)"
  76. .br
  77. .ti -1c
  78. .RI "int \fBhwloc_bitmap_only\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  79. .br
  80. .ti -1c
  81. .RI "int \fBhwloc_bitmap_allbut\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  82. .br
  83. .ti -1c
  84. .RI "int \fBhwloc_bitmap_from_ulong\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned long mask)"
  85. .br
  86. .ti -1c
  87. .RI "int \fBhwloc_bitmap_from_ith_ulong\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned i, unsigned long mask)"
  88. .br
  89. .ti -1c
  90. .RI "int \fBhwloc_bitmap_from_ulongs\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned nr, const unsigned long *masks)"
  91. .br
  92. .ti -1c
  93. .RI "int \fBhwloc_bitmap_set\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  94. .br
  95. .ti -1c
  96. .RI "int \fBhwloc_bitmap_set_range\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned begin, int end)"
  97. .br
  98. .ti -1c
  99. .RI "int \fBhwloc_bitmap_set_ith_ulong\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned i, unsigned long mask)"
  100. .br
  101. .ti -1c
  102. .RI "int \fBhwloc_bitmap_clr\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  103. .br
  104. .ti -1c
  105. .RI "int \fBhwloc_bitmap_clr_range\fP (\fBhwloc_bitmap_t\fP bitmap, unsigned begin, int end)"
  106. .br
  107. .ti -1c
  108. .RI "int \fBhwloc_bitmap_singlify\fP (\fBhwloc_bitmap_t\fP bitmap)"
  109. .br
  110. .ti -1c
  111. .RI "unsigned long \fBhwloc_bitmap_to_ulong\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  112. .br
  113. .ti -1c
  114. .RI "unsigned long \fBhwloc_bitmap_to_ith_ulong\fP (\fBhwloc_const_bitmap_t\fP bitmap, unsigned i)"
  115. .br
  116. .ti -1c
  117. .RI "int \fBhwloc_bitmap_to_ulongs\fP (\fBhwloc_const_bitmap_t\fP bitmap, unsigned nr, unsigned long *masks)"
  118. .br
  119. .ti -1c
  120. .RI "int \fBhwloc_bitmap_nr_ulongs\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  121. .br
  122. .ti -1c
  123. .RI "int \fBhwloc_bitmap_isset\fP (\fBhwloc_const_bitmap_t\fP bitmap, unsigned id)"
  124. .br
  125. .ti -1c
  126. .RI "int \fBhwloc_bitmap_iszero\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  127. .br
  128. .ti -1c
  129. .RI "int \fBhwloc_bitmap_isfull\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  130. .br
  131. .ti -1c
  132. .RI "int \fBhwloc_bitmap_first\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  133. .br
  134. .ti -1c
  135. .RI "int \fBhwloc_bitmap_next\fP (\fBhwloc_const_bitmap_t\fP bitmap, int prev)"
  136. .br
  137. .ti -1c
  138. .RI "int \fBhwloc_bitmap_last\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  139. .br
  140. .ti -1c
  141. .RI "int \fBhwloc_bitmap_weight\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  142. .br
  143. .ti -1c
  144. .RI "int \fBhwloc_bitmap_first_unset\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  145. .br
  146. .ti -1c
  147. .RI "int \fBhwloc_bitmap_next_unset\fP (\fBhwloc_const_bitmap_t\fP bitmap, int prev)"
  148. .br
  149. .ti -1c
  150. .RI "int \fBhwloc_bitmap_last_unset\fP (\fBhwloc_const_bitmap_t\fP bitmap)"
  151. .br
  152. .ti -1c
  153. .RI "int \fBhwloc_bitmap_or\fP (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  154. .br
  155. .ti -1c
  156. .RI "int \fBhwloc_bitmap_and\fP (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  157. .br
  158. .ti -1c
  159. .RI "int \fBhwloc_bitmap_andnot\fP (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  160. .br
  161. .ti -1c
  162. .RI "int \fBhwloc_bitmap_xor\fP (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  163. .br
  164. .ti -1c
  165. .RI "int \fBhwloc_bitmap_not\fP (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap)"
  166. .br
  167. .ti -1c
  168. .RI "int \fBhwloc_bitmap_intersects\fP (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  169. .br
  170. .ti -1c
  171. .RI "int \fBhwloc_bitmap_isincluded\fP (\fBhwloc_const_bitmap_t\fP sub_bitmap, \fBhwloc_const_bitmap_t\fP super_bitmap)"
  172. .br
  173. .ti -1c
  174. .RI "int \fBhwloc_bitmap_isequal\fP (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  175. .br
  176. .ti -1c
  177. .RI "int \fBhwloc_bitmap_compare_first\fP (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  178. .br
  179. .ti -1c
  180. .RI "int \fBhwloc_bitmap_compare\fP (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  181. .br
  182. .in -1c
  183. .SH "Detailed Description"
  184. .PP
  185. The \fBhwloc_bitmap_t\fP type represents a set of integers (positive or null)\&. A bitmap may be of infinite size (all bits are set after some point)\&. A bitmap may even be full if all bits are set\&.
  186. .PP
  187. Bitmaps are used by hwloc for sets of OS processors (which may actually be hardware threads) as by \fBhwloc_cpuset_t\fP (a typedef for \fBhwloc_bitmap_t\fP), or sets of NUMA memory nodes as \fBhwloc_nodeset_t\fP (also a typedef for \fBhwloc_bitmap_t\fP)\&. Those are used for cpuset and nodeset fields in the \fBhwloc_obj\fP structure, see \fBObject Sets (hwloc_cpuset_t and hwloc_nodeset_t)\fP\&.
  188. .PP
  189. \fIBoth CPU and node sets are always indexed by OS physical number\&.\fP However users should usually not build CPU and node sets manually (e\&.g\&. with \fBhwloc_bitmap_set()\fP)\&. One should rather use existing object sets and combine them with \fBhwloc_bitmap_or()\fP, etc\&. For instance, binding the current thread on a pair of cores may be performed with:
  190. .PP
  191. .nf
  192. hwloc_obj_t core1 = \&.\&.\&. , core2 = \&.\&.\&. ;
  193. hwloc_bitmap_t set = hwloc_bitmap_alloc();
  194. hwloc_bitmap_or(set, core1->cpuset, core2->cpuset);
  195. hwloc_set_cpubind(topology, set, HWLOC_CPUBIND_THREAD);
  196. hwloc_bitmap_free(set);
  197. .fi
  198. .PP
  199. .PP
  200. \fBNote\fP
  201. .RS 4
  202. Most functions below return 0 on success and -1 on error\&. The usual error case would be an internal failure to realloc/extend the storage of the bitmap (\fCerrno\fP would be set to \fCENOMEM\fP)\&. See also \fBError reporting in the API\fP\&.
  203. .PP
  204. Several examples of using the bitmap API are available under the doc/examples/ directory in the source tree\&. Regression tests such as tests/hwloc/hwloc_bitmap*\&.c also make intensive use of this API\&.
  205. .RE
  206. .PP
  207. .SH "Macro Definition Documentation"
  208. .PP
  209. .SS "#define hwloc_bitmap_foreach_begin(id, bitmap)"
  210. .PP
  211. Loop macro iterating on bitmap \fCbitmap\fP\&. The loop must start with \fBhwloc_bitmap_foreach_begin()\fP and end with \fBhwloc_bitmap_foreach_end()\fP followed by a terminating ';'\&.
  212. .PP
  213. \fCid\fP is the loop variable; it should be an unsigned int\&. The first iteration will set \fCid\fP to the lowest index in the bitmap\&. Successive iterations will iterate through, in order, all remaining indexes set in the bitmap\&. To be specific: each iteration will return a value for \fCid\fP such that hwloc_bitmap_isset(bitmap, id) is true\&.
  214. .PP
  215. The assert prevents the loop from being infinite if the bitmap is infinitely set\&.
  216. .SS "#define hwloc_bitmap_foreach_end()"
  217. .PP
  218. End of loop macro iterating on a bitmap\&. Needs a terminating ';'\&.
  219. .PP
  220. \fBSee also\fP
  221. .RS 4
  222. \fBhwloc_bitmap_foreach_begin()\fP
  223. .RE
  224. .PP
  225. .SH "Typedef Documentation"
  226. .PP
  227. .SS "typedef struct hwloc_bitmap_s* \fBhwloc_bitmap_t\fP"
  228. .PP
  229. Set of bits represented as an opaque pointer to an internal bitmap\&.
  230. .SS "typedef const struct hwloc_bitmap_s* \fBhwloc_const_bitmap_t\fP"
  231. .PP
  232. a non-modifiable \fBhwloc_bitmap_t\fP
  233. .SH "Function Documentation"
  234. .PP
  235. .SS "int hwloc_bitmap_allbut (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  236. .PP
  237. Fill the bitmap \fCand\fP clear the index \fCid\fP\&.
  238. .SS "\fBhwloc_bitmap_t\fP hwloc_bitmap_alloc (void)"
  239. .PP
  240. Allocate a new empty bitmap\&.
  241. .PP
  242. \fBReturns\fP
  243. .RS 4
  244. A valid bitmap or \fCNULL\fP\&.
  245. .RE
  246. .PP
  247. The bitmap should be freed by a corresponding call to \fBhwloc_bitmap_free()\fP\&.
  248. .SS "\fBhwloc_bitmap_t\fP hwloc_bitmap_alloc_full (void)"
  249. .PP
  250. Allocate a new full bitmap\&.
  251. .PP
  252. \fBReturns\fP
  253. .RS 4
  254. A valid bitmap or \fCNULL\fP\&.
  255. .RE
  256. .PP
  257. The bitmap should be freed by a corresponding call to \fBhwloc_bitmap_free()\fP\&.
  258. .SS "int hwloc_bitmap_and (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  259. .PP
  260. And bitmaps \fCbitmap1\fP and \fCbitmap2\fP and store the result in bitmap \fCres\fP\&. \fCres\fP can be the same as \fCbitmap1\fP or \fCbitmap2\fP
  261. .SS "int hwloc_bitmap_andnot (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  262. .PP
  263. And bitmap \fCbitmap1\fP and the negation of \fCbitmap2\fP and store the result in bitmap \fCres\fP\&. \fCres\fP can be the same as \fCbitmap1\fP or \fCbitmap2\fP
  264. .SS "int hwloc_bitmap_asprintf (char ** strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  265. .PP
  266. Stringify a bitmap into a newly allocated string\&.
  267. .PP
  268. \fBReturns\fP
  269. .RS 4
  270. 0 on success, -1 on error\&.
  271. .RE
  272. .PP
  273. .SS "int hwloc_bitmap_clr (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  274. .PP
  275. Remove index \fCid\fP from bitmap \fCbitmap\fP\&.
  276. .SS "int hwloc_bitmap_clr_range (\fBhwloc_bitmap_t\fP bitmap, unsigned begin, int end)"
  277. .PP
  278. Remove indexes from \fCbegin\fP to \fCend\fP in bitmap \fCbitmap\fP\&. If \fCend\fP is \fC-1\fP, the range is infinite\&.
  279. .SS "int hwloc_bitmap_compare (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  280. .PP
  281. Compare bitmaps \fCbitmap1\fP and \fCbitmap2\fP in lexicographic order\&. Lexicographic comparison of bitmaps, starting for their highest indexes\&. Compare last indexes first, then second, etc\&. The empty bitmap is considered lower than anything\&.
  282. .PP
  283. \fBReturns\fP
  284. .RS 4
  285. -1 if \fCbitmap1\fP is considered smaller than \fCbitmap2\fP\&.
  286. .PP
  287. 1 if \fCbitmap1\fP is considered larger than \fCbitmap2\fP\&.
  288. .PP
  289. 0 if bitmaps are equal (contrary to \fBhwloc_bitmap_compare_first()\fP)\&.
  290. .RE
  291. .PP
  292. For instance comparing binary bitmaps 0011 and 0110 returns -1 (hence 0011 is considered smaller than 0110)\&. Comparing 00101 and 01010 returns -1 too\&.
  293. .PP
  294. \fBNote\fP
  295. .RS 4
  296. This is different from the non-existing hwloc_bitmap_compare_last() which would only compare the highest index of each bitmap\&.
  297. .RE
  298. .PP
  299. .SS "int hwloc_bitmap_compare_first (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  300. .PP
  301. Compare bitmaps \fCbitmap1\fP and \fCbitmap2\fP using their lowest index\&. A bitmap is considered smaller if its least significant bit is smaller\&. The empty bitmap is considered higher than anything (because its least significant bit does not exist)\&.
  302. .PP
  303. \fBReturns\fP
  304. .RS 4
  305. -1 if \fCbitmap1\fP is considered smaller than \fCbitmap2\fP\&.
  306. .PP
  307. 1 if \fCbitmap1\fP is considered larger than \fCbitmap2\fP\&.
  308. .RE
  309. .PP
  310. For instance comparing binary bitmaps 0011 and 0110 returns -1 (hence 0011 is considered smaller than 0110) because least significant bit of 0011 (0001) is smaller than least significant bit of 0110 (0010)\&. Comparing 01001 and 00110 would also return -1 for the same reason\&.
  311. .PP
  312. \fBReturns\fP
  313. .RS 4
  314. 0 if bitmaps are considered equal, even if they are not strictly equal\&. They just need to have the same least significant bit\&. For instance, comparing binary bitmaps 0010 and 0110 returns 0 because they have the same least significant bit\&.
  315. .RE
  316. .PP
  317. .SS "int hwloc_bitmap_copy (\fBhwloc_bitmap_t\fP dst, \fBhwloc_const_bitmap_t\fP src)"
  318. .PP
  319. Copy the contents of bitmap \fCsrc\fP into the already allocated bitmap \fCdst\fP\&.
  320. .SS "\fBhwloc_bitmap_t\fP hwloc_bitmap_dup (\fBhwloc_const_bitmap_t\fP bitmap)"
  321. .PP
  322. Duplicate bitmap \fCbitmap\fP by allocating a new bitmap and copying \fCbitmap\fP contents\&. If \fCbitmap\fP is \fCNULL\fP, \fCNULL\fP is returned\&.
  323. .SS "void hwloc_bitmap_fill (\fBhwloc_bitmap_t\fP bitmap)"
  324. .PP
  325. Fill bitmap \fCbitmap\fP with all possible indexes (even if those objects don't exist or are otherwise unavailable)
  326. .SS "int hwloc_bitmap_first (\fBhwloc_const_bitmap_t\fP bitmap)"
  327. .PP
  328. Compute the first index (least significant bit) in bitmap \fCbitmap\fP\&.
  329. .PP
  330. \fBReturns\fP
  331. .RS 4
  332. the first index set in \fCbitmap\fP\&.
  333. .PP
  334. -1 if \fCbitmap\fP is empty\&.
  335. .RE
  336. .PP
  337. .SS "int hwloc_bitmap_first_unset (\fBhwloc_const_bitmap_t\fP bitmap)"
  338. .PP
  339. Compute the first unset index (least significant bit) in bitmap \fCbitmap\fP\&.
  340. .PP
  341. \fBReturns\fP
  342. .RS 4
  343. the first unset index in \fCbitmap\fP\&.
  344. .PP
  345. -1 if \fCbitmap\fP is full\&.
  346. .RE
  347. .PP
  348. .SS "void hwloc_bitmap_free (\fBhwloc_bitmap_t\fP bitmap)"
  349. .PP
  350. Free bitmap \fCbitmap\fP\&. If \fCbitmap\fP is \fCNULL\fP, no operation is performed\&.
  351. .SS "int hwloc_bitmap_from_ith_ulong (\fBhwloc_bitmap_t\fP bitmap, unsigned i, unsigned long mask)"
  352. .PP
  353. Setup bitmap \fCbitmap\fP from unsigned long \fCmask\fP used as \fCi\fP -th subset\&.
  354. .SS "int hwloc_bitmap_from_ulong (\fBhwloc_bitmap_t\fP bitmap, unsigned long mask)"
  355. .PP
  356. Setup bitmap \fCbitmap\fP from unsigned long \fCmask\fP\&.
  357. .SS "int hwloc_bitmap_from_ulongs (\fBhwloc_bitmap_t\fP bitmap, unsigned nr, const unsigned long * masks)"
  358. .PP
  359. Setup bitmap \fCbitmap\fP from unsigned longs \fCmasks\fP used as first \fCnr\fP subsets\&.
  360. .SS "int hwloc_bitmap_intersects (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  361. .PP
  362. Test whether bitmaps \fCbitmap1\fP and \fCbitmap2\fP intersects\&.
  363. .PP
  364. \fBReturns\fP
  365. .RS 4
  366. 1 if bitmaps intersect, 0 otherwise\&.
  367. .RE
  368. .PP
  369. \fBNote\fP
  370. .RS 4
  371. The empty bitmap does not intersect any other bitmap\&.
  372. .RE
  373. .PP
  374. .SS "int hwloc_bitmap_isequal (\fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  375. .PP
  376. Test whether bitmap \fCbitmap1\fP is equal to bitmap \fCbitmap2\fP\&.
  377. .PP
  378. \fBReturns\fP
  379. .RS 4
  380. 1 if bitmaps are equal, 0 otherwise\&.
  381. .RE
  382. .PP
  383. .SS "int hwloc_bitmap_isfull (\fBhwloc_const_bitmap_t\fP bitmap)"
  384. .PP
  385. Test whether bitmap \fCbitmap\fP is completely full\&.
  386. .PP
  387. \fBReturns\fP
  388. .RS 4
  389. 1 if bitmap is full, 0 otherwise\&.
  390. .RE
  391. .PP
  392. \fBNote\fP
  393. .RS 4
  394. A full bitmap is always infinitely set\&.
  395. .RE
  396. .PP
  397. .SS "int hwloc_bitmap_isincluded (\fBhwloc_const_bitmap_t\fP sub_bitmap, \fBhwloc_const_bitmap_t\fP super_bitmap)"
  398. .PP
  399. Test whether bitmap \fCsub_bitmap\fP is part of bitmap \fCsuper_bitmap\fP\&.
  400. .PP
  401. \fBReturns\fP
  402. .RS 4
  403. 1 if \fCsub_bitmap\fP is included in \fCsuper_bitmap\fP, 0 otherwise\&.
  404. .RE
  405. .PP
  406. \fBNote\fP
  407. .RS 4
  408. The empty bitmap is considered included in any other bitmap\&.
  409. .RE
  410. .PP
  411. .SS "int hwloc_bitmap_isset (\fBhwloc_const_bitmap_t\fP bitmap, unsigned id)"
  412. .PP
  413. Test whether index \fCid\fP is part of bitmap \fCbitmap\fP\&.
  414. .PP
  415. \fBReturns\fP
  416. .RS 4
  417. 1 if the bit at index \fCid\fP is set in bitmap \fCbitmap\fP, 0 otherwise\&.
  418. .RE
  419. .PP
  420. .SS "int hwloc_bitmap_iszero (\fBhwloc_const_bitmap_t\fP bitmap)"
  421. .PP
  422. Test whether bitmap \fCbitmap\fP is empty\&.
  423. .PP
  424. \fBReturns\fP
  425. .RS 4
  426. 1 if bitmap is empty, 0 otherwise\&.
  427. .RE
  428. .PP
  429. .SS "int hwloc_bitmap_last (\fBhwloc_const_bitmap_t\fP bitmap)"
  430. .PP
  431. Compute the last index (most significant bit) in bitmap \fCbitmap\fP\&.
  432. .PP
  433. \fBReturns\fP
  434. .RS 4
  435. the last index set in \fCbitmap\fP\&.
  436. .PP
  437. -1 if \fCbitmap\fP is empty, or if \fCbitmap\fP is infinitely set\&.
  438. .RE
  439. .PP
  440. .SS "int hwloc_bitmap_last_unset (\fBhwloc_const_bitmap_t\fP bitmap)"
  441. .PP
  442. Compute the last unset index (most significant bit) in bitmap \fCbitmap\fP\&.
  443. .PP
  444. \fBReturns\fP
  445. .RS 4
  446. the last index unset in \fCbitmap\fP\&.
  447. .PP
  448. -1 if \fCbitmap\fP is full, or if \fCbitmap\fP is not infinitely set\&.
  449. .RE
  450. .PP
  451. .SS "int hwloc_bitmap_list_asprintf (char ** strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  452. .PP
  453. Stringify a bitmap into a newly allocated list string\&.
  454. .PP
  455. \fBReturns\fP
  456. .RS 4
  457. 0 on success, -1 on error\&.
  458. .RE
  459. .PP
  460. .SS "int hwloc_bitmap_list_snprintf (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  461. .PP
  462. Stringify a bitmap in the list format\&. Lists are comma-separated indexes or ranges\&. Ranges are dash separated indexes\&. The last range may not have an ending indexes if the bitmap is infinitely set\&.
  463. .PP
  464. Up to \fCbuflen\fP characters may be written in buffer \fCbuf\fP\&.
  465. .PP
  466. If \fCbuflen\fP is 0, \fCbuf\fP may safely be \fCNULL\fP\&.
  467. .PP
  468. \fBReturns\fP
  469. .RS 4
  470. the number of characters that were actually written if not truncating, or that would have been written (not including the ending \\0)\&.
  471. .RE
  472. .PP
  473. .SS "int hwloc_bitmap_list_sscanf (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  474. .PP
  475. Parse a list string and stores it in bitmap \fCbitmap\fP\&.
  476. .PP
  477. \fBReturns\fP
  478. .RS 4
  479. 0 on success, -1 on error\&.
  480. .RE
  481. .PP
  482. .SS "int hwloc_bitmap_next (\fBhwloc_const_bitmap_t\fP bitmap, int prev)"
  483. .PP
  484. Compute the next index in bitmap \fCbitmap\fP which is after index \fCprev\fP\&.
  485. .PP
  486. \fBReturns\fP
  487. .RS 4
  488. the first index set in \fCbitmap\fP if \fCprev\fP is \fC-1\fP\&.
  489. .PP
  490. the next index set in \fCbitmap\fP if \fCprev\fP is not \fC-1\fP\&.
  491. .PP
  492. -1 if no index with higher index is set in \fCbitmap\fP\&.
  493. .RE
  494. .PP
  495. .SS "int hwloc_bitmap_next_unset (\fBhwloc_const_bitmap_t\fP bitmap, int prev)"
  496. .PP
  497. Compute the next unset index in bitmap \fCbitmap\fP which is after index \fCprev\fP\&.
  498. .PP
  499. \fBReturns\fP
  500. .RS 4
  501. the first index unset in \fCbitmap\fP if \fCprev\fP is \fC-1\fP\&.
  502. .PP
  503. the next index unset in \fCbitmap\fP if \fCprev\fP is not \fC-1\fP\&.
  504. .PP
  505. -1 if no index with higher index is unset in \fCbitmap\fP\&.
  506. .RE
  507. .PP
  508. .SS "int hwloc_bitmap_not (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap)"
  509. .PP
  510. Negate bitmap \fCbitmap\fP and store the result in bitmap \fCres\fP\&. \fCres\fP can be the same as \fCbitmap\fP
  511. .SS "int hwloc_bitmap_nr_ulongs (\fBhwloc_const_bitmap_t\fP bitmap)"
  512. .PP
  513. Return the number of unsigned longs required for storing bitmap \fCbitmap\fP entirely\&. This is the number of contiguous unsigned longs from the very first bit of the bitmap (even if unset) up to the last set bit\&. This is useful for knowing the \fCnr\fP parameter to pass to \fBhwloc_bitmap_to_ulongs()\fP (or which calls to \fBhwloc_bitmap_to_ith_ulong()\fP are needed) to entirely convert a bitmap into multiple unsigned longs\&.
  514. .PP
  515. When called on the output of \fBhwloc_topology_get_topology_cpuset()\fP, the returned number is large enough for all cpusets of the topology\&.
  516. .PP
  517. \fBReturns\fP
  518. .RS 4
  519. the number of unsigned longs required\&.
  520. .PP
  521. -1 if \fCbitmap\fP is infinite\&.
  522. .RE
  523. .PP
  524. .SS "int hwloc_bitmap_only (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  525. .PP
  526. Empty the bitmap \fCbitmap\fP and add bit \fCid\fP\&.
  527. .SS "int hwloc_bitmap_or (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  528. .PP
  529. Or bitmaps \fCbitmap1\fP and \fCbitmap2\fP and store the result in bitmap \fCres\fP\&. \fCres\fP can be the same as \fCbitmap1\fP or \fCbitmap2\fP
  530. .SS "int hwloc_bitmap_set (\fBhwloc_bitmap_t\fP bitmap, unsigned id)"
  531. .PP
  532. Add index \fCid\fP in bitmap \fCbitmap\fP\&.
  533. .SS "int hwloc_bitmap_set_ith_ulong (\fBhwloc_bitmap_t\fP bitmap, unsigned i, unsigned long mask)"
  534. .PP
  535. Replace \fCi\fP -th subset of bitmap \fCbitmap\fP with unsigned long \fCmask\fP\&.
  536. .SS "int hwloc_bitmap_set_range (\fBhwloc_bitmap_t\fP bitmap, unsigned begin, int end)"
  537. .PP
  538. Add indexes from \fCbegin\fP to \fCend\fP in bitmap \fCbitmap\fP\&. If \fCend\fP is \fC-1\fP, the range is infinite\&.
  539. .SS "int hwloc_bitmap_singlify (\fBhwloc_bitmap_t\fP bitmap)"
  540. .PP
  541. Keep a single index among those set in bitmap \fCbitmap\fP\&. May be useful before binding so that the process does not have a chance of migrating between multiple processors in the original mask\&. Instead of running the task on any PU inside the given CPU set, the operating system scheduler will be forced to run it on a single of these PUs\&. It avoids a migration overhead and cache-line ping-pongs between PUs\&.
  542. .PP
  543. \fBNote\fP
  544. .RS 4
  545. This function is NOT meant to distribute multiple processes within a single CPU set\&. It always return the same single bit when called multiple times on the same input set\&. \fBhwloc_distrib()\fP may be used for generating CPU sets to distribute multiple tasks below a single multi-PU object\&.
  546. .PP
  547. This function cannot be applied to an object set directly\&. It should be applied to a copy (which may be obtained with \fBhwloc_bitmap_dup()\fP)\&.
  548. .RE
  549. .PP
  550. .SS "int hwloc_bitmap_snprintf (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  551. .PP
  552. Stringify a bitmap\&. Up to \fCbuflen\fP characters may be written in buffer \fCbuf\fP\&.
  553. .PP
  554. If \fCbuflen\fP is 0, \fCbuf\fP may safely be \fCNULL\fP\&.
  555. .PP
  556. \fBReturns\fP
  557. .RS 4
  558. the number of characters that were actually written if not truncating, or that would have been written (not including the ending \\0)\&.
  559. .RE
  560. .PP
  561. .SS "int hwloc_bitmap_sscanf (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  562. .PP
  563. Parse a bitmap string and stores it in bitmap \fCbitmap\fP\&.
  564. .PP
  565. \fBReturns\fP
  566. .RS 4
  567. 0 on success, -1 on error\&.
  568. .RE
  569. .PP
  570. .SS "int hwloc_bitmap_taskset_asprintf (char ** strp, \fBhwloc_const_bitmap_t\fP bitmap)"
  571. .PP
  572. Stringify a bitmap into a newly allocated taskset-specific string\&.
  573. .PP
  574. \fBReturns\fP
  575. .RS 4
  576. 0 on success, -1 on error\&.
  577. .RE
  578. .PP
  579. .SS "int hwloc_bitmap_taskset_snprintf (char *restrict buf, size_t buflen, \fBhwloc_const_bitmap_t\fP bitmap)"
  580. .PP
  581. Stringify a bitmap in the taskset-specific format\&. The taskset command manipulates bitmap strings that contain a single (possible very long) hexadecimal number starting with 0x\&.
  582. .PP
  583. Up to \fCbuflen\fP characters may be written in buffer \fCbuf\fP\&.
  584. .PP
  585. If \fCbuflen\fP is 0, \fCbuf\fP may safely be \fCNULL\fP\&.
  586. .PP
  587. \fBReturns\fP
  588. .RS 4
  589. the number of characters that were actually written if not truncating, or that would have been written (not including the ending \\0)\&.
  590. .RE
  591. .PP
  592. .SS "int hwloc_bitmap_taskset_sscanf (\fBhwloc_bitmap_t\fP bitmap, const char *restrict string)"
  593. .PP
  594. Parse a taskset-specific bitmap string and stores it in bitmap \fCbitmap\fP\&.
  595. .PP
  596. \fBReturns\fP
  597. .RS 4
  598. 0 on success, -1 on error\&.
  599. .RE
  600. .PP
  601. .SS "unsigned long hwloc_bitmap_to_ith_ulong (\fBhwloc_const_bitmap_t\fP bitmap, unsigned i)"
  602. .PP
  603. Convert the \fCi\fP -th subset of bitmap \fCbitmap\fP into unsigned long mask\&.
  604. .SS "unsigned long hwloc_bitmap_to_ulong (\fBhwloc_const_bitmap_t\fP bitmap)"
  605. .PP
  606. Convert the beginning part of bitmap \fCbitmap\fP into unsigned long \fCmask\fP\&.
  607. .SS "int hwloc_bitmap_to_ulongs (\fBhwloc_const_bitmap_t\fP bitmap, unsigned nr, unsigned long * masks)"
  608. .PP
  609. Convert the first \fCnr\fP subsets of bitmap \fCbitmap\fP into the array of \fCnr\fP unsigned long \fCmasks\fP\&. \fCnr\fP may be determined earlier with \fBhwloc_bitmap_nr_ulongs()\fP\&.
  610. .PP
  611. \fBReturns\fP
  612. .RS 4
  613. 0
  614. .RE
  615. .PP
  616. .SS "int hwloc_bitmap_weight (\fBhwloc_const_bitmap_t\fP bitmap)"
  617. .PP
  618. Compute the 'weight' of bitmap \fCbitmap\fP (i\&.e\&., number of indexes that are in the bitmap)\&.
  619. .PP
  620. \fBReturns\fP
  621. .RS 4
  622. the number of indexes that are in the bitmap\&.
  623. .PP
  624. -1 if \fCbitmap\fP is infinitely set\&.
  625. .RE
  626. .PP
  627. .SS "int hwloc_bitmap_xor (\fBhwloc_bitmap_t\fP res, \fBhwloc_const_bitmap_t\fP bitmap1, \fBhwloc_const_bitmap_t\fP bitmap2)"
  628. .PP
  629. Xor bitmaps \fCbitmap1\fP and \fCbitmap2\fP and store the result in bitmap \fCres\fP\&. \fCres\fP can be the same as \fCbitmap1\fP or \fCbitmap2\fP
  630. .SS "void hwloc_bitmap_zero (\fBhwloc_bitmap_t\fP bitmap)"
  631. .PP
  632. Empty the bitmap \fCbitmap\fP\&.
  633. .SH "Author"
  634. .PP
  635. Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code\&.