Hardware Locality (hwloc)
v2.0-20191027.0400.gite37e7d8
|
00001 /* 00002 * Copyright © 2009 CNRS 00003 * Copyright © 2009-2018 Inria. All rights reserved. 00004 * Copyright © 2009-2012 Université Bordeaux 00005 * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. 00006 * See COPYING in top-level directory. 00007 */ 00008 00013 #ifndef HWLOC_BITMAP_H 00014 #define HWLOC_BITMAP_H 00015 00016 #include <hwloc/autogen/config.h> 00017 #include <assert.h> 00018 00019 00020 #ifdef __cplusplus 00021 extern "C" { 00022 #endif 00023 00024 00067 typedef struct hwloc_bitmap_s * hwloc_bitmap_t; 00069 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t; 00070 00071 00072 /* 00073 * Bitmap allocation, freeing and copying. 00074 */ 00075 00083 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc(void) __hwloc_attribute_malloc; 00084 00086 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc_full(void) __hwloc_attribute_malloc; 00087 00092 HWLOC_DECLSPEC void hwloc_bitmap_free(hwloc_bitmap_t bitmap); 00093 00098 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) __hwloc_attribute_malloc; 00099 00101 HWLOC_DECLSPEC int hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src); 00102 00103 00104 /* 00105 * Bitmap/String Conversion 00106 */ 00107 00117 HWLOC_DECLSPEC int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap); 00118 00123 HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap); 00124 00127 HWLOC_DECLSPEC int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string); 00128 00142 HWLOC_DECLSPEC int hwloc_bitmap_list_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap); 00143 00148 HWLOC_DECLSPEC int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap); 00149 00152 HWLOC_DECLSPEC int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string); 00153 00166 HWLOC_DECLSPEC int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap); 00167 00172 HWLOC_DECLSPEC int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap); 00173 00176 HWLOC_DECLSPEC int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string); 00177 00178 00179 /* 00180 * Building bitmaps. 00181 */ 00182 00184 HWLOC_DECLSPEC void hwloc_bitmap_zero(hwloc_bitmap_t bitmap); 00185 00187 HWLOC_DECLSPEC void hwloc_bitmap_fill(hwloc_bitmap_t bitmap); 00188 00190 HWLOC_DECLSPEC int hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id); 00191 00193 HWLOC_DECLSPEC int hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id); 00194 00196 HWLOC_DECLSPEC int hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask); 00197 00199 HWLOC_DECLSPEC int hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask); 00200 00201 00202 /* 00203 * Modifying bitmaps. 00204 */ 00205 00207 HWLOC_DECLSPEC int hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id); 00208 00213 HWLOC_DECLSPEC int hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end); 00214 00216 HWLOC_DECLSPEC int hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask); 00217 00219 HWLOC_DECLSPEC int hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id); 00220 00225 HWLOC_DECLSPEC int hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end); 00226 00246 HWLOC_DECLSPEC int hwloc_bitmap_singlify(hwloc_bitmap_t bitmap); 00247 00248 00249 /* 00250 * Consulting bitmaps. 00251 */ 00252 00254 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00255 00257 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) __hwloc_attribute_pure; 00258 00263 HWLOC_DECLSPEC int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) __hwloc_attribute_pure; 00264 00269 HWLOC_DECLSPEC int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00270 00277 HWLOC_DECLSPEC int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00278 00283 HWLOC_DECLSPEC int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00284 00291 HWLOC_DECLSPEC int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure; 00292 00297 HWLOC_DECLSPEC int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00298 00306 HWLOC_DECLSPEC int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00307 00312 HWLOC_DECLSPEC int hwloc_bitmap_first_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00313 00320 HWLOC_DECLSPEC int hwloc_bitmap_next_unset(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure; 00321 00326 HWLOC_DECLSPEC int hwloc_bitmap_last_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure; 00327 00343 #define hwloc_bitmap_foreach_begin(id, bitmap) \ 00344 do { \ 00345 assert(hwloc_bitmap_weight(bitmap) != -1); \ 00346 for (id = hwloc_bitmap_first(bitmap); \ 00347 (unsigned) id != (unsigned) -1; \ 00348 id = hwloc_bitmap_next(bitmap, id)) { 00349 00357 #define hwloc_bitmap_foreach_end() \ 00358 } \ 00359 } while (0) 00360 00361 00362 /* 00363 * Combining bitmaps. 00364 */ 00365 00370 HWLOC_DECLSPEC int hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2); 00371 00376 HWLOC_DECLSPEC int hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2); 00377 00382 HWLOC_DECLSPEC int hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2); 00383 00388 HWLOC_DECLSPEC int hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2); 00389 00394 HWLOC_DECLSPEC int hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap); 00395 00396 00397 /* 00398 * Comparing bitmaps. 00399 */ 00400 00405 HWLOC_DECLSPEC int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure; 00406 00413 HWLOC_DECLSPEC int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) __hwloc_attribute_pure; 00414 00419 HWLOC_DECLSPEC int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure; 00420 00438 HWLOC_DECLSPEC int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure; 00439 00457 HWLOC_DECLSPEC int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure; 00458 00462 #ifdef __cplusplus 00463 } /* extern "C" */ 00464 #endif 00465 00466 00467 #endif /* HWLOC_BITMAP_H */