Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:15

0001 /*
0002  * Copyright © 2009 CNRS
0003  * Copyright © 2009-2023 Inria.  All rights reserved.
0004  * Copyright © 2009-2012 Université Bordeaux
0005  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
0006  * See COPYING in top-level directory.
0007  */
0008 
0009 /** \file
0010  * \brief The bitmap API, for use in hwloc itself.
0011  */
0012 
0013 #ifndef HWLOC_BITMAP_H
0014 #define HWLOC_BITMAP_H
0015 
0016 #include "hwloc/autogen/config.h"
0017 
0018 #include <assert.h>
0019 
0020 
0021 #ifdef __cplusplus
0022 extern "C" {
0023 #endif
0024 
0025 
0026 /** \defgroup hwlocality_bitmap The bitmap API
0027  *
0028  * The ::hwloc_bitmap_t type represents a set of integers (positive or null).
0029  * A bitmap may be of infinite size (all bits are set after some point).
0030  * A bitmap may even be full if all bits are set.
0031  *
0032  * Bitmaps are used by hwloc for sets of OS processors
0033  * (which may actually be hardware threads) as by ::hwloc_cpuset_t
0034  * (a typedef for ::hwloc_bitmap_t), or sets of NUMA memory nodes
0035  * as ::hwloc_nodeset_t (also a typedef for ::hwloc_bitmap_t).
0036  * Those are used for cpuset and nodeset fields in the ::hwloc_obj structure,
0037  * see \ref hwlocality_object_sets.
0038  *
0039  * <em>Both CPU and node sets are always indexed by OS physical number.</em>
0040  * However users should usually not build CPU and node sets manually
0041  * (e.g. with hwloc_bitmap_set()).
0042  * One should rather use existing object sets and combine them with
0043  * hwloc_bitmap_or(), etc.
0044  * For instance, binding the current thread on a pair of cores may be performed with:
0045  * \code
0046  * hwloc_obj_t core1 = ... , core2 = ... ;
0047  * hwloc_bitmap_t set = hwloc_bitmap_alloc();
0048  * hwloc_bitmap_or(set, core1->cpuset, core2->cpuset);
0049  * hwloc_set_cpubind(topology, set, HWLOC_CPUBIND_THREAD);
0050  * hwloc_bitmap_free(set);
0051  * \endcode
0052  *
0053  * \note Most functions below return 0 on success and -1 on error.
0054  * The usual error case would be an internal failure to realloc/extend
0055  * the storage of the bitmap (\p errno would be set to \c ENOMEM).
0056  * See also \ref hwlocality_api_error_reporting.
0057  *
0058  * \note Several examples of using the bitmap API are available under the
0059  * doc/examples/ directory in the source tree.
0060  * Regression tests such as tests/hwloc/hwloc_bitmap*.c also make intensive use
0061  * of this API.
0062  * @{
0063  */
0064 
0065 
0066 /** \brief
0067  * Set of bits represented as an opaque pointer to an internal bitmap.
0068  */
0069 typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
0070 /** \brief a non-modifiable ::hwloc_bitmap_t */
0071 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
0072 
0073 
0074 /*
0075  * Bitmap allocation, freeing and copying.
0076  */
0077 
0078 /** \brief Allocate a new empty bitmap.
0079  *
0080  * \returns A valid bitmap or \c NULL.
0081  *
0082  * The bitmap should be freed by a corresponding call to
0083  * hwloc_bitmap_free().
0084  */
0085 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc(void) __hwloc_attribute_malloc;
0086 
0087 /** \brief Allocate a new full bitmap.
0088  *
0089  * \returns A valid bitmap or \c NULL.
0090  *
0091  * The bitmap should be freed by a corresponding call to
0092  * hwloc_bitmap_free().
0093  */
0094 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc_full(void) __hwloc_attribute_malloc;
0095 
0096 /** \brief Free bitmap \p bitmap.
0097  *
0098  * If \p bitmap is \c NULL, no operation is performed.
0099  */
0100 HWLOC_DECLSPEC void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
0101 
0102 /** \brief Duplicate bitmap \p bitmap by allocating a new bitmap and copying \p bitmap contents.
0103  *
0104  * If \p bitmap is \c NULL, \c NULL is returned.
0105  */
0106 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) __hwloc_attribute_malloc;
0107 
0108 /** \brief Copy the contents of bitmap \p src into the already allocated bitmap \p dst */
0109 HWLOC_DECLSPEC int hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
0110 
0111 
0112 /*
0113  * Bitmap/String Conversion
0114  */
0115 
0116 /** \brief Stringify a bitmap.
0117  *
0118  * Up to \p buflen characters may be written in buffer \p buf.
0119  *
0120  * If \p buflen is 0, \p buf may safely be \c NULL.
0121  *
0122  * \return the number of characters that were actually written if not truncating,
0123  * or that would have been written (not including the ending \\0).
0124  */
0125 HWLOC_DECLSPEC int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
0126 
0127 /** \brief Stringify a bitmap into a newly allocated string.
0128  *
0129  * \return 0 on success, -1 on error.
0130  */
0131 HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
0132 
0133 /** \brief Parse a bitmap string and stores it in bitmap \p bitmap.
0134  *
0135  * \return 0 on success, -1 on error.
0136  */
0137 HWLOC_DECLSPEC int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
0138 
0139 /** \brief Stringify a bitmap in the list format.
0140  *
0141  * Lists are comma-separated indexes or ranges.
0142  * Ranges are dash separated indexes.
0143  * The last range may not have an ending indexes if the bitmap is infinitely set.
0144  *
0145  * Up to \p buflen characters may be written in buffer \p buf.
0146  *
0147  * If \p buflen is 0, \p buf may safely be \c NULL.
0148  *
0149  * \return the number of characters that were actually written if not truncating,
0150  * or that would have been written (not including the ending \\0).
0151  */
0152 HWLOC_DECLSPEC int hwloc_bitmap_list_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
0153 
0154 /** \brief Stringify a bitmap into a newly allocated list string.
0155  *
0156  * \return 0 on success, -1 on error.
0157  */
0158 HWLOC_DECLSPEC int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
0159 
0160 /** \brief Parse a list string and stores it in bitmap \p bitmap.
0161  *
0162  * \return 0 on success, -1 on error.
0163  */
0164 HWLOC_DECLSPEC int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
0165 
0166 /** \brief Stringify a bitmap in the taskset-specific format.
0167  *
0168  * The taskset command manipulates bitmap strings that contain a single
0169  * (possible very long) hexadecimal number starting with 0x.
0170  *
0171  * Up to \p buflen characters may be written in buffer \p buf.
0172  *
0173  * If \p buflen is 0, \p buf may safely be \c NULL.
0174  *
0175  * \return the number of characters that were actually written if not truncating,
0176  * or that would have been written (not including the ending \\0).
0177  */
0178 HWLOC_DECLSPEC int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
0179 
0180 /** \brief Stringify a bitmap into a newly allocated taskset-specific string.
0181  *
0182  * \return 0 on success, -1 on error.
0183  */
0184 HWLOC_DECLSPEC int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
0185 
0186 /** \brief Parse a taskset-specific bitmap string and stores it in bitmap \p bitmap.
0187  *
0188  * \return 0 on success, -1 on error.
0189  */
0190 HWLOC_DECLSPEC int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
0191 
0192 
0193 /*
0194  * Building bitmaps.
0195  */
0196 
0197 /** \brief Empty the bitmap \p bitmap */
0198 HWLOC_DECLSPEC void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
0199 
0200 /** \brief Fill bitmap \p bitmap with all possible indexes (even if those objects don't exist or are otherwise unavailable) */
0201 HWLOC_DECLSPEC void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
0202 
0203 /** \brief Empty the bitmap \p bitmap and add bit \p id */
0204 HWLOC_DECLSPEC int hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
0205 
0206 /** \brief Fill the bitmap \p and clear the index \p id */
0207 HWLOC_DECLSPEC int hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
0208 
0209 /** \brief Setup bitmap \p bitmap from unsigned long \p mask */
0210 HWLOC_DECLSPEC int hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
0211 
0212 /** \brief Setup bitmap \p bitmap from unsigned long \p mask used as \p i -th subset */
0213 HWLOC_DECLSPEC int hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
0214 
0215 /** \brief Setup bitmap \p bitmap from unsigned longs \p masks used as first \p nr subsets */
0216 HWLOC_DECLSPEC int hwloc_bitmap_from_ulongs(hwloc_bitmap_t bitmap, unsigned nr, const unsigned long *masks);
0217 
0218 
0219 /*
0220  * Modifying bitmaps.
0221  */
0222 
0223 /** \brief Add index \p id in bitmap \p bitmap */
0224 HWLOC_DECLSPEC int hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
0225 
0226 /** \brief Add indexes from \p begin to \p end in bitmap \p bitmap.
0227  *
0228  * If \p end is \c -1, the range is infinite.
0229  */
0230 HWLOC_DECLSPEC int hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
0231 
0232 /** \brief Replace \p i -th subset of bitmap \p bitmap with unsigned long \p mask */
0233 HWLOC_DECLSPEC int hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
0234 
0235 /** \brief Remove index \p id from bitmap \p bitmap */
0236 HWLOC_DECLSPEC int hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
0237 
0238 /** \brief Remove indexes from \p begin to \p end in bitmap \p bitmap.
0239  *
0240  * If \p end is \c -1, the range is infinite.
0241  */
0242 HWLOC_DECLSPEC int hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
0243 
0244 /** \brief Keep a single index among those set in bitmap \p bitmap
0245  *
0246  * May be useful before binding so that the process does not
0247  * have a chance of migrating between multiple processors
0248  * in the original mask.
0249  * Instead of running the task on any PU inside the given CPU set,
0250  * the operating system scheduler will be forced to run it on a single
0251  * of these PUs.
0252  * It avoids a migration overhead and cache-line ping-pongs between PUs.
0253  *
0254  * \note This function is NOT meant to distribute multiple processes
0255  * within a single CPU set. It always return the same single bit when
0256  * called multiple times on the same input set. hwloc_distrib() may
0257  * be used for generating CPU sets to distribute multiple tasks below
0258  * a single multi-PU object.
0259  *
0260  * \note This function cannot be applied to an object set directly. It
0261  * should be applied to a copy (which may be obtained with hwloc_bitmap_dup()).
0262  */
0263 HWLOC_DECLSPEC int hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
0264 
0265 
0266 /*
0267  * Consulting bitmaps.
0268  */
0269 
0270 /** \brief Convert the beginning part of bitmap \p bitmap into unsigned long \p mask */
0271 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0272 
0273 /** \brief Convert the \p i -th subset of bitmap \p bitmap into unsigned long mask */
0274 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) __hwloc_attribute_pure;
0275 
0276 /** \brief Convert the first \p nr subsets of bitmap \p bitmap into the array of \p nr unsigned long \p masks
0277  *
0278  * \p nr may be determined earlier with hwloc_bitmap_nr_ulongs().
0279  *
0280  * \return 0
0281  */
0282 HWLOC_DECLSPEC int hwloc_bitmap_to_ulongs(hwloc_const_bitmap_t bitmap, unsigned nr, unsigned long *masks);
0283 
0284 /** \brief Return the number of unsigned longs required for storing bitmap \p bitmap entirely
0285  *
0286  * This is the number of contiguous unsigned longs from the very first bit of the bitmap
0287  * (even if unset) up to the last set bit.
0288  * This is useful for knowing the \p nr parameter to pass to hwloc_bitmap_to_ulongs()
0289  * (or which calls to hwloc_bitmap_to_ith_ulong() are needed)
0290  * to entirely convert a bitmap into multiple unsigned longs.
0291  *
0292  * When called on the output of hwloc_topology_get_topology_cpuset(),
0293  * the returned number is large enough for all cpusets of the topology.
0294  *
0295  * \return the number of unsigned longs required.
0296  * \return -1 if \p bitmap is infinite.
0297  */
0298 HWLOC_DECLSPEC int hwloc_bitmap_nr_ulongs(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0299 
0300 /** \brief Test whether index \p id is part of bitmap \p bitmap.
0301  *
0302  * \return 1 if the bit at index \p id is set in bitmap \p bitmap, 0 otherwise.
0303  */
0304 HWLOC_DECLSPEC int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) __hwloc_attribute_pure;
0305 
0306 /** \brief Test whether bitmap \p bitmap is empty
0307  *
0308  * \return 1 if bitmap is empty, 0 otherwise.
0309  */
0310 HWLOC_DECLSPEC int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0311 
0312 /** \brief Test whether bitmap \p bitmap is completely full
0313  *
0314  * \return 1 if bitmap is full, 0 otherwise.
0315  *
0316  * \note A full bitmap is always infinitely set.
0317  */
0318 HWLOC_DECLSPEC int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0319 
0320 /** \brief Compute the first index (least significant bit) in bitmap \p bitmap
0321  *
0322  * \return the first index set in \p bitmap.
0323  * \return -1 if \p bitmap is empty.
0324  */
0325 HWLOC_DECLSPEC int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0326 
0327 /** \brief Compute the next index in bitmap \p bitmap which is after index \p prev
0328  *
0329  * \return the first index set in \p bitmap if \p prev is \c -1.
0330  * \return the next index set in \p bitmap if \p prev is not \c -1.
0331  * \return -1 if no index with higher index is set in \p bitmap.
0332  */
0333 HWLOC_DECLSPEC int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
0334 
0335 /** \brief Compute the last index (most significant bit) in bitmap \p bitmap
0336  *
0337  * \return the last index set in \p bitmap.
0338  * \return -1 if \p bitmap is empty, or if \p bitmap is infinitely set.
0339  */
0340 HWLOC_DECLSPEC int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0341 
0342 /** \brief Compute the "weight" of bitmap \p bitmap (i.e., number of
0343  * indexes that are in the bitmap).
0344  *
0345  * \return the number of indexes that are in the bitmap.
0346  * \return -1 if \p bitmap is infinitely set.
0347  */
0348 HWLOC_DECLSPEC int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0349 
0350 /** \brief Compute the first unset index (least significant bit) in bitmap \p bitmap
0351  *
0352  * \return the first unset index in \p bitmap.
0353  * \return -1 if \p bitmap is full.
0354  */
0355 HWLOC_DECLSPEC int hwloc_bitmap_first_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0356 
0357 /** \brief Compute the next unset index in bitmap \p bitmap which is after index \p prev
0358  *
0359  * \return the first index unset in \p bitmap if \p prev is \c -1.
0360  * \return the next index unset in \p bitmap if \p prev is not \c -1.
0361  * \return -1 if no index with higher index is unset in \p bitmap.
0362  */
0363 HWLOC_DECLSPEC int hwloc_bitmap_next_unset(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
0364 
0365 /** \brief Compute the last unset index (most significant bit) in bitmap \p bitmap
0366  *
0367  * \return the last index unset in \p bitmap.
0368  * \return -1 if \p bitmap is full, or if \p bitmap is not infinitely set.
0369  */
0370 HWLOC_DECLSPEC int hwloc_bitmap_last_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
0371 
0372 /** \brief Loop macro iterating on bitmap \p bitmap
0373  *
0374  * The loop must start with hwloc_bitmap_foreach_begin() and end
0375  * with hwloc_bitmap_foreach_end() followed by a terminating ';'.
0376  *
0377  * \p id is the loop variable; it should be an unsigned int.  The
0378  * first iteration will set \p id to the lowest index in the bitmap.
0379  * Successive iterations will iterate through, in order, all remaining
0380  * indexes set in the bitmap.  To be specific: each iteration will return a
0381  * value for \p id such that hwloc_bitmap_isset(bitmap, id) is true.
0382  *
0383  * The assert prevents the loop from being infinite if the bitmap is infinitely set.
0384  *
0385  * \hideinitializer
0386  */
0387 #define hwloc_bitmap_foreach_begin(id, bitmap) \
0388 do { \
0389         assert(hwloc_bitmap_weight(bitmap) != -1); \
0390         for (id = hwloc_bitmap_first(bitmap); \
0391              (unsigned) id != (unsigned) -1; \
0392              id = hwloc_bitmap_next(bitmap, id)) {
0393 
0394 /** \brief End of loop macro iterating on a bitmap.
0395  *
0396  * Needs a terminating ';'.
0397  *
0398  * \sa hwloc_bitmap_foreach_begin()
0399  * \hideinitializer
0400  */
0401 #define hwloc_bitmap_foreach_end()      \
0402         } \
0403 } while (0)
0404 
0405 
0406 /*
0407  * Combining bitmaps.
0408  */
0409 
0410 /** \brief Or bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
0411  *
0412  * \p res can be the same as \p bitmap1 or \p bitmap2
0413  */
0414 HWLOC_DECLSPEC int hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
0415 
0416 /** \brief And bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
0417  *
0418  * \p res can be the same as \p bitmap1 or \p bitmap2
0419  */
0420 HWLOC_DECLSPEC int hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
0421 
0422 /** \brief And bitmap \p bitmap1 and the negation of \p bitmap2 and store the result in bitmap \p res
0423  *
0424  * \p res can be the same as \p bitmap1 or \p bitmap2
0425  */
0426 HWLOC_DECLSPEC int hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
0427 
0428 /** \brief Xor bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
0429  *
0430  * \p res can be the same as \p bitmap1 or \p bitmap2
0431  */
0432 HWLOC_DECLSPEC int hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
0433 
0434 /** \brief Negate bitmap \p bitmap and store the result in bitmap \p res
0435  *
0436  * \p res can be the same as \p bitmap
0437  */
0438 HWLOC_DECLSPEC int hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
0439 
0440 
0441 /*
0442  * Comparing bitmaps.
0443  */
0444 
0445 /** \brief Test whether bitmaps \p bitmap1 and \p bitmap2 intersects.
0446  *
0447  * \return 1 if bitmaps intersect, 0 otherwise.
0448  *
0449  * \note The empty bitmap does not intersect any other bitmap.
0450  */
0451 HWLOC_DECLSPEC int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
0452 
0453 /** \brief Test whether bitmap \p sub_bitmap is part of bitmap \p super_bitmap.
0454  *
0455  * \return 1 if \p sub_bitmap is included in \p super_bitmap, 0 otherwise.
0456  *
0457  * \note The empty bitmap is considered included in any other bitmap.
0458  */
0459 HWLOC_DECLSPEC int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) __hwloc_attribute_pure;
0460 
0461 /** \brief Test whether bitmap \p bitmap1 is equal to bitmap \p bitmap2.
0462  *
0463  * \return 1 if bitmaps are equal, 0 otherwise.
0464  */
0465 HWLOC_DECLSPEC int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
0466 
0467 /** \brief Compare bitmaps \p bitmap1 and \p bitmap2 using their lowest index.
0468  *
0469  * A bitmap is considered smaller if its least significant bit is smaller.
0470  * The empty bitmap is considered higher than anything (because its least significant bit does not exist).
0471  *
0472  * \return -1 if \p bitmap1 is considered smaller than \p bitmap2.
0473  * \return 1 if \p bitmap1 is considered larger than \p bitmap2.
0474  *
0475  * For instance comparing binary bitmaps 0011 and 0110 returns -1
0476  * (hence 0011 is considered smaller than 0110)
0477  * because least significant bit of 0011 (0001) is smaller than least significant bit of 0110 (0010).
0478  * Comparing 01001 and 00110 would also return -1 for the same reason.
0479  *
0480  * \return 0 if bitmaps are considered equal, even if they are not strictly equal.
0481  * They just need to have the same least significant bit.
0482  * For instance, comparing binary bitmaps 0010 and 0110 returns 0 because they have the same least significant bit.
0483  */
0484 HWLOC_DECLSPEC int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
0485 
0486 /** \brief Compare bitmaps \p bitmap1 and \p bitmap2 in lexicographic order.
0487  *
0488  * Lexicographic comparison of bitmaps, starting for their highest indexes.
0489  * Compare last indexes first, then second, etc.
0490  * The empty bitmap is considered lower than anything.
0491  *
0492  * \return -1 if \p bitmap1 is considered smaller than \p bitmap2.
0493  * \return 1 if \p bitmap1 is considered larger than \p bitmap2.
0494  * \return 0 if bitmaps are equal (contrary to hwloc_bitmap_compare_first()).
0495  *
0496  * For instance comparing binary bitmaps 0011 and 0110 returns -1
0497  * (hence 0011 is considered smaller than 0110).
0498  * Comparing 00101 and 01010 returns -1 too.
0499  *
0500  * \note This is different from the non-existing hwloc_bitmap_compare_last()
0501  * which would only compare the highest index of each bitmap.
0502  */
0503 HWLOC_DECLSPEC int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
0504 
0505 /** @} */
0506 
0507 
0508 #ifdef __cplusplus
0509 } /* extern "C" */
0510 #endif
0511 
0512 
0513 #endif /* HWLOC_BITMAP_H */