Committing changes so that we can get directories moved and headers changed appropriately.
This commit was SVN r84.
Этот коммит содержится в:
родитель
c54f86cbe1
Коммит
bf0a2c451b
@ -95,19 +95,19 @@ void lam_cth_init(lam_ctchannel_t *channel);
|
||||
*
|
||||
*/
|
||||
|
||||
INLINE int lam_cth_is_connected(lam_ctchannel_t *channel)
|
||||
inline int lam_cth_is_connected(lam_ctchannel_t *channel)
|
||||
{
|
||||
return (CT_CHNL_CONNECTED == channel->cth_status);
|
||||
}
|
||||
|
||||
INLINE uint32_t lam_cth_get_id(lam_ctchannel_t *channel) {return channel->cth_id;}
|
||||
INLINE void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t cid)
|
||||
inline uint32_t lam_cth_get_id(lam_ctchannel_t *channel) {return channel->cth_id;}
|
||||
inline void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t cid)
|
||||
{
|
||||
channel->cth_id = cid;
|
||||
}
|
||||
|
||||
INLINE uint32_t lam_cth_get_timeout(lam_ctchannel_t *channel) {return channel->cth_timeout_secs;}
|
||||
INLINE void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t timeout)
|
||||
inline uint32_t lam_cth_get_timeout(lam_ctchannel_t *channel) {return channel->cth_timeout_secs;}
|
||||
inline void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t timeout)
|
||||
{
|
||||
channel->cth_timeout_secs = timeout;
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ typedef struct lam_ctcontroller
|
||||
void lam_ctl_init(lam_ctctrl_t *ctrl);
|
||||
void lam_ctl_destroy(lam_ctctrl_t *ctrl);
|
||||
|
||||
INLINE void lam_ctl_set_recvd_callback(lam_ctctrl_t *ctrl, lam_ctmsg_recvd_fn callback)
|
||||
inline void lam_ctl_set_recvd_callback(lam_ctctrl_t *ctrl, lam_ctmsg_recvd_fn callback)
|
||||
{
|
||||
ctrl->ctl_msg_recvd_callback = callback;
|
||||
}
|
||||
|
||||
|
||||
INLINE void lam_ctl_set_failed_callback(lam_ctctrl_t *ctrl, lam_ctnode_failed_fn callback)
|
||||
inline void lam_ctl_set_failed_callback(lam_ctctrl_t *ctrl, lam_ctnode_failed_fn callback)
|
||||
{
|
||||
ctrl->ctl_node_failed_callback = callback;
|
||||
}
|
||||
|
@ -125,43 +125,43 @@ void lam_pk_ctc_set_info(uint8_t *buffer, uint8_t *info);
|
||||
* Accessor functions
|
||||
*/
|
||||
|
||||
INLINE uint16_t lam_ctc_get_is_user_msg(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_is_user_msg;}
|
||||
INLINE uint16_t lam_ctc_set_is_user_msg(lam_ct_ctrl_t *ctrl, uint16_t yn)
|
||||
inline uint16_t lam_ctc_get_is_user_msg(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_is_user_msg;}
|
||||
inline uint16_t lam_ctc_set_is_user_msg(lam_ct_ctrl_t *ctrl, uint16_t yn)
|
||||
{
|
||||
ctrl->ctc_is_user_msg = yn;
|
||||
}
|
||||
|
||||
INLINE uint16_t lam_ctc_get_routing_type(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_routing_type;}
|
||||
INLINE uint16_t lam_ctc_set_routing_type(lam_ct_ctrl_t *ctrl, int rtype)
|
||||
inline uint16_t lam_ctc_get_routing_type(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_routing_type;}
|
||||
inline uint16_t lam_ctc_set_routing_type(lam_ct_ctrl_t *ctrl, int rtype)
|
||||
{
|
||||
ctrl->ctc_routing_type = rtype;
|
||||
}
|
||||
|
||||
INLINE uint32_t lam_ctc_get_sender(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_sender;}
|
||||
INLINE void lam_ctc_set_sender(lam_ct_ctrl_t *ctrl, uint32_t sender)
|
||||
inline uint32_t lam_ctc_get_sender(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_sender;}
|
||||
inline void lam_ctc_set_sender(lam_ct_ctrl_t *ctrl, uint32_t sender)
|
||||
{
|
||||
ctrl->ctc_sender = sender;
|
||||
}
|
||||
|
||||
INLINE uint32_t lam_ctc_get_dest(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_dest;}
|
||||
INLINE void lam_ctc_set_dest(lam_ct_ctrl_t *ctrl, uint32_t dest)
|
||||
inline uint32_t lam_ctc_get_dest(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_dest;}
|
||||
inline void lam_ctc_set_dest(lam_ct_ctrl_t *ctrl, uint32_t dest)
|
||||
{
|
||||
ctrl->ctc_dest = dest;
|
||||
}
|
||||
|
||||
INLINE uint32_t lam_ctc_get_forwarding(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_forwarding;}
|
||||
INLINE void lam_ctc_set_forwarding(lam_ct_ctrl_t *ctrl, uint32_t node)
|
||||
inline uint32_t lam_ctc_get_forwarding(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_forwarding;}
|
||||
inline void lam_ctc_set_forwarding(lam_ct_ctrl_t *ctrl, uint32_t node)
|
||||
{
|
||||
ctrl->ctc_forwarding = node;
|
||||
}
|
||||
|
||||
INLINE uint8_t *lam_ctc_get_info(lam_ct_ctrl_t *ctrl, uint32_t *len)
|
||||
inline uint8_t *lam_ctc_get_info(lam_ct_ctrl_t *ctrl, uint32_t *len)
|
||||
{
|
||||
*len = ctrl->ctc_info_len;
|
||||
return ctrl->ctc_info;
|
||||
}
|
||||
|
||||
INLINE void lam_ctc_set_info(lam_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info)
|
||||
inline void lam_ctc_set_info(lam_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info)
|
||||
{
|
||||
ctrl->ctc_info_len = len;
|
||||
ctrl->ctc_info = info;
|
||||
@ -212,8 +212,8 @@ uint8_t *lam_pk_ctm_get_data(uint8_t *buffer, uint32_t *len);
|
||||
*
|
||||
*/
|
||||
|
||||
INLINE lam_ct_ctrl_t *lam_ctm_get_control(lam_ctmsg_t *msg) {return msg->ctm_ctrl;}
|
||||
INLINE void lam_ctm_set_control(lam_ctmsg_t *msg, lam_ct_ctrl_t *ctrl)
|
||||
inline lam_ct_ctrl_t *lam_ctm_get_control(lam_ctmsg_t *msg) {return msg->ctm_ctrl;}
|
||||
inline void lam_ctm_set_control(lam_ctmsg_t *msg, lam_ct_ctrl_t *ctrl)
|
||||
{
|
||||
msg->ctm_ctrl = ctrl;
|
||||
}
|
||||
|
@ -114,11 +114,11 @@ void lam_ctn_set_neighbor(lam_ctnode_t *node, uint32_t label, void *neighbor);
|
||||
*
|
||||
*/
|
||||
|
||||
INLINE uint32_t lam_ctn_get_label(lam_ctnode_t *node) {return node->ctn_label;}
|
||||
INLINE void lam_ctn_set_label(lam_ctnode_t *node, uint32_t label)
|
||||
inline uint32_t lam_ctn_get_label(lam_ctnode_t *node) {return node->ctn_label;}
|
||||
inline void lam_ctn_set_label(lam_ctnode_t *node, uint32_t label)
|
||||
{node->ctn_label = label;}
|
||||
|
||||
INLINE uint32_t lam_ctn_get_num_nodes(lam_ctnode_t *node) {return node->ctn_num_nodes;}
|
||||
inline uint32_t lam_ctn_get_num_nodes(lam_ctnode_t *node) {return node->ctn_num_nodes;}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -33,32 +33,77 @@
|
||||
#include <string.h>
|
||||
#include "lam/lfc/array.h"
|
||||
|
||||
lam_class_info_t array_cls = {"lam_array_t", &object_cls,
|
||||
#define ARR_BLK_SZ 20
|
||||
|
||||
lam_class_info_t lam_array_cls = {"lam_array_t", &lam_object_cls,
|
||||
(class_init_t) lam_arr_init, (class_destroy_t)lam_arr_destroy};
|
||||
|
||||
void lam_arr_init(lam_array_t *arr)
|
||||
{
|
||||
SUPER_INIT(arr, array_cls.cls_parent);
|
||||
SUPER_INIT(arr, lam_array_cls.cls_parent);
|
||||
arr->arr_items = NULL;
|
||||
arr->arr_size = 0;
|
||||
arr->arr_length = 0;
|
||||
}
|
||||
|
||||
void lam_arr_destroy(lam_array_t *arr)
|
||||
{
|
||||
lam_arr_remove_all(arr);
|
||||
free(arr->arr_items);
|
||||
SUPER_DESTROY(arr, array_cls.cls_parent);
|
||||
SUPER_DESTROY(arr, lam_array_cls.cls_parent);
|
||||
}
|
||||
|
||||
void lam_arr_init_with(lam_array_t *arr, size_t length)
|
||||
lam_bool_t lam_arr_init_with(lam_array_t *arr, size_t length)
|
||||
{
|
||||
/* initializes array with fixed length.
|
||||
lam_arr_init() must have been called first. */
|
||||
if ( !arr->arr_items )
|
||||
if ( arr->arr_items )
|
||||
{
|
||||
arr->arr_items = malloc(sizeof(lam_object_t *)*length);
|
||||
arr->arr_length = length;
|
||||
bzero(arr->arr_items, sizeof(lam_object_t *)*length);
|
||||
lam_arr_remove_all(arr);
|
||||
}
|
||||
|
||||
arr->arr_items = malloc(sizeof(lam_object_t *)*length);
|
||||
if ( arr->arr_items )
|
||||
{
|
||||
arr->arr_length = length;
|
||||
bzero(arr->arr_items, sizeof(lam_object_t *)*length);
|
||||
}
|
||||
else
|
||||
return LAM_FALSE;
|
||||
|
||||
return LAM_TRUE;
|
||||
}
|
||||
|
||||
lam_bool_t lam_arr_append_item(lam_array_t *arr, lam_object_t *item)
|
||||
{
|
||||
if ( arr->arr_size == arr->arr_length )
|
||||
{
|
||||
arr->arr_items = (lam_object_t **)realloc(arr->arr_items,
|
||||
sizeof(lam_object_t *)*(arr->arr_length + ARR_BLK_SZ));
|
||||
if ( arr->arr_items )
|
||||
{
|
||||
arr->arr_length += ARR_BLK_SZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LAM_FALSE;
|
||||
}
|
||||
}
|
||||
arr->arr_items[arr->arr_size++] = item;
|
||||
|
||||
return LAM_TRUE;
|
||||
}
|
||||
|
||||
void lam_arr_remove_all(lam_array_t *arr)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i = 0; i < arr->arr_size; i++ )
|
||||
{
|
||||
OBJECT_RELEASE(arr->arr_items[i]);
|
||||
arr->arr_items[i] = 0;
|
||||
}
|
||||
arr->arr_size = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,17 +33,35 @@
|
||||
#ifndef LAM_ARRAY_H
|
||||
#define LAM_ARRAY_H
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "include/lam_types.h"
|
||||
#include "lam/lfc/object.h"
|
||||
|
||||
/*
|
||||
*
|
||||
* Available Classes
|
||||
*
|
||||
*/
|
||||
|
||||
extern lam_class_info_t lam_array_cls;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Arrray interface
|
||||
*
|
||||
*/
|
||||
|
||||
typedef int (*lam_arr_cmp_fn)(lam_object_t *, lam_object_t *);
|
||||
|
||||
typedef struct lam_array
|
||||
{
|
||||
lam_object_t super;
|
||||
lam_object_t **arr_items;
|
||||
lam_object_t **arr_items;
|
||||
size_t arr_length;
|
||||
size_t arr_size;
|
||||
} lam_array_t;
|
||||
|
||||
extern lam_class_info_t array_cls;
|
||||
|
||||
void lam_arr_init(lam_array_t *arr);
|
||||
void lam_arr_destroy(lam_array_t *arr);
|
||||
@ -51,9 +69,11 @@ void lam_arr_destroy(lam_array_t *arr);
|
||||
/* initializes array with fixed length.
|
||||
* lam_arr_init() must have been called first.
|
||||
*/
|
||||
void lam_arr_init_with(lam_array_t *arr, size_t length);
|
||||
lam_bool_t lam_arr_init_with(lam_array_t *arr, size_t length);
|
||||
|
||||
static inline lam_object_t *lam_arr_get_item(lam_array_t *arr, int index)
|
||||
lam_bool_t lam_arr_append_item(lam_array_t *arr, lam_object_t *item);
|
||||
|
||||
inline lam_object_t *lam_arr_get_item(lam_array_t *arr, int index)
|
||||
{
|
||||
if ( (index >=0) && (index < arr->arr_length) )
|
||||
{
|
||||
@ -61,10 +81,29 @@ static inline lam_object_t *lam_arr_get_item(lam_array_t *arr, int index)
|
||||
}
|
||||
}
|
||||
|
||||
inline size_t lam_arr_get_size(lam_array_t *arr)
|
||||
{
|
||||
return arr->arr_size;
|
||||
}
|
||||
|
||||
int lam_arr_index_of_item_matching(lam_array_t *arr, lam_object_t *item,
|
||||
lam_arr_cmp_fn cmp_fn);
|
||||
|
||||
void lam_arr_remove_all(lam_array_t *arr);
|
||||
|
||||
void lam_arr_remove_item(lam_array_t *arr, int index);
|
||||
|
||||
void lam_arr_remove_item_matching(lam_array_t *arr, lam_object_t *item,
|
||||
lam_arr_cmp_fn cmp_fn);
|
||||
|
||||
void lam_arr_set_item(lam_array_t *arr, lam_object_t *item, int index);
|
||||
|
||||
inline lam_object_t **lam_arr_get_c_array(lam_array_t *arr, size_t *size)
|
||||
{
|
||||
*size = arr->arr_size;
|
||||
return arr->arr_items;
|
||||
}
|
||||
|
||||
|
||||
#endif /* LAM_ARRAY_H */
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define BUCKET_ALLOC_SZ 5
|
||||
|
||||
lam_class_info_t lam_fast_hash_cls = {
|
||||
"lam_fast_hash_t", &object_cls, (class_init_t)lam_fh_init,
|
||||
"lam_fast_hash_t", &lam_object_cls, (class_init_t)lam_fh_init,
|
||||
(class_destroy_t)lam_fh_destroy
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifndef LAM_HASH_TABLE_H
|
||||
#define LAM_HASH_TABLE_H
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "include/lam_stdint.h"
|
||||
#include "lam/lfc/object.h"
|
||||
|
||||
@ -79,6 +80,6 @@ int lam_fh_set_value_for_skey(lam_fast_hash_t *htbl, void *val, const char *ke
|
||||
|
||||
|
||||
/* returns the number of items in the table */
|
||||
static inline uint32_t lam_fh_count(lam_fast_hash_t *htbl) {return htbl->fh_count;}
|
||||
inline uint32_t lam_fh_count(lam_fast_hash_t *htbl) {return htbl->fh_count;}
|
||||
|
||||
#endif /* LAM_HASH_TABLE_H */
|
||||
|
@ -38,9 +38,9 @@
|
||||
*/
|
||||
|
||||
|
||||
lam_class_info_t lam_dbl_item_cls = {"lam_dbl_link_item_t", &object_cls,
|
||||
lam_class_info_t lam_dbl_item_cls = {"lam_dbl_link_item_t", &lam_object_cls,
|
||||
(class_init_t) lam_dbl_item_init, (class_destroy_t)lam_obj_destroy};
|
||||
lam_class_info_t lam_dbl_list_cls = {"lam_dbl_list_t", &object_cls,
|
||||
lam_class_info_t lam_dbl_list_cls = {"lam_dbl_list_t", &lam_object_cls,
|
||||
(class_init_t)lam_dbl_init, (class_destroy_t)lam_dbl_destroy};
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include "lam/lfc/object.h"
|
||||
|
||||
lam_class_info_t object_cls = { "lam_object_t", 0, lam_obj_init, lam_obj_destroy };
|
||||
lam_class_info_t lam_object_cls = { "lam_object_t", 0, lam_obj_init, lam_obj_destroy };
|
||||
|
||||
void lam_obj_init(lam_object_t *obj)
|
||||
{
|
||||
|
@ -41,10 +41,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
struct _object;
|
||||
struct lam_object;
|
||||
|
||||
typedef void (*class_init_t)(struct _object *);
|
||||
typedef void (*class_destroy_t)(struct _object *);
|
||||
typedef void (*class_init_t)(struct lam_object *);
|
||||
typedef void (*class_destroy_t)(struct lam_object *);
|
||||
|
||||
typedef struct lam_class_info
|
||||
{
|
||||
@ -71,7 +71,7 @@ typedef struct lam_class_info
|
||||
*
|
||||
*/
|
||||
|
||||
extern lam_class_info_t object_cls;
|
||||
extern lam_class_info_t lam_object_cls;
|
||||
|
||||
/*
|
||||
*
|
||||
@ -100,7 +100,7 @@ extern lam_class_info_t object_cls;
|
||||
#define OBJ_RETAIN(obj) if ( obj ) lam_obj_retain(OBJECT(obj))
|
||||
#define OBJ_RELEASE(obj) if ( obj ) lam_obj_release(OBJECT(obj))
|
||||
|
||||
typedef struct _object
|
||||
typedef struct lam_object
|
||||
{
|
||||
lam_class_info_t *obj_class;
|
||||
int obj_refcnt;
|
||||
|
@ -34,12 +34,12 @@
|
||||
void *lam_alc_malloc(lam_allocator_t *allocator, size_t chunk_size);
|
||||
void lam_alc_default_free(lam_allocator_t *allocator, void *base_ptr);
|
||||
|
||||
lam_class_info_t allocator_cls = {"lam_allocator_t", &object_cls,
|
||||
lam_class_info_t allocator_cls = {"lam_allocator_t", &lam_object_cls,
|
||||
(class_init_t)lam_alc_init, (class_destroy_t)lam_obj_destroy};
|
||||
|
||||
void lam_alc_init(lam_allocator_t *allocator)
|
||||
{
|
||||
SUPER_INIT(allocator, &object_cls);
|
||||
SUPER_INIT(allocator, &lam_object_cls);
|
||||
allocator->alc_alloc_fn = lam_alc_malloc;
|
||||
allocator->alc_free_fn = lam_alc_free;
|
||||
allocator->alc_is_shared = 0;
|
||||
|
@ -1,6 +1,4 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*
|
||||
* Copyright 2002-2003. The Regents of the University of California. This material
|
||||
* was produced under U.S. Government contract W-7405-ENG-36 for Los Alamos
|
||||
* National Laboratory, which is operated by the University of California for
|
||||
@ -30,6 +28,7 @@
|
||||
*/
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "lam/mem/free_list.h"
|
||||
#include "lam/util/lam_log.h"
|
||||
#include "lam/os/numa.h"
|
||||
@ -37,7 +36,17 @@
|
||||
#include "lam/mem/mem_globals.h"
|
||||
|
||||
/* private list functions */
|
||||
void lam_frl_append_nl(lam_free_list_t *flist, void *chunk, int pool_idx);
|
||||
inline lam_flist_elt_t *lam_flr_request_elt(lam_free_list_t *flist, int pool_idx)
|
||||
{
|
||||
lam_dbl_list_t *seg_list = &(flist->fl_free_lists[pool_idx]->sgl_list);
|
||||
volatile lam_flist_elt_t *elt = lam_dbl_get_last(seg_list);
|
||||
|
||||
if ( elt )
|
||||
lam_sgl_set_consec_fail(seg_list, 0);
|
||||
return elt;
|
||||
}
|
||||
|
||||
void lam_frl_append(lam_free_list_t *flist, void *chunk, int pool_idx);
|
||||
|
||||
int lam_frl_create_more_elts(lam_free_list_t *flist, int pool_idx);
|
||||
|
||||
@ -48,7 +57,7 @@ int lam_frl_mem_pool_init(lam_free_list_t *flist, int nlists, long pages_per_lis
|
||||
long default_min_pages_per_list, long default_pages_per_list,
|
||||
long max_pages_per_list, ssize_t max_mem_in_pool);
|
||||
|
||||
lam_class_info_t free_list_cls = {"lam_free_list_t", &object_cls,
|
||||
lam_class_info_t free_list_cls = {"lam_free_list_t", &lam_object_cls,
|
||||
(class_init_t)lam_frl_init, (class_destroy_t)lam_frl_destroy};
|
||||
|
||||
|
||||
@ -121,9 +130,9 @@ int lam_frl_init_with(
|
||||
int max_pages_per_list,
|
||||
int max_consec_req_fail,
|
||||
const char *description,
|
||||
lam_bool_t retry_for_more_resources,
|
||||
bool_t retry_for_more_resources,
|
||||
lam_affinity_t *affinity,
|
||||
lam_bool_t enforce_affinity,
|
||||
bool_t enforce_affinity,
|
||||
lam_mem_pool_t *mem_pool)
|
||||
{
|
||||
/* lam_frl_init must have been called prior to calling this function */
|
||||
@ -335,8 +344,8 @@ void *lam_frl_get_mem_chunk(lam_free_list_t *flist, int index, size_t *len, int
|
||||
sz_to_add = lam_mp_get_chunk_size(flist->fl_pool);
|
||||
|
||||
/* need to add option to configure */
|
||||
/* if (OPT_MEMPROFILE) { */
|
||||
if ( 0 ) {
|
||||
if (OPT_MEMPROFILE)
|
||||
{
|
||||
flist->fl_chunks_req[index]++;
|
||||
}
|
||||
|
||||
@ -372,7 +381,7 @@ void *lam_frl_get_mem_chunk(lam_free_list_t *flist, int index, size_t *len, int
|
||||
|
||||
// get chunk of memory
|
||||
chunk = lam_mp_request_chunk(flist->fl_pool, index);
|
||||
if ( chunk == 0 )
|
||||
if ( 0 == chunk )
|
||||
{
|
||||
// increment failure count
|
||||
lam_sgl_inc_consec_fail(flist->fl_free_lists[index]);
|
||||
@ -393,8 +402,8 @@ void *lam_frl_get_mem_chunk(lam_free_list_t *flist, int index, size_t *len, int
|
||||
this far in the code. */
|
||||
lam_sgl_set_consec_fail(flist->fl_free_lists[index], 0);
|
||||
|
||||
/* if (OPT_MEMPROFILE) { */
|
||||
if ( 0 ) {
|
||||
if (OPT_MEMPROFILE)
|
||||
{
|
||||
flist->fl_chunks_returned[index]++;
|
||||
}
|
||||
|
||||
@ -403,7 +412,7 @@ void *lam_frl_get_mem_chunk(lam_free_list_t *flist, int index, size_t *len, int
|
||||
|
||||
|
||||
|
||||
void lam_frl_append_nl(lam_free_list_t *flist, void *chunk, int pool_idx)
|
||||
void lam_frl_append(lam_free_list_t *flist, void *chunk, int pool_idx)
|
||||
{
|
||||
/* ASSERT: mp_chunk_sz >= fl_elt_per_chunk * fl_elt_size */
|
||||
// push items onto list
|
||||
@ -454,7 +463,75 @@ int lam_frl_create_more_elts(lam_free_list_t *flist, int pool_idx)
|
||||
}
|
||||
|
||||
/* push chunk of memory onto the list */
|
||||
lam_frl_append_nl(flist, ptr, pool_idx);
|
||||
lam_frl_append(flist, ptr, pool_idx);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
lam_flist_elt_t *lam_frl_get_elt(lam_free_list_t *flist, int index, int *error)
|
||||
{
|
||||
int error;
|
||||
volatile lam_flist_elt_t *elem = 0;
|
||||
|
||||
elem = lam_flr_request_elt(flist, index);
|
||||
|
||||
if ( elem )
|
||||
{
|
||||
error = LAM_SUCCESS;
|
||||
}
|
||||
else if ( lam_sgl_get_consec_fail(&(flist->fl_free_lists[index]->sgl_list))
|
||||
< flist->fl_threshold_grow )
|
||||
{
|
||||
error = LAM_ERR_TEMP_OUT_OF_RESOURCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = LAM_SUCCESS;
|
||||
while ( (LAM_SUCCESS) && (0 == elem) &&
|
||||
(flist->fl_retry_more_resources) )
|
||||
{
|
||||
error = lam_frl_create_more_elts(flist, index);
|
||||
/* get element if managed to add resources to the list */
|
||||
if ( LAM_SUCCESS == error )
|
||||
{
|
||||
elem = lam_flr_request_elt(flist, index);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (LAM_ERR_OUT_OF_RESOURCE == error)
|
||||
|| (LAM_ERR_FATAL == error) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ( OPT_MEMPROFILE )
|
||||
{
|
||||
flist->fl_elt_out[index]++;
|
||||
flist->fl_elt_sum[index] += flist->fl_elt_out[index];
|
||||
flist->fl_nevents[index]++;
|
||||
if (flist->fl_elt_max[index] < flist->fl_elt_out[index])
|
||||
{
|
||||
flist->fl_elt_max[index] = flist->fl_elt_out[index];
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
int lam_frl_return_elt(lam_free_list_t *flist, int index, lam_flist_elt_t *item)
|
||||
{
|
||||
mb();
|
||||
lam_dbl_append(&(flist->fl_free_lists[index]->sgl_list), item);
|
||||
mb();
|
||||
|
||||
if ( OPT_MEMPROFILE ) {
|
||||
flist->fl_elt_out[index]--;
|
||||
}
|
||||
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,7 +67,6 @@ typedef int lam_affinity_t;
|
||||
typedef struct lam_free_list
|
||||
{
|
||||
lam_object_t super;
|
||||
lam_mutex_t fl_lock;
|
||||
int fl_is_shared;
|
||||
lam_mem_pool_t *fl_pool;
|
||||
const char *fl_description;
|
||||
@ -112,11 +111,9 @@ int lam_frl_init_with(lam_free_list_t *flist,
|
||||
lam_mem_pool_t *pool);
|
||||
|
||||
|
||||
lam_flist_elt_t *lam_frl_get_elt(lam_free_list_t *flist, int index, int *err);
|
||||
lam_flist_elt_t *lam_frl_get_elt_nl(lam_free_list_t *flist, int index, int *err);
|
||||
lam_flist_elt_t *lam_frl_get_elt(lam_free_list_t *flist, int index, int *error);
|
||||
|
||||
int lam_frl_return_elt(lam_free_list_t *flist, int index, lam_flist_elt_t *item);
|
||||
int lam_frl_return_elt_nl(lam_free_list_t *flist, int index, lam_flist_elt_t *item);
|
||||
|
||||
/*
|
||||
* Accessor functions
|
||||
|
@ -40,11 +40,11 @@
|
||||
#include "lam/util/malloc.h"
|
||||
#include "lam/os/numa.h"
|
||||
|
||||
lam_class_info_t mem_pool_cls = {"lam_mem_pool_t", &object_cls,
|
||||
lam_class_info_t mem_pool_cls = {"lam_mem_pool_t", &lam_object_cls,
|
||||
(class_init_t)lam_mp_init, (class_destroy_t)lam_mp_destroy};
|
||||
|
||||
/* process-shared mem pool class */
|
||||
lam_class_info_t shmem_pool_cls = {"shmem_pool_t", &object_cls,
|
||||
lam_class_info_t shmem_pool_cls = {"shmem_pool_t", &lam_object_cls,
|
||||
(class_init_t)lam_mp_shared_init, (class_destroy_t)lam_mp_destroy};
|
||||
|
||||
void lam_mp_init(lam_mem_pool_t *pool)
|
||||
@ -73,7 +73,7 @@ void lam_mp_destroy(lam_mem_pool_t *pool)
|
||||
OBJ_RELEASE(pool->mp_dev_alloc);
|
||||
OBJ_RELEASE(pool->mp_private_alloc);
|
||||
|
||||
SUPER_DESTROY(pool, &object_cls);
|
||||
SUPER_DESTROY(pool, &lam_object_cls);
|
||||
}
|
||||
|
||||
int lam_mp_init_with(lam_mem_pool_t *pool, uint64_t pool_size,
|
||||
@ -295,12 +295,12 @@ void *lam_mp_request_chunk(lam_mem_pool_t *pool, int pool_index)
|
||||
*/
|
||||
|
||||
|
||||
lam_class_info_t fixed_mem_pool_cls = {"lam_fixed_mpool_t", &object_cls,
|
||||
lam_class_info_t fixed_mem_pool_cls = {"lam_fixed_mpool_t", &lam_object_cls,
|
||||
(class_init_t)lam_fmp_init, (class_destroy_t)lam_fmp_destroy};
|
||||
|
||||
void lam_fmp_init(lam_fixed_mpool_t *pool)
|
||||
{
|
||||
SUPER_INIT(pool, &object_cls);
|
||||
SUPER_INIT(pool, &lam_object_cls);
|
||||
|
||||
CREATE_OBJECT(pool->fmp_private_alloc, lam_allocator_t, &allocator_cls);
|
||||
lam_alc_set_is_shared(pool->fmp_private_alloc, 1);
|
||||
@ -333,7 +333,7 @@ void lam_fmp_destroy(lam_fixed_mpool_t *pool)
|
||||
if ( pool->fmp_n_segs_in_array )
|
||||
free(pool->fmp_n_segs_in_array);
|
||||
|
||||
SUPER_DESTROY(pool, &object_cls);
|
||||
SUPER_DESTROY(pool, &lam_object_cls);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
*/
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
#ifndef LAM_MEMORY_POOL
|
||||
#define LAM_MEMORY_POOL
|
||||
#ifndef LAM_MEMORY_POOL_H
|
||||
#define LAM_MEMORY_POOL_H
|
||||
|
||||
#include "include/lam_types.h"
|
||||
#include "lam/lfc/object.h"
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "lam/mem/seg_list.h"
|
||||
|
||||
lam_class_info_t seg_list_cls = {"lam_seg_list_t", &object_cls,
|
||||
lam_class_info_t seg_list_cls = {"lam_seg_list_t", &lam_object_cls,
|
||||
(class_init_t)lam_sgl_init, (class_destroy_t)lam_sgl_destroy};
|
||||
|
||||
void lam_sgl_init(lam_seg_list_t *slist)
|
||||
|
@ -1,6 +1,4 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*
|
||||
* Copyright 2002-2003. The Regents of the University of California. This material
|
||||
* was produced under U.S. Government contract W-7405-ENG-36 for Los Alamos
|
||||
* National Laboratory, which is operated by the University of California for
|
||||
@ -30,9 +28,10 @@
|
||||
*/
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
#ifndef LAM_SEG_LIST_H
|
||||
#define LAM_SEG_LIST_H
|
||||
#ifndef SEG_LIST_H
|
||||
#define SEG_LIST_H
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "lam/lfc/list.h"
|
||||
#include "lam/threads/mutex.h"
|
||||
|
||||
@ -68,7 +67,7 @@ void lam_sgl_append_elt_chunk(
|
||||
#define lam_sgl_lock_list(slist) lam_mtx_trylock(&slist->sgl_lock)
|
||||
#define lam_sgl_unlock_list(slist) lam_mtx_unlock(&slist->sgl_lock)
|
||||
|
||||
static inline int lam_sgl_is_locked(lam_seg_list_t *slist)
|
||||
inline int lam_sgl_is_locked(lam_seg_list_t *slist)
|
||||
{
|
||||
/* returns 1 if list is currently locked, otherwise 0. */
|
||||
int ret;
|
||||
@ -102,4 +101,7 @@ static inline int lam_sgl_is_locked(lam_seg_list_t *slist)
|
||||
#define lam_sgl_inc_consec_fail(slist) \
|
||||
((slist)->sgl_consec_fail++)
|
||||
|
||||
#endif /* LAM_SEG_LIST_H */
|
||||
#endif /* SEG_LIST_H */
|
||||
|
||||
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#ifndef LAM_ATOMIC_H_INCLUDED
|
||||
#define LAM_ATOMIC_H_INCLUDED
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
/*
|
||||
* Atomic functions
|
||||
*/
|
||||
|
@ -70,7 +70,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
* A value of 0 indicates that the lock is available
|
||||
* 1 or more the lock is held by someone
|
||||
*/
|
||||
INLINE void spinlock(lam_lock_data_t *lock)
|
||||
inline void spinlock(lam_lock_data_t *lock)
|
||||
{
|
||||
/*** sungeun *** ref: alpha-linux spinlock sources ***/
|
||||
int tmp = 0;
|
||||
@ -100,7 +100,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
/*
|
||||
* This routine tries once to obtain the lock
|
||||
*/
|
||||
INLINE int spintrylock(lam_lock_data_t *lock)
|
||||
inline int spintrylock(lam_lock_data_t *lock)
|
||||
{
|
||||
int got_lock = 0;
|
||||
int tmp = 0;
|
||||
@ -125,13 +125,13 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
/*
|
||||
* Clear the lock - alpha specific - need memory barrier
|
||||
*/
|
||||
INLINE void spinunlock(lam_lock_data_t *lock)
|
||||
inline void spinunlock(lam_lock_data_t *lock)
|
||||
{
|
||||
mb();
|
||||
lock->data.lockData_m = 0;
|
||||
}
|
||||
|
||||
INLINE int fetchNadd(volatile int *addr, int inc)
|
||||
inline int fetchNadd(volatile int *addr, int inc)
|
||||
{
|
||||
int oldval = 0;
|
||||
int tmp = 0;
|
||||
@ -155,7 +155,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
|
||||
|
||||
|
||||
INLINE int fetchNset(volatile int *addr, int val)
|
||||
inline int fetchNset(volatile int *addr, int val)
|
||||
{
|
||||
int oldval = 0;
|
||||
int tmp = 0;
|
||||
@ -178,7 +178,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr, int inc)
|
||||
inline unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr, int inc)
|
||||
{
|
||||
unsigned long long oldval = 0;
|
||||
unsigned long long tmp = 0;
|
||||
@ -206,7 +206,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
int inc)
|
||||
{
|
||||
unsigned long long val;
|
||||
@ -217,7 +217,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
return val;
|
||||
}
|
||||
|
||||
INLINE unsigned long long fetchNsetLong(volatile unsigned long long *addr,
|
||||
inline unsigned long long fetchNsetLong(volatile unsigned long long *addr,
|
||||
unsigned long long val)
|
||||
{
|
||||
unsigned long long oldval = 0;
|
||||
@ -241,7 +241,7 @@ __asm__ __volatile__("wmb": : :"memory")
|
||||
}
|
||||
|
||||
|
||||
INLINE void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
inline void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
unsigned long long val)
|
||||
{
|
||||
*addr = val;
|
||||
|
@ -78,7 +78,7 @@ extern "C"
|
||||
/*
|
||||
* Spin until I can get the lock
|
||||
*/
|
||||
INLINE void spinlock(lam_lock_data_t *lockData)
|
||||
inline void spinlock(lam_lock_data_t *lockData)
|
||||
{
|
||||
|
||||
__asm__ __volatile__ (
|
||||
@ -98,7 +98,7 @@ INLINE void spinlock(lam_lock_data_t *lockData)
|
||||
/*
|
||||
* This routine tries once to obtain the lock
|
||||
*/
|
||||
INLINE int spintrylock(lam_lock_data_t *lockData)
|
||||
inline int spintrylock(lam_lock_data_t *lockData)
|
||||
{
|
||||
|
||||
int gotLock;
|
||||
@ -119,7 +119,7 @@ INLINE int spintrylock(lam_lock_data_t *lockData)
|
||||
* previous value
|
||||
*/
|
||||
|
||||
INLINE int fetchNadd(volatile int *addr, int inc)
|
||||
inline int fetchNadd(volatile int *addr, int inc)
|
||||
{
|
||||
int inputValue;
|
||||
|
||||
@ -131,7 +131,7 @@ INLINE int fetchNadd(volatile int *addr, int inc)
|
||||
}
|
||||
|
||||
|
||||
INLINE int fetchNset(volatile int *addr, int setValue)
|
||||
inline int fetchNset(volatile int *addr, int setValue)
|
||||
{
|
||||
int inputValue;
|
||||
|
||||
@ -147,12 +147,12 @@ INLINE int fetchNset(volatile int *addr, int setValue)
|
||||
/*
|
||||
* Clear the lock
|
||||
*/
|
||||
INLINE void spinunlock(lam_lock_data_t *lockData)
|
||||
inline void spinunlock(lam_lock_data_t *lockData)
|
||||
{
|
||||
lockData->data.lockData_m = LOCK_UNLOCKED;
|
||||
}
|
||||
|
||||
INLINE unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
int inc)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -166,7 +166,7 @@ INLINE unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
unsigned long long val)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -180,7 +180,7 @@ INLINE unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
int inc)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -191,7 +191,7 @@ INLINE unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
INLINE void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
inline void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
unsigned long long value)
|
||||
{
|
||||
addr->data = value;
|
||||
|
@ -79,7 +79,7 @@ extern "C"
|
||||
/*
|
||||
* Spin until I can get the lock
|
||||
*/
|
||||
INLINE void spinlock(lam_lock_data_t *lockData)
|
||||
inline void spinlock(lam_lock_data_t *lockData)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cmp $1, %0\n"
|
||||
@ -98,7 +98,7 @@ INLINE void spinlock(lam_lock_data_t *lockData)
|
||||
/*
|
||||
* This routine tries once to obtain the lock
|
||||
*/
|
||||
INLINE int spintrylock(lam_lock_data_t *lockData)
|
||||
inline int spintrylock(lam_lock_data_t *lockData)
|
||||
{
|
||||
int gotLock;
|
||||
|
||||
@ -128,7 +128,7 @@ INLINE int spintrylock(lam_lock_data_t *lockData)
|
||||
* atomically add a constant to the input integer returning the
|
||||
* previous value
|
||||
*/
|
||||
INLINE int fetchNadd(volatile int *addr, int inc)
|
||||
inline int fetchNadd(volatile int *addr, int inc)
|
||||
{
|
||||
int inputValue;
|
||||
__asm__ __volatile__(
|
||||
@ -144,7 +144,7 @@ INLINE int fetchNadd(volatile int *addr, int inc)
|
||||
}
|
||||
|
||||
|
||||
INLINE int fetchNset(volatile int *addr, int setValue)
|
||||
inline int fetchNset(volatile int *addr, int setValue)
|
||||
{
|
||||
int inputValue;
|
||||
|
||||
@ -166,13 +166,13 @@ INLINE int fetchNset(volatile int *addr, int setValue)
|
||||
/*
|
||||
* Clear the lock
|
||||
*/
|
||||
INLINE void spinunlock(lam_lock_data_t *lockData)
|
||||
inline void spinunlock(lam_lock_data_t *lockData)
|
||||
{
|
||||
lockData->data.lockData_m = 1;
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
int inc)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -186,7 +186,7 @@ INLINE unsigned long long fetchNaddLong(bigAtomicUnsignedInt *addr,
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
unsigned long long val)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -200,7 +200,7 @@ INLINE unsigned long long fetchNsetLong(bigAtomicUnsignedInt *addr,
|
||||
}
|
||||
|
||||
|
||||
INLINE unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
inline unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
int inc)
|
||||
{
|
||||
unsigned long long returnValue;
|
||||
@ -211,7 +211,7 @@ INLINE unsigned long long fetchNaddLongNoLock(bigAtomicUnsignedInt *addr,
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
INLINE void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
inline void setBigAtomicUnsignedInt(bigAtomicUnsignedInt *addr,
|
||||
unsigned long long value)
|
||||
{
|
||||
addr->data = value;
|
||||
|
@ -52,7 +52,7 @@ static inline int lam_get_cpu_set(void)
|
||||
|
||||
#else
|
||||
|
||||
# OS / architecture specific implementation elsewhere
|
||||
/* OS / architecture specific implementation elsewhere */
|
||||
|
||||
int lam_set_affinity(void *addr, size_t size, affinity_t affinity);
|
||||
|
||||
|
@ -62,7 +62,8 @@ static inline void lam_mtx_lock(lam_mutex_t* m)
|
||||
int locked;
|
||||
|
||||
fetchNadd(&m->mtx_waiting, 1);
|
||||
while((locked = fetchNset(&m->mtx_spinlock, 1)) == 1 && cnt++ < MUTEX_SPINWAIT)
|
||||
while( ((locked = fetchNset(&m->mtx_spinlock, 1)) == 1)
|
||||
&& (cnt++ < MUTEX_SPINWAIT) )
|
||||
;
|
||||
if(locked) {
|
||||
pthread_mutex_lock(&m->mtx_lock);
|
||||
|
@ -52,7 +52,7 @@ const int LAM_NOTIFY_ALL = 7;
|
||||
|
||||
|
||||
lam_class_info_t lam_reactor_cls = {
|
||||
"lam_reactor_t", &object_cls, (class_init_t)lam_reactor_init,
|
||||
"lam_reactor_t", &lam_object_cls, (class_init_t)lam_reactor_init,
|
||||
(class_destroy_t)lam_reactor_destroy
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,8 @@
|
||||
*/
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
#ifndef LAM_REACTOR
|
||||
#define LAM_REACTOR
|
||||
#ifndef LAM_REACTOR_H
|
||||
#define LAM_REACTOR_H
|
||||
|
||||
#include "include/lam_types.h"
|
||||
#include "lam/lfc/list.h"
|
||||
@ -101,5 +101,5 @@ lam_bool_t lam_reactor_remove(lam_reactor_t*, int sd, lam_reactor_listener_t*, i
|
||||
void lam_reactor_poll(lam_reactor_t*);
|
||||
void lam_reactor_run(lam_reactor_t*);
|
||||
|
||||
#endif /* LAM_REACTOR */
|
||||
#endif /* LAM_REACTOR_H */
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user