2005-05-24 17:39:15 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-09-01 21:38:04 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-24 17:39:15 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2005-09-01 21:38:04 +04:00
|
|
|
*
|
2005-05-24 17:39:15 +04:00
|
|
|
* Additional copyrights may follow
|
2005-09-01 21:38:04 +04:00
|
|
|
*
|
2005-05-24 17:39:15 +04:00
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file
|
2005-05-26 17:12:11 +04:00
|
|
|
*
|
|
|
|
* See ompi_bitmap.h for an explanation of why there is a split
|
|
|
|
* between OMPI and ORTE for this generic class.
|
2005-05-24 17:39:15 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ORTE_BITMAP_H
|
|
|
|
#define ORTE_BITMAP_H
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
2006-08-15 23:54:10 +04:00
|
|
|
#include "orte/orte_types.h"
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/types.h"
|
2005-07-03 20:06:07 +04:00
|
|
|
#include "opal/class/opal_object.h"
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
struct orte_bitmap_t {
|
2005-07-03 20:06:07 +04:00
|
|
|
opal_object_t super; /**< Subclass of opal_object_t */
|
2005-05-24 17:39:15 +04:00
|
|
|
unsigned char *bitmap; /**< The actual bitmap array of characters */
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t array_size; /**< The actual array size that maintains the bitmap */
|
|
|
|
orte_std_cntr_t legal_numbits; /**< The number of bits which are legal (the
|
2005-09-01 21:38:04 +04:00
|
|
|
actual bitmap may contain more bits, since
|
|
|
|
it needs to be rounded to the nearest
|
|
|
|
char */
|
2005-05-24 17:39:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct orte_bitmap_t orte_bitmap_t;
|
|
|
|
|
|
|
|
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_bitmap_t);
|
|
|
|
|
|
|
|
|
2005-06-08 19:48:38 +04:00
|
|
|
/**
|
|
|
|
* Sizes the bitmap to ensure it has at least the specified number of
|
|
|
|
* bits in it. If it already does, then nothing happens. However, if the
|
|
|
|
* bitmap is too small, then it is resized to accommodate the bit, with
|
|
|
|
* all bits in the new space "cleared"
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @param bit The bit that must be "covered" by the bitmap (IN)
|
|
|
|
* @return ORTE error code or success
|
|
|
|
*
|
|
|
|
*/
|
2006-08-15 23:54:10 +04:00
|
|
|
OMPI_DECLSPEC int orte_bitmap_resize(orte_bitmap_t *bm, orte_std_cntr_t bit);
|
2005-06-08 19:48:38 +04:00
|
|
|
|
|
|
|
|
2005-05-24 17:39:15 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @param bit The bit which is to be set (IN)
|
|
|
|
* @return OMPI error code or success
|
|
|
|
*
|
|
|
|
*/
|
2006-08-15 23:54:10 +04:00
|
|
|
OMPI_DECLSPEC int orte_bitmap_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear/unset a bit of the bitmap. If the bit is beyond the current
|
|
|
|
* size of the bitmap, an error is returned
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @param bit The bit which is to be cleared (IN)
|
|
|
|
* @return ORTE error code if the bit is out of range, else success
|
|
|
|
*
|
|
|
|
*/
|
2006-08-15 23:54:10 +04:00
|
|
|
OMPI_DECLSPEC int orte_bitmap_clear_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find out if a bit is set in the bitmap
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @param bit The bit which is to be checked (IN)
|
|
|
|
* @return ORTE error code if the bit is out of range
|
|
|
|
* 1 if the bit is set
|
|
|
|
* 0 if the bit is not set
|
|
|
|
*
|
|
|
|
*/
|
2006-08-15 23:54:10 +04:00
|
|
|
OMPI_DECLSPEC int orte_bitmap_is_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the first clear bit in the bitmap and set it
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @param position Position of the first clear bit (OUT)
|
|
|
|
|
|
|
|
* @return err ORTE_SUCCESS on success
|
|
|
|
*/
|
2005-09-01 21:38:04 +04:00
|
|
|
OMPI_DECLSPEC int orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm,
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t *position);
|
2005-05-24 17:39:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear all bits in the bitmap
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @return ORTE error code if bm is NULL
|
2005-09-01 21:38:04 +04:00
|
|
|
*
|
2005-05-24 17:39:15 +04:00
|
|
|
*/
|
|
|
|
OMPI_DECLSPEC int orte_bitmap_clear_all_bits(orte_bitmap_t *bm);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set all bits in the bitmap
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @return ORTE error code if bm is NULL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
OMPI_DECLSPEC int orte_bitmap_set_all_bits(orte_bitmap_t *bm);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gives the current size (number of bits) in the bitmap. This is the
|
|
|
|
* legal (accessible) number of bits
|
|
|
|
*
|
|
|
|
* @param bitmap The input bitmap (IN)
|
|
|
|
* @return ORTE error code if bm is NULL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static inline int orte_bitmap_size(orte_bitmap_t *bm)
|
|
|
|
{
|
|
|
|
return (NULL == bm) ? 0 : bm->legal_numbits;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2005-09-01 21:38:04 +04:00
|
|
|
|
2005-05-24 17:39:15 +04:00
|
|
|
#endif
|