|  | 
        
          | 
      
      
        
          | 
|  |  | hwloc_bitmap_t | hwloc_bitmap_alloc (void) |  |  |  | hwloc_bitmap_t | hwloc_bitmap_alloc_full (void) |  |  |  | void | hwloc_bitmap_free (hwloc_bitmap_t bitmap) |  |  |  | hwloc_bitmap_t | hwloc_bitmap_dup (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_copy (hwloc_bitmap_t dst, hwloc_const_bitmap_t src) |  |  |  | int | hwloc_bitmap_snprintf (char *restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_asprintf (char **strp, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_sscanf (hwloc_bitmap_t bitmap, const char *restrict string) |  |  |  | int | hwloc_bitmap_list_snprintf (char *restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_list_asprintf (char **strp, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_list_sscanf (hwloc_bitmap_t bitmap, const char *restrict string) |  |  |  | int | hwloc_bitmap_taskset_snprintf (char *restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_taskset_asprintf (char **strp, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_taskset_sscanf (hwloc_bitmap_t bitmap, const char *restrict string) |  |  |  | void | hwloc_bitmap_zero (hwloc_bitmap_t bitmap) |  |  |  | void | hwloc_bitmap_fill (hwloc_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_only (hwloc_bitmap_t bitmap, unsigned id) |  |  |  | int | hwloc_bitmap_allbut (hwloc_bitmap_t bitmap, unsigned id) |  |  |  | int | hwloc_bitmap_from_ulong (hwloc_bitmap_t bitmap, unsigned long mask) |  |  |  | int | hwloc_bitmap_from_ith_ulong (hwloc_bitmap_t bitmap, unsigned i, unsigned long mask) |  |  |  | int | hwloc_bitmap_from_ulongs (hwloc_bitmap_t bitmap, unsigned nr, const unsigned long *masks) |  |  |  | int | hwloc_bitmap_set (hwloc_bitmap_t bitmap, unsigned id) |  |  |  | int | hwloc_bitmap_set_range (hwloc_bitmap_t bitmap, unsigned begin, int end) |  |  |  | int | hwloc_bitmap_set_ith_ulong (hwloc_bitmap_t bitmap, unsigned i, unsigned long mask) |  |  |  | int | hwloc_bitmap_clr (hwloc_bitmap_t bitmap, unsigned id) |  |  |  | int | hwloc_bitmap_clr_range (hwloc_bitmap_t bitmap, unsigned begin, int end) |  |  |  | int | hwloc_bitmap_singlify (hwloc_bitmap_t bitmap) |  |  |  | unsigned long | hwloc_bitmap_to_ulong (hwloc_const_bitmap_t bitmap) |  |  |  | unsigned long | hwloc_bitmap_to_ith_ulong (hwloc_const_bitmap_t bitmap, unsigned i) |  |  |  | int | hwloc_bitmap_to_ulongs (hwloc_const_bitmap_t bitmap, unsigned nr, unsigned long *masks) |  |  |  | int | hwloc_bitmap_nr_ulongs (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_isset (hwloc_const_bitmap_t bitmap, unsigned id) |  |  |  | int | hwloc_bitmap_iszero (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_isfull (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_first (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_next (hwloc_const_bitmap_t bitmap, int prev) |  |  |  | int | hwloc_bitmap_last (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_weight (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_first_unset (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_next_unset (hwloc_const_bitmap_t bitmap, int prev) |  |  |  | int | hwloc_bitmap_last_unset (hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap) |  |  |  | int | hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) |  |  |  | int | hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_compare_first (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  | int | hwloc_bitmap_compare (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) |  |  |  The hwloc_bitmap_t 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. Bitmaps are used by hwloc for sets of OS processors (which may actually be hardware threads) as by hwloc_cpuset_t (a typedef for hwloc_bitmap_t), or sets of NUMA memory nodes as hwloc_nodeset_t (also a typedef for hwloc_bitmap_t). Those are used for cpuset and nodeset fields in the hwloc_obj structure, see Object Sets (hwloc_cpuset_t and hwloc_nodeset_t). Both CPU and node sets are always indexed by OS physical number. However users should usually not build CPU and node sets manually (e.g. with hwloc_bitmap_set()). One should rather use existing object sets and combine them with hwloc_bitmap_or(), etc. For instance, binding the current thread on a pair of cores may be performed with:  
int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags) Bind current process or thread on cpus given in physical bitmap set.@ HWLOC_CPUBIND_THREAD Bind current thread of current process. Definition: hwloc.h:1161int hwloc_bitmap_or(hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) Or bitmaps bitmap1 and bitmap2 and store the result in bitmap res.void hwloc_bitmap_free(hwloc_bitmap_t bitmap) Free bitmap bitmap.struct hwloc_bitmap_s * hwloc_bitmap_t Set of bits represented as an opaque pointer to an internal bitmap. Definition: bitmap.h:68hwloc_bitmap_t hwloc_bitmap_alloc(void) Allocate a new empty bitmap.Structure of a topology object. Definition: hwloc.h:395hwloc_cpuset_t cpuset CPUs covered by this object. Definition: hwloc.h:511 NoteMost functions below return an int that may be negative in case of error. The usual error case would be an internal failure to realloc/extend the storage of the bitmap (errnowould be set toENOMEM).
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. 
 ◆ hwloc_bitmap_foreach_begin
      
        
          | #define hwloc_bitmap_foreach_begin | ( |  | id, |  
          |  |  |  | bitmap |  
          |  | ) |  |  |  
Loop macro iterating on bitmap bitmap. The loop must start with hwloc_bitmap_foreach_begin() and end with hwloc_bitmap_foreach_end() followed by a terminating ';'. indexis the loop variable; it should be an unsigned int. The first iteration will setindexto 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 forindexsuch that hwloc_bitmap_isset(bitmap, index) is true.
 The assert prevents the loop from being infinite if the bitmap is infinitely set.  ◆ hwloc_bitmap_foreach_end
      
        
          | #define hwloc_bitmap_foreach_end | ( |  | ) |  |  ◆ hwloc_bitmap_t
Set of bits represented as an opaque pointer to an internal bitmap.  ◆ hwloc_const_bitmap_t◆ hwloc_bitmap_allbut()
Fill the bitmap andclear the indexid. ◆ hwloc_bitmap_alloc()
Allocate a new empty bitmap.  ReturnsA valid bitmap or NULL.
 The bitmap should be freed by a corresponding call to hwloc_bitmap_free().  ◆ hwloc_bitmap_alloc_full()
Allocate a new full bitmap.  ◆ hwloc_bitmap_and()
And bitmaps bitmap1andbitmap2and store the result in bitmapres. rescan be the same asbitmap1orbitmap2
 ◆ hwloc_bitmap_andnot()
And bitmap bitmap1and the negation ofbitmap2and store the result in bitmapres. rescan be the same asbitmap1orbitmap2
 ◆ hwloc_bitmap_asprintf()
Stringify a bitmap into a newly allocated string.  Returns-1 on error. 
 ◆ hwloc_bitmap_clr()
Remove index idfrom bitmapbitmap. ◆ hwloc_bitmap_clr_range()
      
        
          | int hwloc_bitmap_clr_range | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned | begin, |  
          |  |  | int | end |  
          |  | ) |  |  |  
Remove indexes from begintoendin bitmapbitmap. If endis-1, the range is infinite. ◆ hwloc_bitmap_compare()
Compare bitmaps bitmap1andbitmap2in 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. Returns-1 if bitmap1is considered smaller thanbitmap2.
1 if bitmap1is considered larger thanbitmap2.
0 if bitmaps are equal (contrary to hwloc_bitmap_compare_first()).
 For instance comparing binary bitmaps 0011 and 0110 returns -1 (hence 0011 is considered smaller than 0110). Comparing 00101 and 01010 returns -1 too. NoteThis is different from the non-existing hwloc_bitmap_compare_last() which would only compare the highest index of each bitmap. 
 ◆ hwloc_bitmap_compare_first()
Compare bitmaps bitmap1andbitmap2using 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). Returns-1 if bitmap1is considered smaller thanbitmap2.
1 if bitmap1is considered larger thanbitmap2.
 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. Returns0 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. 
 ◆ hwloc_bitmap_copy()
Copy the contents of bitmap srcinto the already allocated bitmapdst. ◆ hwloc_bitmap_dup()
Duplicate bitmap bitmapby allocating a new bitmap and copyingbitmapcontents. If bitmapisNULL,NULLis returned. ◆ hwloc_bitmap_fill()
Fill bitmap bitmapwith all possible indexes (even if those objects don't exist or are otherwise unavailable) ◆ hwloc_bitmap_first()
Compute the first index (least significant bit) in bitmap bitmap. Returns-1 if no index is set in bitmap.
 ◆ hwloc_bitmap_first_unset()
Compute the first unset index (least significant bit) in bitmap bitmap. Returns-1 if no index is unset in bitmap.
 ◆ hwloc_bitmap_free()
Free bitmap bitmap. If bitmapisNULL, no operation is performed. ◆ hwloc_bitmap_from_ith_ulong()
      
        
          | int hwloc_bitmap_from_ith_ulong | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned | i, |  
          |  |  | unsigned long | mask |  
          |  | ) |  |  |  
Setup bitmap bitmapfrom unsigned longmaskused asi-th subset. ◆ hwloc_bitmap_from_ulong()
      
        
          | int hwloc_bitmap_from_ulong | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned long | mask |  
          |  | ) |  |  |  
Setup bitmap bitmapfrom unsigned longmask. ◆ hwloc_bitmap_from_ulongs()
      
        
          | int hwloc_bitmap_from_ulongs | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned | nr, |  
          |  |  | const unsigned long * | masks |  
          |  | ) |  |  |  
Setup bitmap bitmapfrom unsigned longsmasksused as firstnrsubsets. ◆ hwloc_bitmap_intersects()
Test whether bitmaps bitmap1andbitmap2intersects. Returns1 if bitmaps intersect, 0 otherwise. 
 ◆ hwloc_bitmap_isequal()
Test whether bitmap bitmap1is equal to bitmapbitmap2. Returns1 if bitmaps are equal, 0 otherwise. 
 ◆ hwloc_bitmap_isfull()
Test whether bitmap bitmapis completely full. Returns1 if bitmap is full, 0 otherwise.
 NoteA full bitmap is always infinitely set. 
 ◆ hwloc_bitmap_isincluded()
Test whether bitmap sub_bitmapis part of bitmapsuper_bitmap. Returns1 if sub_bitmapis included insuper_bitmap, 0 otherwise.
 NoteThe empty bitmap is considered included in any other bitmap. 
 ◆ hwloc_bitmap_isset()
Test whether index idis part of bitmapbitmap. Returns1 if the bit at index idis set in bitmapbitmap, 0 otherwise.
 ◆ hwloc_bitmap_iszero()
Test whether bitmap bitmapis empty. Returns1 if bitmap is empty, 0 otherwise. 
 ◆ hwloc_bitmap_last()
Compute the last index (most significant bit) in bitmap bitmap. Returns-1 if no index is set in bitmap, or ifbitmapis infinitely set.
 ◆ hwloc_bitmap_last_unset()
Compute the last unset index (most significant bit) in bitmap bitmap. Returns-1 if no index is unset in bitmap, or ifbitmapis infinitely set.
 ◆ hwloc_bitmap_list_asprintf()
Stringify a bitmap into a newly allocated list string.  Returns-1 on error. 
 ◆ hwloc_bitmap_list_snprintf()
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. Up to buflencharacters may be written in bufferbuf. If buflenis 0,bufmay safely beNULL. Returnsthe number of character that were actually written if not truncating, or that would have been written (not including the ending \0). 
 ◆ hwloc_bitmap_list_sscanf()
      
        
          | int hwloc_bitmap_list_sscanf | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | const char *restrict | string |  
          |  | ) |  |  |  
Parse a list string and stores it in bitmap bitmap. ◆ hwloc_bitmap_next()
Compute the next index in bitmap bitmapwhich is after indexprev. If previs -1, the first index is returned. Returns-1 if no index with higher index is set in bitmap.
 ◆ hwloc_bitmap_next_unset()
Compute the next unset index in bitmap bitmapwhich is after indexprev. If previs -1, the first unset index is returned. Returns-1 if no index with higher index is unset in bitmap.
 ◆ hwloc_bitmap_not()
Negate bitmap bitmapand store the result in bitmapres. rescan be the same asbitmap
 ◆ hwloc_bitmap_nr_ulongs()
Return the number of unsigned longs required for storing bitmap bitmapentirely. 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 nrparameter to pass to hwloc_bitmap_to_ulongs() (or which calls to hwloc_bitmap_to_ith_ulong() are needed) to entirely convert a bitmap into multiple unsigned longs. When called on the output of hwloc_topology_get_topology_cpuset(), the returned number is large enough for all cpusets of the topology. Returns-1 if bitmapis infinite.
 ◆ hwloc_bitmap_only()
Empty the bitmap bitmapand add bitid. ◆ hwloc_bitmap_or()
Or bitmaps bitmap1andbitmap2and store the result in bitmapres. rescan be the same asbitmap1orbitmap2
 ◆ hwloc_bitmap_set()
Add index idin bitmapbitmap. ◆ hwloc_bitmap_set_ith_ulong()
      
        
          | int hwloc_bitmap_set_ith_ulong | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned | i, |  
          |  |  | unsigned long | mask |  
          |  | ) |  |  |  
Replace i-th subset of bitmapbitmapwith unsigned longmask. ◆ hwloc_bitmap_set_range()
      
        
          | int hwloc_bitmap_set_range | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | unsigned | begin, |  
          |  |  | int | end |  
          |  | ) |  |  |  
Add indexes from begintoendin bitmapbitmap. If endis-1, the range is infinite. ◆ hwloc_bitmap_singlify()
Keep a single index among those set in bitmap bitmap. 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. NoteThis 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. hwloc_distrib() may be used for generating CPU sets to distribute multiple tasks below a single multi-PU object.
This function cannot be applied to an object set directly. It should be applied to a copy (which may be obtained with hwloc_bitmap_dup()). 
 ◆ hwloc_bitmap_snprintf()
Stringify a bitmap.  Up to buflencharacters may be written in bufferbuf. If buflenis 0,bufmay safely beNULL. Returnsthe number of character that were actually written if not truncating, or that would have been written (not including the ending \0). 
 ◆ hwloc_bitmap_sscanf()
      
        
          | int hwloc_bitmap_sscanf | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | const char *restrict | string |  
          |  | ) |  |  |  
Parse a bitmap string and stores it in bitmap bitmap. ◆ hwloc_bitmap_taskset_asprintf()
Stringify a bitmap into a newly allocated taskset-specific string.  Returns-1 on error. 
 ◆ hwloc_bitmap_taskset_snprintf()
      
        
          | int hwloc_bitmap_taskset_snprintf | ( | char *restrict | buf, |  
          |  |  | size_t | buflen, |  
          |  |  | hwloc_const_bitmap_t | bitmap |  
          |  | ) |  |  |  
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. Up to buflencharacters may be written in bufferbuf. If buflenis 0,bufmay safely beNULL. Returnsthe number of character that were actually written if not truncating, or that would have been written (not including the ending \0). 
 ◆ hwloc_bitmap_taskset_sscanf()
      
        
          | int hwloc_bitmap_taskset_sscanf | ( | hwloc_bitmap_t | bitmap, |  
          |  |  | const char *restrict | string |  
          |  | ) |  |  |  
Parse a taskset-specific bitmap string and stores it in bitmap bitmap. ◆ hwloc_bitmap_to_ith_ulong()
Convert the i-th subset of bitmapbitmapinto unsigned long mask. ◆ hwloc_bitmap_to_ulong()
Convert the beginning part of bitmap bitmapinto unsigned longmask. ◆ hwloc_bitmap_to_ulongs()
Convert the first nrsubsets of bitmapbitmapinto the array ofnrunsigned longmasks. nrmay be determined earlier with hwloc_bitmap_nr_ulongs().
 Returns0 
 ◆ hwloc_bitmap_weight()
Compute the "weight" of bitmap bitmap(i.e., number of indexes that are in the bitmap). Returnsthe number of indexes that are in the bitmap.
-1 if bitmapis infinitely set.
 ◆ hwloc_bitmap_xor()
Xor bitmaps bitmap1andbitmap2and store the result in bitmapres. rescan be the same asbitmap1orbitmap2
 ◆ hwloc_bitmap_zero() |  |  |