Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.5.2

  |   Home   |   Support   |   FAQ   |  
bitmap.h
1 /*
2  * Copyright © 2009 CNRS
3  * Copyright © 2009-2011 inria. All rights reserved.
4  * Copyright © 2009-2012 Université Bordeaux 1
5  * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
6  * See COPYING in top-level directory.
7  */
8 
13 #ifndef HWLOC_BITMAP_H
14 #define HWLOC_BITMAP_H
15 
16 #include <hwloc/autogen/config.h>
17 #include <assert.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
45 typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
47 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
48 
49 
50 /*
51  * Bitmap allocation, freeing and copying.
52  */
53 
61  hwloc_bitmap_t hwloc_bitmap_alloc(void) ;
62 
64  hwloc_bitmap_t hwloc_bitmap_alloc_full(void) ;
65 
70  void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
71 
76  hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) ;
77 
79  void hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
80 
81 
82 /*
83  * Bitmap/String Conversion
84  */
85 
95  int hwloc_bitmap_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
96 
99  int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
100 
103  int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
104 
118  int hwloc_bitmap_list_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
119 
122  int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
123 
126  int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
127 
140  int hwloc_bitmap_taskset_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
141 
144  int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
145 
148  int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
149 
150 
151 /*
152  * Building bitmaps.
153  */
154 
156  void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
157 
159  void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
160 
162  void hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
163 
165  void hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
166 
168  void hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
169 
171  void hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
172 
173 
174 /*
175  * Modifying bitmaps.
176  */
177 
179  void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
180 
185  void hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
186 
188  void hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
189 
191  void hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
192 
197  void hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
198 
205  void hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
206 
207 
208 /*
209  * Consulting bitmaps.
210  */
211 
213  unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) ;
214 
216  unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) ;
217 
219  int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) ;
220 
222  int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) ;
223 
225  int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) ;
226 
231  int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) ;
232 
239  int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) ;
240 
245  int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) ;
246 
252  int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) ;
253 
265 #define hwloc_bitmap_foreach_begin(id, bitmap) \
266 do { \
267  assert(hwloc_bitmap_weight(bitmap) != -1); \
268  for (id = hwloc_bitmap_first(bitmap); \
269  (unsigned) id != (unsigned) -1; \
270  id = hwloc_bitmap_next(bitmap, id)) { \
271 
275 #define hwloc_bitmap_foreach_end() \
276  } \
277 } while (0)
278 
279 
280 /*
281  * Combining bitmaps.
282  */
283 
288  void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
289 
294  void hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
295 
300  void hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
301 
306  void hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
307 
312  void hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
313 
314 
315 /*
316  * Comparing bitmaps.
317  */
318 
320  int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
321 
323  int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) ;
324 
326  int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
327 
333  int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
334 
340  int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
341 
345 #ifdef __cplusplus
346 } /* extern "C" */
347 #endif
348 
349 
350 #endif /* HWLOC_BITMAP_H */