From 5894f0c1f299dd9475b5c95e1b5e709cc0323dd9 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 23 Feb 2015 08:07:45 -0800 Subject: [PATCH] usnic: update to new mpool API NOTE: Have not added cross-compatibility with v1.8 branch yet --- opal/mca/btl/usnic/btl_usnic.h | 4 +- opal/mca/btl/usnic/btl_usnic_compat.h | 15 -- opal/mca/btl/usnic/btl_usnic_endpoint.h | 2 +- opal/mca/btl/usnic/btl_usnic_frag.c | 4 +- opal/mca/btl/usnic/btl_usnic_frag.h | 34 ++-- opal/mca/btl/usnic/btl_usnic_module.c | 200 ++++++++++++++---------- opal/mca/btl/usnic/btl_usnic_module.h | 14 +- opal/mca/btl/usnic/btl_usnic_recv.c | 8 +- 8 files changed, 147 insertions(+), 134 deletions(-) diff --git a/opal/mca/btl/usnic/btl_usnic.h b/opal/mca/btl/usnic/btl_usnic.h index a99378d4e3..2137facf49 100644 --- a/opal/mca/btl/usnic/btl_usnic.h +++ b/opal/mca/btl/usnic/btl_usnic.h @@ -33,14 +33,14 @@ #include "opal/class/opal_hash_table.h" #include "opal/mca/event/event.h" -#if BTL_IN_OPAL #include "opal/class/opal_free_list.h" + +#if BTL_IN_OPAL #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/btl_base_error.h" #include "opal/mca/btl/base/base.h" #include "opal/mca/mpool/grdma/mpool_grdma.h" #else -#include "ompi/class/ompi_free_list.h" #include "ompi/mca/btl/btl.h" #include "ompi/mca/btl/base/btl_base_error.h" #include "ompi/mca/btl/base/base.h" diff --git a/opal/mca/btl/usnic/btl_usnic_compat.h b/opal/mca/btl/usnic/btl_usnic_compat.h index ebc4251ea7..b401ceef6e 100644 --- a/opal/mca/btl/usnic/btl_usnic_compat.h +++ b/opal/mca/btl/usnic/btl_usnic_compat.h @@ -175,21 +175,6 @@ char* opal_get_proc_hostname(opal_proc_t *proc); # error OMPI version too old (< 1.7) #endif -/************************************************************************/ - -/* The FREE_LIST_*_MT stuff was introduced on the SVN trunk in r28722 - (2013-07-04), but so far, has not been merged into the v1.7 branch - yet (2013-09-06). */ -#ifndef OPAL_FREE_LIST_GET_MT -# define OPAL_FREE_LIST_GET_MT(list_, item_) \ - do { \ - int rc_ __opal_attribute_unused__; \ - OPAL_FREE_LIST_GET(list_, item_, rc_); \ - } while (0) -# define OPAL_FREE_LIST_RETURN_MT(list_, item_) \ - OPAL_FREE_LIST_RETURN(list_, item_) -#endif - /************************************************************************ * Common to all versions ************************************************************************/ diff --git a/opal/mca/btl/usnic/btl_usnic_endpoint.h b/opal/mca/btl/usnic/btl_usnic_endpoint.h index 877dae1e46..c76eee6d95 100644 --- a/opal/mca/btl/usnic/btl_usnic_endpoint.h +++ b/opal/mca/btl/usnic/btl_usnic_endpoint.h @@ -104,7 +104,7 @@ typedef struct opal_btl_usnic_rx_frag_info_t { bool rfi_data_in_pool; /* data in data_pool if true, else malloced */ int rfi_data_pool; /* if <0, data malloced, else rx buf pool */ char *rfi_data; /* pointer to assembly area */ - ompi_free_list_item_t *rfi_fl_elt; /* free list elemement from buf pool + opal_free_list_item_t *rfi_fl_elt; /* free list elemement from buf pool when rfi_data_pool is nonzero */ } opal_btl_usnic_rx_frag_info_t; diff --git a/opal/mca/btl/usnic/btl_usnic_frag.c b/opal/mca/btl/usnic/btl_usnic_frag.c index 257adc8ec0..5944e02cba 100644 --- a/opal/mca/btl/usnic/btl_usnic_frag.c +++ b/opal/mca/btl/usnic/btl_usnic_frag.c @@ -255,7 +255,7 @@ put_dest_frag_destructor(opal_btl_usnic_put_dest_frag_t *pfrag) } OBJ_CLASS_INSTANCE(opal_btl_usnic_segment_t, - ompi_free_list_item_t, + opal_free_list_item_t, NULL, NULL); @@ -308,6 +308,6 @@ OBJ_CLASS_INSTANCE(opal_btl_usnic_put_dest_frag_t, put_dest_frag_destructor); OBJ_CLASS_INSTANCE(opal_btl_usnic_rx_buf_t, - ompi_free_list_item_t, + opal_free_list_item_t, NULL, NULL); diff --git a/opal/mca/btl/usnic/btl_usnic_frag.h b/opal/mca/btl/usnic/btl_usnic_frag.h index 69d79ae3cb..827c34be89 100644 --- a/opal/mca/btl/usnic/btl_usnic_frag.h +++ b/opal/mca/btl/usnic/btl_usnic_frag.h @@ -167,7 +167,7 @@ typedef struct { * be sent or received. */ typedef struct opal_btl_usnic_segment_t { - ompi_free_list_item_t us_list; + opal_free_list_item_t us_list; opal_btl_usnic_seg_type_t us_type; @@ -245,7 +245,7 @@ typedef struct opal_btl_usnic_frag_t { mca_btl_base_segment_t uf_remote_seg[1]; /* freelist this came from */ - ompi_free_list_t *uf_freelist; + opal_free_list_t *uf_freelist; } opal_btl_usnic_frag_t; /** @@ -326,14 +326,14 @@ typedef struct opal_btl_usnic_small_send_frag_t { typedef opal_btl_usnic_frag_t opal_btl_usnic_put_dest_frag_t; /** - * A simple buffer that can be enqueued on an ompi_free_list_t that is intended + * A simple buffer that can be enqueued on an opal_free_list_t that is intended * to be used for fragment reassembly. Nominally the free list code supports * this via the rb_super.ptr field, but that field is only allocated and * non-NULL if an mpool is used, and we don't need this reassembly memory to be * registered. */ typedef struct opal_btl_usnic_rx_buf_t { - ompi_free_list_item_t rb_super; + opal_free_list_item_t rb_super; char buf[1]; /* flexible array member for frag reassembly */ } opal_btl_usnic_rx_buf_t; @@ -358,10 +358,10 @@ OBJ_CLASS_DECLARATION(opal_btl_usnic_ack_segment_t); static inline opal_btl_usnic_small_send_frag_t * opal_btl_usnic_small_send_frag_alloc(opal_btl_usnic_module_t *module) { - ompi_free_list_item_t *item; + opal_free_list_item_t *item; opal_btl_usnic_small_send_frag_t *frag; - OMPI_FREE_LIST_GET_MT(&(module->small_send_frags), item); + item = opal_free_list_get(&(module->small_send_frags)); if (OPAL_UNLIKELY(NULL == item)) { return NULL; } @@ -380,10 +380,10 @@ opal_btl_usnic_small_send_frag_alloc(opal_btl_usnic_module_t *module) static inline opal_btl_usnic_large_send_frag_t * opal_btl_usnic_large_send_frag_alloc(opal_btl_usnic_module_t *module) { - ompi_free_list_item_t *item; + opal_free_list_item_t *item; opal_btl_usnic_large_send_frag_t *frag; - OMPI_FREE_LIST_GET_MT(&(module->large_send_frags), item); + item = opal_free_list_get(&(module->large_send_frags)); if (OPAL_UNLIKELY(NULL == item)) { return NULL; } @@ -403,10 +403,10 @@ static inline opal_btl_usnic_put_dest_frag_t * opal_btl_usnic_put_dest_frag_alloc( struct opal_btl_usnic_module_t *module) { - ompi_free_list_item_t *item; + opal_free_list_item_t *item; opal_btl_usnic_put_dest_frag_t *frag; - OMPI_FREE_LIST_GET_MT(&(module->put_dest_frags), item); + item = opal_free_list_get(&(module->put_dest_frags)); if (OPAL_UNLIKELY(NULL == item)) { return NULL; } @@ -480,7 +480,7 @@ opal_btl_usnic_frag_return( } } - OMPI_FREE_LIST_RETURN_MT(frag->uf_freelist, &(frag->uf_base.super)); + opal_free_list_return(frag->uf_freelist, &(frag->uf_base.super)); } /* @@ -522,10 +522,10 @@ static inline opal_btl_usnic_chunk_segment_t * opal_btl_usnic_chunk_segment_alloc( opal_btl_usnic_module_t *module) { - ompi_free_list_item_t *item; + opal_free_list_item_t *item; opal_btl_usnic_send_segment_t *seg; - OMPI_FREE_LIST_GET_MT(&(module->chunk_segs), item); + item = opal_free_list_get(&(module->chunk_segs)); if (OPAL_UNLIKELY(NULL == item)) { return NULL; } @@ -547,7 +547,7 @@ opal_btl_usnic_chunk_segment_return( assert(seg); assert(OPAL_BTL_USNIC_SEG_CHUNK == seg->ss_base.us_type); - OMPI_FREE_LIST_RETURN_MT(&(module->chunk_segs), &(seg->ss_base.us_list)); + opal_free_list_return(&(module->chunk_segs), &(seg->ss_base.us_list)); } /* @@ -556,10 +556,10 @@ opal_btl_usnic_chunk_segment_return( static inline opal_btl_usnic_ack_segment_t * opal_btl_usnic_ack_segment_alloc(opal_btl_usnic_module_t *module) { - ompi_free_list_item_t *item; + opal_free_list_item_t *item; opal_btl_usnic_send_segment_t *ack; - OMPI_FREE_LIST_GET_MT(&(module->ack_segs), item); + item = opal_free_list_get(&(module->ack_segs)); if (OPAL_UNLIKELY(NULL == item)) { return NULL; } @@ -584,7 +584,7 @@ opal_btl_usnic_ack_segment_return( assert(ack); assert(OPAL_BTL_USNIC_SEG_ACK == ack->ss_base.us_type); - OMPI_FREE_LIST_RETURN_MT(&(module->ack_segs), &(ack->ss_base.us_list)); + opal_free_list_return(&(module->ack_segs), &(ack->ss_base.us_list)); } /* Compute and set the proper value for sfrag->sf_size. This must not be used diff --git a/opal/mca/btl/usnic/btl_usnic_module.c b/opal/mca/btl/usnic/btl_usnic_module.c index d3520bc2eb..594b107eb4 100644 --- a/opal/mca/btl/usnic/btl_usnic_module.c +++ b/opal/mca/btl/usnic/btl_usnic_module.c @@ -1511,7 +1511,7 @@ static int init_one_channel(opal_btl_usnic_module_t *module, int rc; uint32_t segsize; opal_btl_usnic_recv_segment_t *rseg; - ompi_free_list_item_t* item; + opal_free_list_item_t* item; struct opal_btl_usnic_channel_t *channel; struct fi_cq_attr cq_attr; @@ -1559,19 +1559,23 @@ static int init_one_channel(opal_btl_usnic_module_t *module, */ segsize = (max_msg_size + channel->info->ep_attr->msg_prefix_size + opal_cache_line_size - 1) & ~(opal_cache_line_size - 1); - OBJ_CONSTRUCT(&channel->recv_segs, ompi_free_list_t); - rc = ompi_free_list_init_new(&channel->recv_segs, - sizeof(opal_btl_usnic_recv_segment_t), - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_recv_segment_t), - segsize, - opal_cache_line_size, - rd_num, - rd_num, - rd_num, - module->super.btl_mpool); + OBJ_CONSTRUCT(&channel->recv_segs, opal_free_list_t); + rc = opal_free_list_init(&channel->recv_segs, + sizeof(opal_btl_usnic_recv_segment_t) /* frag size */, + opal_cache_line_size /* frag alignment */, + OBJ_CLASS(opal_btl_usnic_recv_segment_t), + segsize /* payload buffer size */, + opal_cache_line_size /* payload alignment */, + rd_num /* num erorments to alloc */, + rd_num /* max elements to alloc */, + rd_num /* num elements per alloc */, + module->super.btl_mpool /* memory pool for reg */, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); channel->recv_segs.ctx = module; /* must come after - ompi_free_list_init_new, + opal_free_list_init_new, otherwise ctx gets clobbered */ if (OPAL_SUCCESS != rc) { @@ -1580,7 +1584,7 @@ static int init_one_channel(opal_btl_usnic_module_t *module, /* Post receive descriptors */ for (i = 0; i < rd_num; i++) { - OMPI_FREE_LIST_GET_MT(&channel->recv_segs, item); + item = opal_free_list_get(&channel->recv_segs); assert(NULL != item); rseg = (opal_btl_usnic_recv_segment_t*)item; @@ -2015,61 +2019,77 @@ static void init_freelists(opal_btl_usnic_module_t *module) ~(opal_cache_line_size - 1); /* Send frags freelists */ - OBJ_CONSTRUCT(&module->small_send_frags, ompi_free_list_t); - rc = ompi_free_list_init_new(&module->small_send_frags, - sizeof(opal_btl_usnic_small_send_frag_t) + - mca_btl_usnic_component.transport_header_len, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_small_send_frag_t), - segsize, - opal_cache_line_size, - module->sd_num * 4, - -1, - module->sd_num / 2, - module->super.btl_mpool); + OBJ_CONSTRUCT(&module->small_send_frags, opal_free_list_t); + rc = opal_free_list_init(&module->small_send_frags, + sizeof(opal_btl_usnic_small_send_frag_t) + + mca_btl_usnic_component.transport_header_len, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_small_send_frag_t), + segsize, + opal_cache_line_size, + module->sd_num * 4, + -1, + module->sd_num / 2, + module->super.btl_mpool, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); - OBJ_CONSTRUCT(&module->large_send_frags, ompi_free_list_t); - rc = ompi_free_list_init_new(&module->large_send_frags, - sizeof(opal_btl_usnic_large_send_frag_t) + - mca_btl_usnic_component.transport_header_len, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_large_send_frag_t), - 0, /* payload size */ - 0, /* payload align */ - module->sd_num / 8, - -1, - module->sd_num / 8, - NULL); + OBJ_CONSTRUCT(&module->large_send_frags, opal_free_list_t); + rc = opal_free_list_init(&module->large_send_frags, + sizeof(opal_btl_usnic_large_send_frag_t) + + mca_btl_usnic_component.transport_header_len, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_large_send_frag_t), + 0, /* payload size */ + 0, /* payload align */ + module->sd_num / 8, + -1, + module->sd_num / 8, + NULL, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); - OBJ_CONSTRUCT(&module->put_dest_frags, ompi_free_list_t); - rc = ompi_free_list_init_new(&module->put_dest_frags, - sizeof(opal_btl_usnic_put_dest_frag_t) + - mca_btl_usnic_component.transport_header_len, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_put_dest_frag_t), - 0, /* payload size */ - 0, /* payload align */ - module->sd_num / 8, - -1, - module->sd_num / 8, - NULL); + OBJ_CONSTRUCT(&module->put_dest_frags, opal_free_list_t); + rc = opal_free_list_init(&module->put_dest_frags, + sizeof(opal_btl_usnic_put_dest_frag_t) + + mca_btl_usnic_component.transport_header_len, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_put_dest_frag_t), + 0, /* payload size */ + 0, /* payload align */ + module->sd_num / 8, + -1, + module->sd_num / 8, + NULL, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); /* list of segments to use for sending */ - OBJ_CONSTRUCT(&module->chunk_segs, ompi_free_list_t); - rc = ompi_free_list_init_new(&module->chunk_segs, - sizeof(opal_btl_usnic_chunk_segment_t) + - mca_btl_usnic_component.transport_header_len, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_chunk_segment_t), - segsize, - opal_cache_line_size, - module->sd_num * 4, - -1, - module->sd_num / 2, - module->super.btl_mpool); + OBJ_CONSTRUCT(&module->chunk_segs, opal_free_list_t); + rc = opal_free_list_init(&module->chunk_segs, + sizeof(opal_btl_usnic_chunk_segment_t) + + mca_btl_usnic_component.transport_header_len, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_chunk_segment_t), + segsize, + opal_cache_line_size, + module->sd_num * 4, + -1, + module->sd_num / 2, + module->super.btl_mpool, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); /* ACK segments freelist */ @@ -2077,18 +2097,22 @@ static void init_freelists(opal_btl_usnic_module_t *module) ack_segment_len = (sizeof(opal_btl_usnic_btl_header_t) + module->fabric_info->ep_attr->msg_prefix_size + opal_cache_line_size - 1) & ~(opal_cache_line_size - 1); - OBJ_CONSTRUCT(&module->ack_segs, ompi_free_list_t); - rc = ompi_free_list_init_new(&module->ack_segs, - sizeof(opal_btl_usnic_ack_segment_t) + - mca_btl_usnic_component.transport_header_len, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_ack_segment_t), - ack_segment_len, - opal_cache_line_size, - module->sd_num * 4, - -1, - module->sd_num / 2, - module->super.btl_mpool); + OBJ_CONSTRUCT(&module->ack_segs, opal_free_list_t); + rc = opal_free_list_init(&module->ack_segs, + sizeof(opal_btl_usnic_ack_segment_t) + + mca_btl_usnic_component.transport_header_len, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_ack_segment_t), + ack_segment_len, + opal_cache_line_size, + module->sd_num * 4, + -1, + module->sd_num / 2, + module->super.btl_mpool, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); /* @@ -2100,21 +2124,25 @@ static void init_freelists(opal_btl_usnic_module_t *module) module->first_pool = 16; /* 64 kiB */ module->last_pool = usnic_fls(module->super.btl_eager_limit-1); module->module_recv_buffers = calloc(module->last_pool+1, - sizeof(ompi_free_list_t)); + sizeof(opal_free_list_t)); assert(module->module_recv_buffers != NULL); for (int i = module->first_pool; i <= module->last_pool; ++i) { size_t elt_size = sizeof(opal_btl_usnic_rx_buf_t) - 1 + (1 << i); - OBJ_CONSTRUCT(&module->module_recv_buffers[i], ompi_free_list_t); - rc = ompi_free_list_init_new(&module->module_recv_buffers[i], - elt_size, - opal_cache_line_size, - OBJ_CLASS(opal_btl_usnic_rx_buf_t), - 0, /* payload size */ - 0, /* payload align */ - 128, /* init elts to alloc */ - 128, /* max elts to alloc */ - 128, /* num elts per alloc */ - NULL /* mpool */); + OBJ_CONSTRUCT(&module->module_recv_buffers[i], opal_free_list_t); + rc = opal_free_list_init(&module->module_recv_buffers[i], + elt_size, + opal_cache_line_size, + OBJ_CLASS(opal_btl_usnic_rx_buf_t), + 0, /* payload size */ + 0, /* payload align */ + 128, /* init elts to alloc */ + 128, /* max elts to alloc */ + 128, /* num elts per alloc */ + NULL /* mpool */, + 0 /* mpool reg flags */, + NULL /* unused0 */, + NULL /* item_init */, + NULL /* item_init_context */); assert(OPAL_SUCCESS == rc); } } diff --git a/opal/mca/btl/usnic/btl_usnic_module.h b/opal/mca/btl/usnic/btl_usnic_module.h index 42774436c6..9403775ece 100644 --- a/opal/mca/btl/usnic/btl_usnic_module.h +++ b/opal/mca/btl/usnic/btl_usnic_module.h @@ -87,7 +87,7 @@ typedef struct opal_btl_usnic_channel_t { struct opal_btl_usnic_recv_segment_t *repost_recv_head; /** receive segments & buffers */ - ompi_free_list_t recv_segs; + opal_free_list_t recv_segs; bool chan_error; /* set when error detected on channel */ @@ -163,15 +163,15 @@ typedef struct opal_btl_usnic_module_t { opal_pointer_array_t all_procs; /** send fragments & buffers */ - ompi_free_list_t small_send_frags; - ompi_free_list_t large_send_frags; - ompi_free_list_t put_dest_frags; - ompi_free_list_t chunk_segs; + opal_free_list_t small_send_frags; + opal_free_list_t large_send_frags; + opal_free_list_t put_dest_frags; + opal_free_list_t chunk_segs; /** receive buffer pools */ int first_pool; int last_pool; - ompi_free_list_t *module_recv_buffers; + opal_free_list_t *module_recv_buffers; /** list of endpoints with data to send */ /* this list uses base endpoint ptr */ @@ -182,7 +182,7 @@ typedef struct opal_btl_usnic_module_t { opal_list_t pending_resend_segs; /** ack segments */ - ompi_free_list_t ack_segs; + opal_free_list_t ack_segs; /** list of endpoints to which we need to send ACKs */ /* this list uses endpoint->endpoint_ack_li */ diff --git a/opal/mca/btl/usnic/btl_usnic_recv.c b/opal/mca/btl/usnic/btl_usnic_recv.c index 910495b1a3..d717ae6255 100644 --- a/opal/mca/btl/usnic/btl_usnic_recv.c +++ b/opal/mca/btl/usnic/btl_usnic_recv.c @@ -215,10 +215,10 @@ void opal_btl_usnic_recv_call(opal_btl_usnic_module_t *module, pool = usnic_fls(chunk_hdr->ch_frag_size-1); if (pool >= module->first_pool && pool <= module->last_pool) { - ompi_free_list_item_t* item; + opal_free_list_item_t* item; opal_btl_usnic_rx_buf_t *rx_buf; - OMPI_FREE_LIST_GET_MT(&module->module_recv_buffers[pool], - item); + item = + opal_free_list_get(&module->module_recv_buffers[pool]); rx_buf = (opal_btl_usnic_rx_buf_t *)item; if (OPAL_LIKELY(NULL != rx_buf)) { fip->rfi_fl_elt = item; @@ -304,7 +304,7 @@ void opal_btl_usnic_recv_call(opal_btl_usnic_module_t *module, /* free temp buffer for non-put */ if (fip->rfi_data_in_pool) { - OMPI_FREE_LIST_RETURN_MT( + opal_free_list_return( &module->module_recv_buffers[fip->rfi_data_pool], fip->rfi_fl_elt); } else {