1
1

usnic: restore compatibility with the v1.8 branch

Also include two other minor changes:

1. More C99-style member initialization in the component struct
1. Fix the BTL module member initialization to not be redundant
Этот коммит содержится в:
Jeff Squyres 2015-02-25 05:37:51 -08:00
родитель b28e1d1b51
Коммит f3c9354d4b
7 изменённых файлов: 106 добавлений и 39 удалений

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

@ -33,8 +33,6 @@
#include "opal/class/opal_hash_table.h"
#include "opal/mca/event/event.h"
#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"

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

@ -119,6 +119,36 @@ const char *usnic_compat_proc_name_print(opal_process_name_t *pname)
return OMPI_NAME_PRINT(pname);
}
/*
* In v1.8, we call ompi_free_list_init, and ignore some of these params
*/
int usnic_compat_free_list_init(opal_free_list_t *free_list,
size_t frag_size,
size_t frag_alignment,
opal_class_t* frag_class,
size_t payload_buffer_size,
size_t payload_buffer_alignment,
int num_elements_to_alloc,
int max_elements_to_alloc,
int num_elements_per_alloc,
struct mca_mpool_base_module_t *mpool,
int mpool_reg_flags,
void *unused0,
opal_free_list_item_init_fn_t item_init,
void *ctx)
{
return ompi_free_list_init_new(free_list,
frag_size,
frag_alignment,
frag_class,
payload_buffer_size,
payload_buffer_alignment,
num_elements_to_alloc,
max_elements_to_alloc,
num_elements_per_alloc,
mpool);
}
#endif /* OMPI version */
/************************************************************************/

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

@ -29,6 +29,9 @@
/* Proc stuff */
# include "opal/util/proc.h"
/* Free lists are unified into OPAL free lists */
# include "opal/class/opal_free_list.h"
# define USNIC_OUT opal_btl_base_framework.framework_output
/* JMS Really want to be able to get the job size somehow... But for
now, so that we can compile, just set it to a constant :-( */
@ -57,6 +60,13 @@
# define BTL_VERSION 30
# define USNIC_COMPAT_FREE_LIST_GET(list, item) \
(item) = opal_free_list_get((list))
# define USNIC_COMPAT_FREE_LIST_RETURN(list, item) \
opal_free_list_return((list), (item))
# define usnic_compat_free_list_init opal_free_list_init
/*
* Performance critical; needs to be inline
*/
@ -79,6 +89,9 @@ usnic_compat_proc_name_compare(opal_process_name_t a,
/* Proc stuff */
# include "ompi/proc/proc.h"
/* Use OMPI free lists in v1.8 */
# include "ompi/class/ompi_free_list.h"
# define USNIC_OUT ompi_btl_base_framework.framework_output
# define USNIC_MCW_SIZE ompi_process_info.num_procs
# define proc_bound() (ompi_rte_proc_is_bound)
@ -138,8 +151,17 @@ usnic_compat_proc_name_compare(opal_process_name_t a,
# define BTL_VERSION 20
# define opal_free_list_t ompi_free_list_t
# define opal_free_list_item_t ompi_free_list_item_t
# define opal_free_list_item_init_fn_t ompi_free_list_item_init_fn_t
# define USNIC_COMPAT_FREE_LIST_GET(list, item) \
OMPI_FREE_LIST_GET_MT(list, (item))
# define USNIC_COMPAT_FREE_LIST_RETURN(list, item) \
OMPI_FREE_LIST_RETURN_MT((list), (item))
# define USNIC_COMPAT_BASE_VERSION \
MCA_BTL_BASE_VERSION_2_0_0, \
MCA_BASE_VERSION_2_0_0, \
.mca_type_name = "btl", \
.mca_type_major_version = OMPI_MAJOR_VERSION, \
.mca_type_minor_version = OMPI_MINOR_VERSION, \
@ -169,6 +191,24 @@ usnic_compat_proc_name_compare(opal_process_name_t a,
*/
char* opal_get_proc_hostname(opal_proc_t *proc);
/*
* Wrapper to call ompi_free_list_init
*/
int usnic_compat_free_list_init(opal_free_list_t *free_list,
size_t frag_size,
size_t frag_alignment,
opal_class_t* frag_class,
size_t payload_buffer_size,
size_t payload_buffer_alignment,
int num_elements_to_alloc,
int max_elements_to_alloc,
int num_elements_per_alloc,
struct mca_mpool_base_module_t *mpool,
int mpool_reg_flags,
void *unused0,
opal_free_list_item_init_fn_t item_init,
void *ctx);
/************************************************************************/
#else

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

@ -133,7 +133,7 @@ static void free_filter(usnic_if_filter_t *filter);
opal_btl_usnic_component_t mca_btl_usnic_component = {
{
.super = {
/* First, the mca_base_component_t struct containing meta information
about the component itself */
.btl_version = {

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

@ -361,7 +361,7 @@ opal_btl_usnic_small_send_frag_alloc(opal_btl_usnic_module_t *module)
opal_free_list_item_t *item;
opal_btl_usnic_small_send_frag_t *frag;
item = opal_free_list_get(&(module->small_send_frags));
USNIC_COMPAT_FREE_LIST_GET(&(module->small_send_frags), item);
if (OPAL_UNLIKELY(NULL == item)) {
return NULL;
}
@ -383,7 +383,7 @@ opal_btl_usnic_large_send_frag_alloc(opal_btl_usnic_module_t *module)
opal_free_list_item_t *item;
opal_btl_usnic_large_send_frag_t *frag;
item = opal_free_list_get(&(module->large_send_frags));
USNIC_COMPAT_FREE_LIST_GET(&(module->large_send_frags), item);
if (OPAL_UNLIKELY(NULL == item)) {
return NULL;
}
@ -406,7 +406,7 @@ opal_btl_usnic_put_dest_frag_alloc(
opal_free_list_item_t *item;
opal_btl_usnic_put_dest_frag_t *frag;
item = opal_free_list_get(&(module->put_dest_frags));
USNIC_COMPAT_FREE_LIST_GET(&(module->put_dest_frags), item);
if (OPAL_UNLIKELY(NULL == item)) {
return NULL;
}
@ -480,7 +480,7 @@ opal_btl_usnic_frag_return(
}
}
opal_free_list_return(frag->uf_freelist, &(frag->uf_base.super));
USNIC_COMPAT_FREE_LIST_RETURN(frag->uf_freelist, &(frag->uf_base.super));
}
/*
@ -525,7 +525,7 @@ opal_btl_usnic_chunk_segment_alloc(
opal_free_list_item_t *item;
opal_btl_usnic_send_segment_t *seg;
item = opal_free_list_get(&(module->chunk_segs));
USNIC_COMPAT_FREE_LIST_GET(&(module->chunk_segs), item);
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);
opal_free_list_return(&(module->chunk_segs), &(seg->ss_base.us_list));
USNIC_COMPAT_FREE_LIST_RETURN(&(module->chunk_segs), &(seg->ss_base.us_list));
}
/*
@ -559,7 +559,7 @@ opal_btl_usnic_ack_segment_alloc(opal_btl_usnic_module_t *module)
opal_free_list_item_t *item;
opal_btl_usnic_send_segment_t *ack;
item = opal_free_list_get(&(module->ack_segs));
USNIC_COMPAT_FREE_LIST_GET(&(module->ack_segs), item);
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);
opal_free_list_return(&(module->ack_segs), &(ack->ss_base.us_list));
USNIC_COMPAT_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

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

@ -1560,22 +1560,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, 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 */);
rc =
usnic_compat_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 alignmt */,
rd_num /* num erorments to alloc */,
rd_num /* max elements to alloc */,
rd_num /* num elements per alloc */,
module->super.btl_mpool /* mpool for reg */,
0 /* mpool reg flags */,
NULL /* unused0 */,
NULL /* item_init */,
NULL /* item_init_context */);
channel->recv_segs.ctx = module; /* must come after
opal_free_list_init_new,
free_list_init,
otherwise ctx gets
clobbered */
if (OPAL_SUCCESS != rc) {
@ -1584,7 +1585,7 @@ static int init_one_channel(opal_btl_usnic_module_t *module,
/* Post receive descriptors */
for (i = 0; i < rd_num; i++) {
item = opal_free_list_get(&channel->recv_segs);
USNIC_COMPAT_FREE_LIST_GET(&channel->recv_segs, item);
assert(NULL != item);
rseg = (opal_btl_usnic_recv_segment_t*)item;
@ -2020,7 +2021,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
/* Send frags freelists */
OBJ_CONSTRUCT(&module->small_send_frags, opal_free_list_t);
rc = opal_free_list_init(&module->small_send_frags,
rc = usnic_compat_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,
@ -2038,7 +2039,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
assert(OPAL_SUCCESS == rc);
OBJ_CONSTRUCT(&module->large_send_frags, opal_free_list_t);
rc = opal_free_list_init(&module->large_send_frags,
rc = usnic_compat_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,
@ -2056,7 +2057,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
assert(OPAL_SUCCESS == rc);
OBJ_CONSTRUCT(&module->put_dest_frags, opal_free_list_t);
rc = opal_free_list_init(&module->put_dest_frags,
rc = usnic_compat_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,
@ -2075,7 +2076,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
/* list of segments to use for sending */
OBJ_CONSTRUCT(&module->chunk_segs, opal_free_list_t);
rc = opal_free_list_init(&module->chunk_segs,
rc = usnic_compat_free_list_init(&module->chunk_segs,
sizeof(opal_btl_usnic_chunk_segment_t) +
mca_btl_usnic_component.transport_header_len,
opal_cache_line_size,
@ -2098,7 +2099,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
module->fabric_info->ep_attr->msg_prefix_size +
opal_cache_line_size - 1) & ~(opal_cache_line_size - 1);
OBJ_CONSTRUCT(&module->ack_segs, opal_free_list_t);
rc = opal_free_list_init(&module->ack_segs,
rc = usnic_compat_free_list_init(&module->ack_segs,
sizeof(opal_btl_usnic_ack_segment_t) +
mca_btl_usnic_component.transport_header_len,
opal_cache_line_size,
@ -2129,7 +2130,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
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], opal_free_list_t);
rc = opal_free_list_init(&module->module_recv_buffers[i],
rc = usnic_compat_free_list_init(&module->module_recv_buffers[i],
elt_size,
opal_cache_line_size,
OBJ_CLASS(opal_btl_usnic_rx_buf_t),

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

@ -217,8 +217,7 @@ void opal_btl_usnic_recv_call(opal_btl_usnic_module_t *module,
pool <= module->last_pool) {
opal_free_list_item_t* item;
opal_btl_usnic_rx_buf_t *rx_buf;
item =
opal_free_list_get(&module->module_recv_buffers[pool]);
USNIC_COMPAT_FREE_LIST_GET(&module->module_recv_buffers[pool], item);
rx_buf = (opal_btl_usnic_rx_buf_t *)item;
if (OPAL_LIKELY(NULL != rx_buf)) {
fip->rfi_fl_elt = item;
@ -304,9 +303,8 @@ void opal_btl_usnic_recv_call(opal_btl_usnic_module_t *module,
/* free temp buffer for non-put */
if (fip->rfi_data_in_pool) {
opal_free_list_return(
&module->module_recv_buffers[fip->rfi_data_pool],
fip->rfi_fl_elt);
USNIC_COMPAT_FREE_LIST_RETURN(&module->module_recv_buffers[fip->rfi_data_pool],
fip->rfi_fl_elt);
} else {
free(fip->rfi_data);
}