1
1

* change ompi -> opal and remove the mpool code

This commit was SVN r6295.
Этот коммит содержится в:
Brian Barrett 2005-07-02 15:42:29 +00:00
родитель aa14a515e5
Коммит 957ac4fe3d
2 изменённых файлов: 31 добавлений и 43 удалений

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

@ -16,23 +16,23 @@
#include "ompi_config.h"
#include "class/ompi_free_list.h"
#include "class/opal_free_list.h"
#include "include/sys/cache.h"
static void ompi_free_list_construct(ompi_free_list_t* fl);
static void ompi_free_list_destruct(ompi_free_list_t* fl);
static void opal_free_list_construct(opal_free_list_t* fl);
static void opal_free_list_destruct(opal_free_list_t* fl);
ompi_class_t ompi_free_list_t_class = {
"ompi_free_list_t",
ompi_class_t opal_free_list_t_class = {
"opal_free_list_t",
OBJ_CLASS(ompi_list_t),
(ompi_construct_t)ompi_free_list_construct,
(ompi_destruct_t)ompi_free_list_destruct
(ompi_construct_t)opal_free_list_construct,
(ompi_destruct_t)opal_free_list_destruct
};
static void ompi_free_list_construct(ompi_free_list_t* fl)
static void opal_free_list_construct(opal_free_list_t* fl)
{
OBJ_CONSTRUCT(&fl->fl_lock, ompi_mutex_t);
fl->fl_max_to_alloc = 0;
@ -44,46 +44,40 @@ static void ompi_free_list_construct(ompi_free_list_t* fl)
fl->fl_mpool = 0;
}
static void ompi_free_list_destruct(ompi_free_list_t* fl)
static void opal_free_list_destruct(opal_free_list_t* fl)
{
OBJ_DESTRUCT(&fl->fl_lock);
}
int ompi_free_list_init(
ompi_free_list_t *flist,
int opal_free_list_init(
opal_free_list_t *flist,
size_t elem_size,
ompi_class_t* elem_class,
int num_elements_to_alloc,
int max_elements_to_alloc,
int num_elements_per_alloc,
mca_mpool_base_module_t* mpool)
int num_elements_per_alloc)
{
flist->fl_elem_size = elem_size;
flist->fl_elem_class = elem_class;
flist->fl_max_to_alloc = max_elements_to_alloc;
flist->fl_num_allocated = 0;
flist->fl_num_per_alloc = num_elements_per_alloc;
flist->fl_mpool = mpool;
if(num_elements_to_alloc)
return ompi_free_list_grow(flist, num_elements_to_alloc);
return opal_free_list_grow(flist, num_elements_to_alloc);
return OMPI_SUCCESS;
}
int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elements)
int opal_free_list_grow(opal_free_list_t* flist, size_t num_elements)
{
unsigned char* ptr;
size_t i;
size_t mod;
mca_mpool_base_registration_t* user_out;
if (flist->fl_max_to_alloc > 0 && flist->fl_num_allocated + num_elements > flist->fl_max_to_alloc)
return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
if (NULL != flist->fl_mpool)
ptr = (unsigned char*)flist->fl_mpool->mpool_alloc(flist->fl_mpool, (num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE, 0, &user_out);
else
ptr = (unsigned char *)malloc((num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE);
ptr = (unsigned char *)malloc((num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE);
if(NULL == ptr)
return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
@ -93,8 +87,8 @@ int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elements)
}
for(i=0; i<num_elements; i++) {
ompi_free_list_item_t* item = (ompi_free_list_item_t*)ptr;
item->user_data = user_out;
opal_free_list_item_t* item = (opal_free_list_item_t*)ptr;
item->user_data = NULL;
if (NULL != flist->fl_elem_class) {
OBJ_CONSTRUCT_INTERNAL(item, flist->fl_elem_class);
}

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

@ -22,16 +22,14 @@
#include "threads/thread.h"
#include "threads/condition.h"
#include "include/constants.h"
#include "mca/mpool/mpool.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OMPI_DECLSPEC extern ompi_class_t ompi_free_list_t_class;
struct mca_mem_pool_t;
OMPI_DECLSPEC extern ompi_class_t opal_free_list_t_class;
struct ompi_free_list_t
struct opal_free_list_t
{
ompi_list_t super;
size_t fl_max_to_alloc;
@ -40,19 +38,17 @@ struct ompi_free_list_t
size_t fl_num_waiting;
size_t fl_elem_size;
ompi_class_t* fl_elem_class;
mca_mpool_base_module_t* fl_mpool;
ompi_mutex_t fl_lock;
ompi_condition_t fl_condition;
};
typedef struct ompi_free_list_t ompi_free_list_t;
typedef struct opal_free_list_t opal_free_list_t;
struct ompi_free_list_item_t
struct opal_free_list_item_t
{
ompi_list_item_t super;
void* user_data;
};
typedef struct ompi_free_list_item_t ompi_free_list_item_t;
typedef struct opal_free_list_item_t opal_free_list_item_t;
/**
* Initialize a free list.
@ -63,19 +59,17 @@ typedef struct ompi_free_list_item_t ompi_free_list_item_t;
* @param num_elements_to_alloc Initial number of elements to allocate.
* @param max_elements_to_alloc Maximum number of elements to allocate.
* @param num_elements_per_alloc Number of elements to grow by per allocation.
* @param mpool Optional memory pool for allocation.s
*/
OMPI_DECLSPEC int ompi_free_list_init(
OMPI_DECLSPEC int opal_free_list_init(
ompi_free_list_t *free_list,
size_t element_size,
ompi_class_t* element_class,
int num_elements_to_alloc,
int max_elements_to_alloc,
int num_elements_per_alloc,
mca_mpool_base_module_t*);
int num_elements_per_alloc);
OMPI_DECLSPEC int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elements);
OMPI_DECLSPEC int opal_free_list_grow(opal_free_list_t* flist, size_t num_elements);
/**
* Attemp to obtain an item from a free list.
@ -90,20 +84,20 @@ OMPI_DECLSPEC int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elemen
* returned to the caller.
*/
#define OMPI_FREE_LIST_GET(fl, item, rc) \
#define OPAL_FREE_LIST_GET(fl, item, rc) \
{ \
if(ompi_using_threads()) { \
ompi_mutex_lock(&((fl)->fl_lock)); \
item = ompi_list_remove_first(&((fl)->super)); \
if(NULL == item) { \
ompi_free_list_grow((fl), (fl)->fl_num_per_alloc); \
opal_free_list_grow((fl), (fl)->fl_num_per_alloc); \
item = ompi_list_remove_first(&((fl)->super)); \
} \
ompi_mutex_unlock(&((fl)->fl_lock)); \
} else { \
item = ompi_list_remove_first(&((fl)->super)); \
if(NULL == item) { \
ompi_free_list_grow((fl), (fl)->fl_num_per_alloc); \
opal_free_list_grow((fl), (fl)->fl_num_per_alloc); \
item = ompi_list_remove_first(&((fl)->super)); \
} \
} \
@ -124,7 +118,7 @@ OMPI_DECLSPEC int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elemen
*/
#define OMPI_FREE_LIST_WAIT(fl, item, rc) \
#define OPAL_FREE_LIST_WAIT(fl, item, rc) \
{ \
OMPI_THREAD_LOCK(&((fl)->fl_lock)); \
item = ompi_list_remove_first(&((fl)->super)); \
@ -134,7 +128,7 @@ OMPI_DECLSPEC int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elemen
ompi_condition_wait(&((fl)->fl_condition), &((fl)->fl_lock)); \
(fl)->fl_num_waiting--; \
} else { \
ompi_free_list_grow((fl), (fl)->fl_num_per_alloc); \
opal_free_list_grow((fl), (fl)->fl_num_per_alloc); \
} \
item = ompi_list_remove_first(&((fl)->super)); \
} \
@ -151,7 +145,7 @@ OMPI_DECLSPEC int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elemen
*
*/
#define OMPI_FREE_LIST_RETURN(fl, item) \
#define OPAL_FREE_LIST_RETURN(fl, item) \
{ \
OMPI_THREAD_LOCK(&(fl)->fl_lock); \
ompi_list_prepend(&((fl)->super), (item)); \