1
1

Few cleanups. The most important is getting rid of the orte_bitmap_t class

which is not used anymore in the orte code.

This commit was SVN r14336.
Этот коммит содержится в:
George Bosilca 2007-04-12 05:50:33 +00:00
родитель 10dfd534f6
Коммит 5c65c55e59
6 изменённых файлов: 26 добавлений и 465 удалений

Просмотреть файл

@ -3,7 +3,7 @@
# 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
# Copyright (c) 2004-2007 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -21,12 +21,10 @@
headers += \
class/orte_proc_table.h \
class/orte_bitmap.h \
class/orte_pointer_array.h \
class/orte_value_array.h
libopen_rte_la_SOURCES += \
class/orte_proc_table.c \
class/orte_bitmap.c \
class/orte_pointer_array.c \
class/orte_value_array.c

Просмотреть файл

@ -1,250 +0,0 @@
/*
* 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.
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include "orte/orte_constants.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/class/orte_bitmap.h"
#define SIZE_OF_CHAR (sizeof(char) * 8)
#define DEFAULT_BITMAP_SIZE 64
static void orte_bitmap_construct(orte_bitmap_t *bm);
static void orte_bitmap_destruct(orte_bitmap_t *bm);
OBJ_CLASS_INSTANCE(
orte_bitmap_t,
opal_object_t,
orte_bitmap_construct,
orte_bitmap_destruct
);
static void
orte_bitmap_construct(orte_bitmap_t *bm)
{
orte_std_cntr_t size;
size = DEFAULT_BITMAP_SIZE / SIZE_OF_CHAR;
bm->array_size = size + ((size % SIZE_OF_CHAR == 0) ? 0 : 1);
bm->bitmap = (unsigned char *) malloc(bm->array_size);
bm->legal_numbits = SIZE_OF_CHAR*bm->array_size;
memset(bm->bitmap, 0, bm->array_size);
}
static void
orte_bitmap_destruct(orte_bitmap_t *bm)
{
if (NULL != bm->bitmap) {
free(bm->bitmap);
}
}
int
orte_bitmap_resize(orte_bitmap_t *bm, orte_std_cntr_t bit)
{
orte_std_cntr_t index, new_size, i;
index = bit / SIZE_OF_CHAR;
index += (bit % SIZE_OF_CHAR == 0) ? 0 : 1;
if (index >= bm->array_size) {
/* We need to allocate more space for the bitmap, since we are
out of range. We dont throw any error here, because this is
valid and we simply expand the bitmap */
new_size = (index / bm->array_size + 1 ) * bm->array_size;
/* New size is just a multiple of the original size to fit in
the index. */
bm->bitmap = (unsigned char *) realloc(bm->bitmap, new_size);
if (NULL == bm->bitmap) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* zero out the new elements */
for (i = bm->array_size; i < new_size; ++i) {
bm->bitmap[i] = 0;
}
/* Update the array_size */
bm->array_size = new_size;
bm->legal_numbits = new_size*SIZE_OF_CHAR;
}
return ORTE_SUCCESS;
}
int
orte_bitmap_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit)
{
orte_std_cntr_t index, offset;
int rc;
if (NULL == bm) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* make sure the bitmap covers the requested bit */
if (ORTE_SUCCESS != (rc = orte_bitmap_resize(bm, bit))) {
ORTE_ERROR_LOG(rc);
return rc;
}
index = bit / SIZE_OF_CHAR;
offset = bit % SIZE_OF_CHAR;
/* Now set the bit */
bm->bitmap[index] |= (1 << offset);
return ORTE_SUCCESS;
}
int
orte_bitmap_clear_bit(orte_bitmap_t *bm, orte_std_cntr_t bit)
{
orte_std_cntr_t index, offset;
int rc;
if (NULL == bm) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* make sure the bitmap covers the requested bit */
if (ORTE_SUCCESS != (rc = orte_bitmap_resize(bm, bit))) {
ORTE_ERROR_LOG(rc);
return rc;
}
index = bit / SIZE_OF_CHAR;
offset = bit % SIZE_OF_CHAR;
/* now clear the bit */
bm->bitmap[index] &= ~(1 << offset);
return ORTE_SUCCESS;
}
int
orte_bitmap_is_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit)
{
orte_std_cntr_t index, offset;
if ((bit > bm->legal_numbits - 1) || (NULL == bm)) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
index = bit / SIZE_OF_CHAR;
offset = bit % SIZE_OF_CHAR;
if (index >= bm->array_size) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
if (0 != (bm->bitmap[index] & (1 << offset))) {
return (int) true;
}
return (int) false;
}
int
orte_bitmap_clear_all_bits(orte_bitmap_t *bm)
{
if (NULL == bm) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
memset(bm->bitmap, 0, bm->array_size);
return ORTE_SUCCESS;
}
int
orte_bitmap_set_all_bits(orte_bitmap_t *bm)
{
orte_std_cntr_t i;
if (NULL == bm) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
for (i = 0; i < bm->array_size; ++i) {
bm->bitmap[i] = ~((char) 0);
}
return ORTE_SUCCESS;
}
int
orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm, orte_std_cntr_t *position)
{
orte_std_cntr_t i = 0;
unsigned char temp;
unsigned char all_ones = 0xff;
if (NULL == bm || NULL == position) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* Neglect all which don't have an unset bit */
*position = 0;
while((i < bm->array_size) && (bm->bitmap[i] == all_ones)) {
++i;
}
if (i == bm->array_size) {
/* increase the bitmap size then */
*position = bm->array_size * SIZE_OF_CHAR;
return orte_bitmap_set_bit(bm, *position);
}
/* This one has an unset bit, find its bit number */
temp = bm->bitmap[i];
while (temp & 0x1) {
++(*position);
temp >>= 1;
}
/* Now set the bit number */
bm->bitmap[i] |= (bm->bitmap[i] + 1);
(*position) += i * SIZE_OF_CHAR;
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,166 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
/** @file
*
* See ompi_bitmap.h for an explanation of why there is a split
* between OMPI and ORTE for this generic class.
*
* 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"
#include "orte/orte_types.h"
#include <string.h>
#include "opal/types.h"
#include "opal/class/opal_object.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
struct orte_bitmap_t {
opal_object_t super; /**< Subclass of opal_object_t */
unsigned char *bitmap; /**< The actual bitmap array of characters */
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
actual bitmap may contain more bits, since
it needs to be rounded to the nearest
char */
};
typedef struct orte_bitmap_t orte_bitmap_t;
ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_bitmap_t);
/**
* 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
*
*/
ORTE_DECLSPEC int orte_bitmap_resize(orte_bitmap_t *bm, orte_std_cntr_t 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
*
* @param bitmap The input bitmap (IN)
* @param bit The bit which is to be set (IN)
* @return OMPI error code or success
*
*/
ORTE_DECLSPEC int orte_bitmap_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
/**
* 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
*
*/
ORTE_DECLSPEC int orte_bitmap_clear_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
/**
* 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
*
*/
ORTE_DECLSPEC int orte_bitmap_is_set_bit(orte_bitmap_t *bm, orte_std_cntr_t bit);
/**
* 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
*/
ORTE_DECLSPEC int orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm,
orte_std_cntr_t *position);
/**
* Clear all bits in the bitmap
*
* @param bitmap The input bitmap (IN)
* @return ORTE error code if bm is NULL
*
*/
ORTE_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
*
*/
ORTE_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 : (int)bm->legal_numbits;
}
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -23,20 +23,14 @@
#ifndef ORTE_GPR_REPLICA_H
#define ORTE_GPR_REPLICA_H
#include "orte_config.h"
#include <time.h>
#include "orte/class/orte_bitmap.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/class/orte_value_array.h"
#include "opal/threads/mutex.h"
#include "opal/threads/condition.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/class/orte_value_array.h"
#include "orte/mca/ns/ns_types.h"
#include "orte/mca/gpr/base/base.h"
#if defined(c_plusplus) || defined(__cplusplus)
@ -125,7 +119,6 @@ typedef struct {
orte_pointer_array_t *srch_ival;
orte_std_cntr_t num_acted_upon;
orte_pointer_array_t *acted_upon;
orte_bitmap_t srch_itag;
} orte_gpr_replica_globals_t;
@ -430,21 +423,6 @@ typedef struct orte_gpr_replica_write_invalidate_t orte_gpr_replica_write_invali
extern orte_gpr_replica_t orte_gpr_replica;
extern orte_gpr_replica_globals_t orte_gpr_replica_globals;
/*
* Module open / close
*/
int orte_gpr_replica_open(void);
int orte_gpr_replica_close(void);
/*
* Startup / Shutdown
*/
orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority);
int orte_gpr_replica_finalize(void);
int orte_gpr_replica_module_init(void);
int orte_gpr_replica_ft_event(int state);
ORTE_MODULE_DECLSPEC extern mca_gpr_base_component_t mca_gpr_replica_component;

Просмотреть файл

@ -3,7 +3,7 @@
* 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
* Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -25,9 +25,6 @@
#include "orte_config.h"
#include "orte/class/orte_bitmap.h"
#include "opal/class/opal_object.h"
#include "gpr_replica.h"
/*

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2007 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
* Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -27,20 +27,27 @@
*/
#include "orte_config.h"
#include "orte/class/orte_bitmap.h"
#include "opal/class/opal_object.h"
#include "opal/util/output.h"
#include "opal/util/trace.h"
#include "orte/util/proc_info.h"
#include "orte/mca/rml/rml.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/replica/gpr_replica.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/errmgr/errmgr.h"
/*
* Static functions.
*/
static orte_gpr_base_module_t*
orte_gpr_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads,
int *priority);
static int orte_gpr_replica_finalize(void);
static int orte_gpr_replica_open(void);
static int orte_gpr_replica_close(void);
static int orte_gpr_replica_module_init(void);
/*
* Struct of function pointers that need to be initialized
@ -141,7 +148,7 @@ orte_gpr_replica_globals_t orte_gpr_replica_globals;
/* instantiate the classes */
#include "orte/mca/gpr/replica/gpr_replica_class_instances.h"
int orte_gpr_replica_open(void)
static int orte_gpr_replica_open(void)
{
int id, tmp;
@ -169,14 +176,16 @@ int orte_gpr_replica_open(void)
/*
* close function
*/
int orte_gpr_replica_close(void)
static int orte_gpr_replica_close(void)
{
OPAL_TRACE(5);
return ORTE_SUCCESS;
}
orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority)
static orte_gpr_base_module_t*
orte_gpr_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads,
int *priority)
{
int rc;
@ -290,8 +299,6 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
}
orte_gpr_replica_globals.num_acted_upon = 0;
OBJ_CONSTRUCT(&(orte_gpr_replica_globals.srch_itag), orte_bitmap_t);
if (orte_gpr_replica_globals.debug) {
opal_output(0, "nb receive setup");
}
@ -300,13 +307,11 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
initialized = true;
return &orte_gpr_replica_module;
} else {
return NULL;
}
return NULL;
}
int orte_gpr_replica_module_init(void)
static int orte_gpr_replica_module_init(void)
{
OPAL_TRACE(5);
@ -326,7 +331,7 @@ int orte_gpr_replica_module_init(void)
/*
* finalize routine
*/
int orte_gpr_replica_finalize(void)
static int orte_gpr_replica_finalize(void)
{
orte_std_cntr_t i;
orte_gpr_subscription_id_t j;
@ -432,8 +437,6 @@ int orte_gpr_replica_finalize(void)
OBJ_RELEASE(orte_gpr_replica_globals.acted_upon);
}
OBJ_DESTRUCT(&(orte_gpr_replica_globals.srch_itag));
/* All done */
if (orte_gpr_replica_globals.isolate) {
return ORTE_SUCCESS;
@ -443,3 +446,4 @@ int orte_gpr_replica_finalize(void)
return ORTE_SUCCESS;
}