1
1

make ompi_free_list_item_t a class..

This will go to the 1.1 branch but will probably require a few changes as
ompi_free_list_t is different in the branch.. 

This commit was SVN r10306.
Этот коммит содержится в:
Galen Shipman 2006-06-12 16:44:00 +00:00
родитель a31a73cb15
Коммит 18dda70fd0
25 изменённых файлов: 65 добавлений и 58 удалений

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

@ -43,6 +43,9 @@ static OBJ_CLASS_INSTANCE(ompi_free_list_memory_t,
opal_list_item_t,
NULL, NULL);
OBJ_CLASS_INSTANCE(ompi_free_list_item_t,
opal_list_item_t,
NULL, NULL);
static void ompi_free_list_construct(ompi_free_list_t* fl)
{

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

@ -57,6 +57,8 @@ struct ompi_free_list_item_t
};
typedef struct ompi_free_list_item_t ompi_free_list_item_t;
OBJ_CLASS_DECLARATION(ompi_free_list_item_t);
/**
* Initialize a free list.
*
@ -110,18 +112,18 @@ OMPI_DECLSPEC int ompi_free_list_parse( ompi_free_list_t* list,
#define OMPI_FREE_LIST_GET(fl, item, rc) \
{ \
if(opal_using_threads()) { \
item = opal_atomic_lifo_pop(&((fl)->super)); \
item = (ompi_free_list_item_t*) opal_atomic_lifo_pop(&((fl)->super)); \
if(NULL == item) { \
opal_mutex_lock(&((fl)->fl_lock)); \
ompi_free_list_grow((fl), (fl)->fl_num_per_alloc); \
opal_mutex_unlock(&((fl)->fl_lock)); \
item = opal_atomic_lifo_pop(&((fl)->super)); \
item = (ompi_free_list_item_t*) opal_atomic_lifo_pop(&((fl)->super)); \
} \
} else { \
item = opal_atomic_lifo_pop(&((fl)->super)); \
item = (ompi_free_list_item_t*) opal_atomic_lifo_pop(&((fl)->super)); \
if(NULL == item) { \
ompi_free_list_grow((fl), (fl)->fl_num_per_alloc); \
item = opal_atomic_lifo_pop(&((fl)->super)); \
item =(ompi_free_list_item_t*) opal_atomic_lifo_pop(&((fl)->super)); \
} \
} \
rc = (NULL == item) ? OMPI_ERR_TEMP_OUT_OF_RESOURCE : OMPI_SUCCESS; \

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

@ -24,7 +24,7 @@
#include "ompi/class/ompi_rb_tree.h"
/* declare the instance of the classes */
OBJ_CLASS_INSTANCE(ompi_rb_tree_node_t, opal_list_item_t, NULL, NULL);
OBJ_CLASS_INSTANCE(ompi_rb_tree_node_t, ompi_free_list_item_t, NULL, NULL);
OBJ_CLASS_INSTANCE(ompi_rb_tree_t, opal_object_t, ompi_rb_tree_construct,
ompi_rb_tree_destruct);
@ -71,7 +71,7 @@ int ompi_rb_tree_init(ompi_rb_tree_t * tree,
{
int rc;
opal_list_item_t * node;
ompi_free_list_item_t * node;
/* we need to get memory for the root pointer from the free list */
OMPI_FREE_LIST_GET(&(tree->free_list), node, rc);
tree->root_ptr = (ompi_rb_tree_node_t *) node;
@ -110,7 +110,7 @@ int ompi_rb_tree_insert(ompi_rb_tree_t *tree, void * key, void * value)
{
ompi_rb_tree_node_t * y;
ompi_rb_tree_node_t * node;
opal_list_item_t * item;
ompi_free_list_item_t * item;
int rc;
/* get the memory for a node */
@ -266,17 +266,17 @@ int ompi_rb_tree_delete(ompi_rb_tree_t *tree, void *key)
/* Destroy the hashmap */
int ompi_rb_tree_destroy(ompi_rb_tree_t *tree)
{
opal_list_item_t * item;
ompi_free_list_item_t * item;
/* Recursive inorder traversal for delete */
inorder_destroy(tree, tree->root_ptr);
/* Now free the root -- root does not get free'd in the above
* inorder destroy */
item = (opal_list_item_t *) tree->root_ptr;
item = (ompi_free_list_item_t *) tree->root_ptr;
OMPI_FREE_LIST_RETURN(&(tree->free_list), item);
/* free the tree->nill node */
item = (opal_list_item_t *) tree->nill;
item = (ompi_free_list_item_t *) tree->nill;
OMPI_FREE_LIST_RETURN(&(tree->free_list), item);
return(OMPI_SUCCESS);
}
@ -411,7 +411,7 @@ void btree_delete_fixup(ompi_rb_tree_t *tree, ompi_rb_tree_node_t * x)
void
inorder_destroy(ompi_rb_tree_t *tree, ompi_rb_tree_node_t * node)
{
opal_list_item_t * item;
ompi_free_list_item_t * item;
if (node == tree->nill) {
return;
@ -420,14 +420,14 @@ inorder_destroy(ompi_rb_tree_t *tree, ompi_rb_tree_node_t * node)
inorder_destroy(tree, node->left);
if (node->left != tree->nill) {
item = (opal_list_item_t *) node->left;
item = (ompi_free_list_item_t *) node->left;
--tree->tree_size;
OMPI_FREE_LIST_RETURN(&(tree->free_list), item);
}
inorder_destroy(tree, node->right);
if (node->right != tree->nill) {
item = (opal_list_item_t *) node->right;
item = (ompi_free_list_item_t *) node->right;
--tree->tree_size;
OMPI_FREE_LIST_RETURN(&(tree->free_list), item);
}

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

@ -47,7 +47,7 @@ typedef enum {RED, BLACK} ompi_rb_tree_nodecolor_t;
*/
struct ompi_rb_tree_node_t
{
opal_list_item_t super; /**< the parent class */
ompi_free_list_item_t super; /**< the parent class */
ompi_rb_tree_nodecolor_t color; /**< the node color */
struct ompi_rb_tree_node_t * parent;/**< the parent node, can be NULL */
struct ompi_rb_tree_node_t * left; /**< the left child - can be nill */

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

@ -54,7 +54,7 @@ mca_allocator_base_component_t mca_allocator_basic_component = {
OBJ_CLASS_INSTANCE(
mca_allocator_basic_segment_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL);
@ -123,7 +123,7 @@ static void mca_allocator_basic_combine_prev(
mca_allocator_basic_segment_t *prev = (mca_allocator_basic_segment_t*)item;
if(prev->seg_addr + prev->seg_size == seg->seg_addr) {
prev->seg_size += seg->seg_size;
opal_list_remove_item(&module->seg_list, &seg->seg_item);
opal_list_remove_item(&module->seg_list, &seg->seg_item.super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, &seg->seg_item);
return;
}
@ -140,7 +140,7 @@ static void mca_allocator_basic_combine_next(
if(seg->seg_addr + seg->seg_size == next->seg_addr) {
next->seg_addr = seg->seg_addr;
next->seg_size += seg->seg_size;
opal_list_remove_item(&module->seg_list, &seg->seg_item);
opal_list_remove_item(&module->seg_list, &seg->seg_item.super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, &seg->seg_item);
return;
}
@ -167,16 +167,16 @@ void *mca_allocator_basic_alloc(
{
mca_allocator_basic_module_t* module = (mca_allocator_basic_module_t*)base;
mca_allocator_basic_segment_t* seg;
opal_list_item_t* item;
ompi_free_list_item_t* item;
unsigned char* addr;
size_t allocated_size;
OPAL_THREAD_LOCK(&module->seg_lock);
/* search the list for a segment of the required size */
size += sizeof(size_t);
for(item = opal_list_get_first(&module->seg_list);
item != opal_list_get_end(&module->seg_list);
item = opal_list_get_next(item)) {
for(item = (ompi_free_list_item_t*) opal_list_get_first(&module->seg_list);
item != (ompi_free_list_item_t*) opal_list_get_end(&module->seg_list);
item = (ompi_free_list_item_t*) opal_list_get_next(&item->super)) {
seg = (mca_allocator_basic_segment_t*)item;
/* split the segment */
@ -189,7 +189,7 @@ void *mca_allocator_basic_alloc(
return addr+sizeof(size_t);
} else if (seg->seg_size == size) {
addr = seg->seg_addr;
opal_list_remove_item(&module->seg_list, item);
opal_list_remove_item(&module->seg_list, &item->super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, item);
OPAL_THREAD_UNLOCK(&module->seg_lock);
*(size_t*)addr = size;
@ -215,7 +215,7 @@ void *mca_allocator_basic_alloc(
seg = (mca_allocator_basic_segment_t*)item;
seg->seg_addr = addr + size;
seg->seg_size = allocated_size - size;
opal_list_append(&module->seg_list, item);
opal_list_append(&module->seg_list, &item->super);
}
*(size_t*)addr = size;
@ -274,16 +274,16 @@ void mca_allocator_basic_free(
{
mca_allocator_basic_module_t* module = (mca_allocator_basic_module_t*)base;
mca_allocator_basic_segment_t* seg;
opal_list_item_t *item;
ompi_free_list_item_t *item;
unsigned char* addr = (unsigned char*)ptr - sizeof(size_t);
size_t size = *(size_t*)addr;
int rc;
OPAL_THREAD_LOCK(&module->seg_lock);
/* maintain the free list in sorted order by address */
for(item = opal_list_get_first(&module->seg_list);
item != opal_list_get_end(&module->seg_list);
item = opal_list_get_next(item)) {
for(item = (ompi_free_list_item_t*) opal_list_get_first(&module->seg_list);
item != (ompi_free_list_item_t*) opal_list_get_end(&module->seg_list);
item = (ompi_free_list_item_t*) opal_list_get_next((&item->super))) {
seg = (mca_allocator_basic_segment_t*)item;
if (seg->seg_addr < addr) {
@ -315,10 +315,11 @@ void mca_allocator_basic_free(
OPAL_THREAD_UNLOCK(&module->seg_lock);
return;
}
new_seg = (mca_allocator_basic_segment_t*)item;
new_seg = (
mca_allocator_basic_segment_t*)item;
new_seg->seg_addr = addr;
new_seg->seg_size = size;
opal_list_insert_pos(&module->seg_list, &seg->seg_item, item);
opal_list_insert_pos(&module->seg_list, &seg->seg_item.super, &item->super);
OPAL_THREAD_UNLOCK(&module->seg_lock);
return;
}
@ -334,7 +335,7 @@ void mca_allocator_basic_free(
seg = (mca_allocator_basic_segment_t*)item;
seg->seg_addr = addr;
seg->seg_size = size;
opal_list_append(&module->seg_list, item);
opal_list_append(&module->seg_list, &item->super);
OPAL_THREAD_UNLOCK(&module->seg_lock);
}

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

@ -36,7 +36,7 @@
*/
struct mca_allocator_basic_segment_t {
opal_list_item_t seg_item;
ompi_free_list_item_t seg_item;
unsigned char* seg_addr;
size_t seg_size;
};

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

@ -122,7 +122,7 @@ int mca_io_base_request_alloc(ompi_file_t *file,
{
int err;
mca_io_base_module_request_once_init_fn_t func;
opal_list_item_t *item;
ompi_free_list_item_t *item;
/* See if we've got a request on the module's freelist (which is
cached on the file, since there's only one module per

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

@ -24,7 +24,7 @@
#include "mpool_base_tree.h"
OBJ_CLASS_INSTANCE(mca_mpool_base_tree_item_t, opal_list_item_t, NULL, NULL);
OBJ_CLASS_INSTANCE(mca_mpool_base_tree_item_t, ompi_free_list_item_t, NULL, NULL);
/*
* use globals for the tree and the tree_item free list..
@ -96,7 +96,7 @@ mca_mpool_base_tree_item_t* mca_mpool_base_tree_find(void* base) {
* get a tree item from the free list
*/
mca_mpool_base_tree_item_t* mca_mpool_base_tree_item_get(void) {
opal_list_item_t* item = NULL;
ompi_free_list_item_t* item = NULL;
int rc;
OMPI_FREE_LIST_GET(&mca_mpool_base_tree_item_free_list,
item,

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

@ -99,7 +99,7 @@ int mca_mpool_mvapi_register(
mca_mpool_mvapi_registration_t * vapi_reg;
VAPI_mrw_t mr_in, mr_out;
VAPI_ret_t ret;
opal_list_item_t *item;
ompi_free_list_item_t *item;
int rc;
@ -240,7 +240,7 @@ int mca_mpool_mvapi_release(
opal_output(0, "%s: error unpinning vapi memory\n", __func__);
return OMPI_ERROR;
}
OMPI_FREE_LIST_RETURN(&mpool_mvapi->reg_list, (opal_list_item_t*) vapi_reg);
OMPI_FREE_LIST_RETURN(&mpool_mvapi->reg_list, (ompi_free_list_item_t*) vapi_reg);
}
return OMPI_SUCCESS;
}

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

@ -90,7 +90,7 @@ int mca_mpool_openib_register(mca_mpool_base_module_t* mpool,
mca_mpool_openib_module_t * mpool_module = (mca_mpool_openib_module_t*) mpool;
mca_mpool_openib_registration_t * vapi_reg;
opal_list_item_t *item;
ompi_free_list_item_t *item;
int rc;
OMPI_FREE_LIST_GET(&mpool_module->reg_list, item, rc);
@ -217,7 +217,7 @@ int mca_mpool_openib_release(
opal_output(0, "%s: error unpinning openib memory errno says %s\n", __func__, strerror(errno));
return OMPI_ERROR;
}
OMPI_FREE_LIST_RETURN(&mpool_openib->reg_list, (opal_list_item_t*) openib_reg);
OMPI_FREE_LIST_RETURN(&mpool_openib->reg_list, (ompi_free_list_item_t*) openib_reg);
}
return OMPI_SUCCESS;
}

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

@ -62,14 +62,14 @@ do {
OBJ_CLASS_INSTANCE(
mca_pml_dr_buffer_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL
);
OBJ_CLASS_INSTANCE(
mca_pml_dr_recv_frag_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL
);

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

@ -27,7 +27,7 @@
#include "pml_dr_hdr.h"
struct mca_pml_dr_buffer_t {
opal_list_item_t super;
ompi_free_list_item_t super;
size_t len;
unsigned char addr[1];
};
@ -37,7 +37,7 @@ OBJ_CLASS_DECLARATION(mca_pml_dr_buffer_t);
struct mca_pml_dr_recv_frag_t {
opal_list_item_t super;
ompi_free_list_item_t super;
mca_pml_dr_hdr_t hdr;
struct mca_pml_dr_recv_request_t* request;
size_t num_segments;

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

@ -66,7 +66,7 @@ OBJ_CLASS_DECLARATION(mca_pml_dr_recv_request_t);
*/
#define MCA_PML_DR_RECV_REQUEST_ALLOC(recvreq, rc) \
do { \
opal_list_item_t* item; \
ompi_free_list_item_t* item; \
rc = OMPI_SUCCESS; \
OMPI_FREE_LIST_GET(&mca_pml_dr.recv_requests, item, rc); \
recvreq = (mca_pml_dr_recv_request_t*)item; \

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

@ -56,7 +56,7 @@ static void mca_pml_dr_vfrag_destruct(mca_pml_dr_vfrag_t* vfrag)
OBJ_CLASS_INSTANCE(
mca_pml_dr_vfrag_t,
opal_list_item_t,
ompi_free_list_item_t,
mca_pml_dr_vfrag_construct,
mca_pml_dr_vfrag_destruct
);

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

@ -34,7 +34,7 @@ extern "C" {
#define MCA_PML_DR_VFRAG_RETRANS 0x04
struct mca_pml_dr_vfrag_t {
opal_list_item_t super;
ompi_free_list_item_t super;
ompi_ptr_t vf_send;
ompi_ptr_t vf_recv;
uint32_t vf_id;

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

@ -133,6 +133,7 @@ int mca_pml_ob1_component_open(void)
NULL);
OBJ_CONSTRUCT(&mca_pml_ob1.recv_frags, ompi_free_list_t);
ompi_free_list_init(
&mca_pml_ob1.recv_frags,
sizeof(mca_pml_ob1_recv_frag_t),

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

@ -24,6 +24,6 @@
OBJ_CLASS_INSTANCE(
mca_pml_ob1_rdma_frag_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL);

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

@ -34,7 +34,7 @@ typedef enum {
} mca_pml_ob1_rdma_state_t;
struct mca_pml_ob1_rdma_frag_t {
opal_list_item_t super;
ompi_free_list_item_t super;
mca_btl_base_module_t* rdma_btl;
mca_pml_ob1_hdr_t rdma_hdr;
mca_pml_ob1_rdma_state_t rdma_state;

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

@ -38,7 +38,7 @@
OBJ_CLASS_INSTANCE(
mca_pml_ob1_buffer_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL
);

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

@ -27,7 +27,7 @@
#include "pml_ob1_hdr.h"
struct mca_pml_ob1_buffer_t {
opal_list_item_t super;
ompi_free_list_item_t super;
size_t len;
unsigned char addr[1];
};
@ -37,7 +37,7 @@ OBJ_CLASS_DECLARATION(mca_pml_ob1_buffer_t);
struct mca_pml_ob1_recv_frag_t {
opal_list_item_t super;
ompi_free_list_item_t super;
mca_pml_ob1_hdr_t hdr;
struct mca_pml_ob1_recv_request_t* request;
size_t num_segments;

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

@ -65,7 +65,7 @@ OBJ_CLASS_DECLARATION(mca_pml_ob1_recv_request_t);
*/
#define MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq, rc) \
do { \
opal_list_item_t* item; \
ompi_free_list_item_t* item; \
rc = OMPI_SUCCESS; \
OMPI_FREE_LIST_GET(&mca_pml_ob1.recv_requests, item, rc); \
recvreq = (mca_pml_ob1_recv_request_t*)item; \

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

@ -24,7 +24,7 @@
#include "rcache_rb_tree.h"
OBJ_CLASS_INSTANCE(mca_rcache_rb_tree_item_t, opal_list_item_t, NULL, NULL);
OBJ_CLASS_INSTANCE(mca_rcache_rb_tree_item_t, ompi_free_list_item_t, NULL, NULL);
int mca_rcache_rb_tree_node_compare(void * key1, void * key2);
@ -106,7 +106,7 @@ int mca_rcache_rb_tree_insert(
mca_mpool_base_registration_t* reg
)
{
opal_list_item_t *item;
ompi_free_list_item_t *item;
int rc;
mca_rcache_rb_tree_item_t* rb_tree_item;

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

@ -65,7 +65,7 @@ static int ompi_request_empty_free(ompi_request_t** request)
OBJ_CLASS_INSTANCE(
ompi_request_t,
opal_list_item_t,
ompi_free_list_item_t,
ompi_request_construct,
ompi_request_destruct);

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

@ -25,7 +25,7 @@
#define OMPI_REQUEST_H
#include "mpi.h"
#include "opal/class/opal_list.h"
#include "ompi/class/ompi_free_list.h"
#include "ompi/class/ompi_pointer_array.h"
#include "ompi/errhandler/errhandler.h"
#include "opal/threads/condition.h"
@ -83,7 +83,7 @@ typedef int (*ompi_request_cancel_fn_t)(struct ompi_request_t* request, int flag
* Main top-level request struct definition
*/
struct ompi_request_t {
opal_list_item_t super; /**< Base type */
ompi_free_list_item_t super; /**< Base type */
ompi_request_type_t req_type; /**< Enum indicating the type of the request */
ompi_status_public_t req_status; /**< Completion status */
volatile bool req_complete; /**< Flag indicating wether request has completed */

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

@ -272,14 +272,14 @@ typedef struct ompi_test_rb_key_t ompi_test_rb_key_t;
struct ompi_test_rb_value_t
{
opal_list_item_t super; /* the parent class */
ompi_free_list_item_t super; /* the parent class */
ompi_test_rb_key_t key; /* the key which holds the memory pointers */
mca_mpool_base_module_t* registered_mpools[MAX_REGISTRATIONS];
/* the mpools the memory is registered with */
};
typedef struct ompi_test_rb_value_t ompi_test_rb_value_t;
OBJ_CLASS_INSTANCE(ompi_test_rb_value_t, opal_list_item_t, NULL, NULL);
OBJ_CLASS_INSTANCE(ompi_test_rb_value_t, ompi_free_list_item_t, NULL, NULL);
int mem_node_compare(void * key1, void * key2)
{