OpenMPI
0.1.1
|
A bitmap implementation. More...
Go to the source code of this file.
Data Structures | |
struct | opal_bitmap_t |
Typedefs | |
typedef struct opal_bitmap_t | opal_bitmap_t |
Functions | |
OPAL_DECLSPEC | OBJ_CLASS_DECLARATION (opal_bitmap_t) |
OPAL_DECLSPEC int | opal_bitmap_set_max_size (opal_bitmap_t *bm, int max_size) |
Set the maximum size of the bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_init (opal_bitmap_t *bm, int size) |
Initializes the bitmap and sets its size. More... | |
OPAL_DECLSPEC int | opal_bitmap_set_bit (opal_bitmap_t *bm, int bit) |
Set a bit of the bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_clear_bit (opal_bitmap_t *bm, int bit) |
Clear/unset a bit of the bitmap. More... | |
OPAL_DECLSPEC bool | opal_bitmap_is_set_bit (opal_bitmap_t *bm, int bit) |
Find out if a bit is set in the bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_find_and_set_first_unset_bit (opal_bitmap_t *bm, int *position) |
Find the first clear bit in the bitmap and set it. More... | |
OPAL_DECLSPEC int | opal_bitmap_clear_all_bits (opal_bitmap_t *bm) |
Clear all bits in the bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_set_all_bits (opal_bitmap_t *bm) |
Set all bits in the bitmap. More... | |
static int | opal_bitmap_size (opal_bitmap_t *bm) |
Gives the current size (number of bits) in the bitmap. More... | |
static void | opal_bitmap_copy (opal_bitmap_t *dest, opal_bitmap_t *src) |
Copy a bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_bitwise_and_inplace (opal_bitmap_t *dest, opal_bitmap_t *right) |
Bitwise AND operator (inplace) More... | |
OPAL_DECLSPEC int | opal_bitmap_bitwise_or_inplace (opal_bitmap_t *dest, opal_bitmap_t *right) |
Bitwise OR operator (inplace) More... | |
OPAL_DECLSPEC int | opal_bitmap_bitwise_xor_inplace (opal_bitmap_t *dest, opal_bitmap_t *right) |
Bitwise XOR operator (inplace) More... | |
OPAL_DECLSPEC bool | opal_bitmap_are_different (opal_bitmap_t *left, opal_bitmap_t *right) |
If the bitmaps are different. More... | |
OPAL_DECLSPEC char * | opal_bitmap_get_string (opal_bitmap_t *bitmap) |
Get a string representation of the bitmap. More... | |
OPAL_DECLSPEC int | opal_bitmap_num_unset_bits (opal_bitmap_t *bm, int len) |
Return the number of 'unset' bits, upto the specified length. More... | |
OPAL_DECLSPEC int | opal_bitmap_num_set_bits (opal_bitmap_t *bm, int len) |
Return the number of 'set' bits, upto the specified length. More... | |
A bitmap implementation.
The bits start off with 0, so this bitmap has bits numbered as bit 0, bit 1, bit 2 and so on. This bitmap has auto-expansion capabilities, that is once the size is set during init, it can be automatically expanded by setting the bit beyond the current size. But note, this is allowed just when the bit is set – so the valid functions are set_bit and find_and_set_bit. Other functions like clear, if passed a bit outside the initialized range will result in an error.
To allow these bitmaps to track fortran handles (which MPI defines to be Fortran INTEGER), we offer a opal_bitmap_set_max_size, so that the upper layer can ask to never have more than OMPI_FORTRAN_HANDLE_MAX, which is min(INT_MAX, fortran INTEGER max). Currently the only user of this is ompi/attribute/attribute.c
OPAL_DECLSPEC bool opal_bitmap_are_different | ( | opal_bitmap_t * | left, |
opal_bitmap_t * | right | ||
) |
If the bitmaps are different.
left | Pointer to a bitmap |
right | Pointer to another bitmap |
References opal_bitmap_t::array_size, opal_bitmap_t::bitmap, and opal_bitmap_size().
OPAL_DECLSPEC int opal_bitmap_bitwise_and_inplace | ( | opal_bitmap_t * | dest, |
opal_bitmap_t * | right | ||
) |
Bitwise AND operator (inplace)
dest | Pointer to the bitmap that should be modified |
right | Point to the other bitmap in the operation |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
OPAL_DECLSPEC int opal_bitmap_bitwise_or_inplace | ( | opal_bitmap_t * | dest, |
opal_bitmap_t * | right | ||
) |
Bitwise OR operator (inplace)
dest | Pointer to the bitmap that should be modified |
right | Point to the other bitmap in the operation |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
OPAL_DECLSPEC int opal_bitmap_bitwise_xor_inplace | ( | opal_bitmap_t * | dest, |
opal_bitmap_t * | right | ||
) |
Bitwise XOR operator (inplace)
dest | Pointer to the bitmap that should be modified |
right | Point to the other bitmap in the operation |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
OPAL_DECLSPEC int opal_bitmap_clear_all_bits | ( | opal_bitmap_t * | bm | ) |
Clear all bits in the bitmap.
bitmap | The input bitmap (IN) |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
Referenced by opal_bitmap_init().
OPAL_DECLSPEC int opal_bitmap_clear_bit | ( | opal_bitmap_t * | bm, |
int | bit | ||
) |
Clear/unset a bit of the bitmap.
If the bit is beyond the current size of the bitmap, an error is returned
bitmap | The input bitmap (IN) |
bit | The bit which is to be cleared (IN) |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
|
inlinestatic |
Copy a bitmap.
dest | Pointer to the destination bitmap |
src | Pointer to the source bitmap @ return OPAL error code if something goes wrong |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
OPAL_DECLSPEC int opal_bitmap_find_and_set_first_unset_bit | ( | opal_bitmap_t * | bm, |
int * | position | ||
) |
Find the first clear bit in the bitmap and set it.
bitmap | The input bitmap (IN) |
position | Position of the first clear bit (OUT) |
References opal_bitmap_t::array_size, opal_bitmap_t::bitmap, and opal_bitmap_set_bit().
OPAL_DECLSPEC char* opal_bitmap_get_string | ( | opal_bitmap_t * | bitmap | ) |
Get a string representation of the bitmap.
Useful for debugging.
bitmap | Point to the bitmap to represent |
References opal_bitmap_t::array_size, and opal_bitmap_is_set_bit().
OPAL_DECLSPEC int opal_bitmap_init | ( | opal_bitmap_t * | bm, |
int | size | ||
) |
Initializes the bitmap and sets its size.
This must be called before the bitmap can be actually used
bitmap | The input bitmap (IN) |
size | The initial size of the bitmap in terms of bits (IN) |
References opal_bitmap_t::array_size, opal_bitmap_t::bitmap, opal_bitmap_t::max_size, and opal_bitmap_clear_all_bits().
Referenced by ompi_attr_init().
OPAL_DECLSPEC bool opal_bitmap_is_set_bit | ( | opal_bitmap_t * | bm, |
int | bit | ||
) |
Find out if a bit is set in the bitmap.
bitmap | The input bitmap (IN) |
bit | The bit which is to be checked (IN) |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
Referenced by opal_bitmap_get_string().
OPAL_DECLSPEC int opal_bitmap_num_set_bits | ( | opal_bitmap_t * | bm, |
int | len | ||
) |
Return the number of 'set' bits, upto the specified length.
bitmap | Pointer to the bitmap |
len | Number of bits to check |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
Referenced by opal_bitmap_num_unset_bits().
OPAL_DECLSPEC int opal_bitmap_num_unset_bits | ( | opal_bitmap_t * | bm, |
int | len | ||
) |
Return the number of 'unset' bits, upto the specified length.
bitmap | Pointer to the bitmap |
len | Number of bits to check |
References opal_bitmap_num_set_bits().
OPAL_DECLSPEC int opal_bitmap_set_all_bits | ( | opal_bitmap_t * | bm | ) |
Set all bits in the bitmap.
bitmap | The input bitmap (IN) |
References opal_bitmap_t::array_size, and opal_bitmap_t::bitmap.
OPAL_DECLSPEC int opal_bitmap_set_bit | ( | opal_bitmap_t * | bm, |
int | bit | ||
) |
Set a bit of the bitmap.
If the bit asked for is beyond the current size of the bitmap, then the bitmap is extended to accomodate the bit
bitmap | The input bitmap (IN) |
bit | The bit which is to be set (IN) |
References opal_bitmap_t::array_size, opal_bitmap_t::bitmap, and opal_bitmap_t::max_size.
Referenced by mca_btl_gm_add_procs(), mca_btl_mx_add_procs(), mca_btl_sctp_add_procs(), mca_btl_self_add_procs(), mca_btl_sm_add_procs(), mca_btl_smcuda_add_procs(), mca_btl_tcp_add_procs(), mca_btl_template_add_procs(), mca_btl_ud_add_procs(), mca_btl_udapl_add_procs(), and opal_bitmap_find_and_set_first_unset_bit().
OPAL_DECLSPEC int opal_bitmap_set_max_size | ( | opal_bitmap_t * | bm, |
int | max_size | ||
) |
Set the maximum size of the bitmap.
May be reset any time, but HAS TO BE SET BEFORE opal_bitmap_init!
bitmap | The input bitmap (IN) |
max_size | The maximum size of the bitmap in terms of bits (IN) |
References opal_bitmap_t::max_size.
Referenced by ompi_attr_init().
|
inlinestatic |
Gives the current size (number of bits) in the bitmap.
This is the legal (accessible) number of bits
bitmap | The input bitmap (IN) |
References opal_bitmap_t::array_size.
Referenced by opal_bitmap_are_different().