Hardware Locality (hwloc): bitmap.h Source File

Hardware Locality (hwloc) 1.2.2

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List

bitmap.h

    00001 /*
    00002  * Copyright © 2009 CNRS
    00003  * Copyright © 2009-2011 INRIA.  All rights reserved.
    00004  * Copyright © 2009-2011 Université Bordeaux 1
    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
    00045 typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
    00047 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
    00048
    00049
    00050 /*
    00051  * Bitmap allocation, freeing and copying.
    00052  */
    00053
    00061  hwloc_bitmap_t hwloc_bitmap_alloc(void) ;
    00062
    00064  hwloc_bitmap_t hwloc_bitmap_alloc_full(void) ;
    00065
    00070  void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
    00071
    00076  hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) ;
    00077
    00079  void hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
    00080
    00081
    00082 /*
    00083  * Bitmap/String Conversion
    00084  */
    00085
    00095  int hwloc_bitmap_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
    00096
    00099  int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
    00100
    00103  int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
    00104
    00118  int hwloc_bitmap_list_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
    00119
    00122  int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
    00123
    00126  int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
    00127
    00140  int hwloc_bitmap_taskset_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
    00141
    00144  int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
    00145
    00148  int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
    00149
    00150
    00151 /*
    00152  * Building bitmaps.
    00153  */
    00154
    00156  void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
    00157
    00159  void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
    00160
    00162  void hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
    00163
    00165  void hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
    00166
    00168  void hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
    00169
    00171  void hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
    00172
    00173
    00174 /*
    00175  * Modifying bitmaps.
    00176  */
    00177
    00179  void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
    00180
    00185  void hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
    00186
    00188  void hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
    00189
    00191  void hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
    00192
    00197  void hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
    00198
    00205  void hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
    00206
    00207
    00208 /*
    00209  * Consulting bitmaps.
    00210  */
    00211
    00213  unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) ;
    00214
    00216  unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) ;
    00217
    00219  int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) ;
    00220
    00222  int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) ;
    00223
    00225  int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) ;
    00226
    00231  int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) ;
    00232
    00239  int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) ;
    00240
    00245  int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) ;
    00246
    00252  int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) ;
    00253
    00265 #define hwloc_bitmap_foreach_begin(id, bitmap) \
    00266 do { \
    00267         assert(hwloc_bitmap_weight(bitmap) != -1); \
    00268         for (id = hwloc_bitmap_first(bitmap); \
    00269              (unsigned) id != (unsigned) -1; \
    00270              id = hwloc_bitmap_next(bitmap, id)) { \
    00271
    00275 #define hwloc_bitmap_foreach_end() \
    00276         } \
    00277 } while (0)
    00278
    00279
    00280 /*
    00281  * Combining bitmaps.
    00282  */
    00283
    00285  void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
    00286
    00288  void hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
    00289
    00291  void hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
    00292
    00294  void hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
    00295
    00297  void hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
    00298
    00299
    00300 /*
    00301  * Comparing bitmaps.
    00302  */
    00303
    00305  int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
    00306
    00308  int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) ;
    00309
    00311  int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
    00312
    00318  int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
    00319
    00325  int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
    00326
    00330 #ifdef __cplusplus
    00331 } /* extern "C" */
    00332 #endif
    00333
    00334
    00335 #endif /* HWLOC_BITMAP_H */