@@ -1421,7 +1421,7 @@ static int create_ep(opal_btl_usnic_module_t* module,
14211421 opal_process_info .my_local_rank );
14221422 }
14231423
1424- rc = fi_getinfo (FI_VERSION (1 , 0 ), NULL , 0 , 0 , hint , & channel -> info );
1424+ rc = fi_getinfo (FI_VERSION (1 , 1 ), NULL , 0 , 0 , hint , & channel -> info );
14251425 fi_freeinfo (hint );
14261426 if (0 != rc ) {
14271427 opal_show_help ("help-mpi-btl-usnic.txt" ,
@@ -1634,6 +1634,9 @@ static int init_one_channel(opal_btl_usnic_module_t *module,
16341634 goto error ;
16351635 }
16361636
1637+ assert (channel -> info -> ep_attr -> msg_prefix_size ==
1638+ (uint32_t ) mca_btl_usnic_component .transport_header_len );
1639+
16371640 /*
16381641 * Initialize pool of receive segments. Round MTU up to cache
16391642 * line size so that each segment is guaranteed to start on a
@@ -1777,6 +1780,33 @@ static void init_find_transport_header_len(opal_btl_usnic_module_t *module)
17771780 module -> fabric_info -> ep_attr -> msg_prefix_size ;
17781781 mca_btl_usnic_component .transport_protocol =
17791782 module -> fabric_info -> ep_attr -> protocol ;
1783+
1784+ /* The usnic provider in libfabric v1.0.0 (i.e., API v1.0) treated
1785+ FI_MSG_PREFIX inconsistently between senders and receivers. It
1786+ was corrected in libfabric v1.1.0 (i.e., API v1.1), meaning
1787+ that FI_MSG_PREFIX is treated consistently between senders and
1788+ receivers.
1789+
1790+ So check what version of the libfabric API we have, and setup
1791+ to use the "old" (inconsistent) MSG_PREFIX behavior, or the
1792+ "new" MSG_PREFIX (consistent) behavior.
1793+
1794+ NOTE: This is a little redundant; we're setting a
1795+ component-level attribute during each module's setup. We do
1796+ this here (and not earlier, when we check fi_version() during
1797+ the component setup) because we can't obtain the value of the
1798+ endpoint msg_prefix_size until we setup the first module.
1799+ Also, it's safe because each module will set the component
1800+ attribute to the same value. So it's ok. */
1801+ uint32_t libfabric_api ;
1802+ libfabric_api = fi_version ();
1803+ if (1 == FI_MAJOR (libfabric_api ) &&
1804+ 0 == FI_MINOR (libfabric_api )) {
1805+ mca_btl_usnic_component .prefix_send_offset = 0 ;
1806+ } else {
1807+ mca_btl_usnic_component .prefix_send_offset =
1808+ module -> fabric_info -> ep_attr -> msg_prefix_size ;
1809+ }
17801810}
17811811
17821812/*
@@ -1835,13 +1865,15 @@ static void init_payload_lengths(opal_btl_usnic_module_t *module)
18351865 /* Find the max payload this port can handle */
18361866 module -> max_frag_payload =
18371867 module -> local_modex .max_msg_size - /* start with the MTU */
1838- sizeof (opal_btl_usnic_btl_header_t ); /* subtract size of
1839- the BTL header */
1868+ sizeof (opal_btl_usnic_btl_header_t ) - /* subtract size of
1869+ the BTL header */
1870+ mca_btl_usnic_component .prefix_send_offset ;
18401871
18411872 /* same, but use chunk header */
18421873 module -> max_chunk_payload =
18431874 module -> local_modex .max_msg_size -
1844- sizeof (opal_btl_usnic_btl_chunk_header_t );
1875+ sizeof (opal_btl_usnic_btl_chunk_header_t ) -
1876+ mca_btl_usnic_component .prefix_send_offset ;
18451877
18461878 /* Priorirty queue MTU and max size */
18471879 if (0 == module -> max_tiny_msg_size ) {
@@ -2097,15 +2129,14 @@ static void init_freelists(opal_btl_usnic_module_t *module)
20972129 uint32_t segsize ;
20982130
20992131 segsize = (module -> local_modex .max_msg_size +
2100- module -> fabric_info -> ep_attr -> msg_prefix_size +
21012132 opal_cache_line_size - 1 ) &
21022133 ~(opal_cache_line_size - 1 );
21032134
21042135 /* Send frags freelists */
21052136 OBJ_CONSTRUCT (& module -> small_send_frags , opal_free_list_t );
21062137 rc = usnic_compat_free_list_init (& module -> small_send_frags ,
21072138 sizeof (opal_btl_usnic_small_send_frag_t ) +
2108- mca_btl_usnic_component .transport_header_len ,
2139+ mca_btl_usnic_component .prefix_send_offset ,
21092140 opal_cache_line_size ,
21102141 OBJ_CLASS (opal_btl_usnic_small_send_frag_t ),
21112142 segsize ,
@@ -2123,7 +2154,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
21232154 OBJ_CONSTRUCT (& module -> large_send_frags , opal_free_list_t );
21242155 rc = usnic_compat_free_list_init (& module -> large_send_frags ,
21252156 sizeof (opal_btl_usnic_large_send_frag_t ) +
2126- mca_btl_usnic_component .transport_header_len ,
2157+ mca_btl_usnic_component .prefix_send_offset ,
21272158 opal_cache_line_size ,
21282159 OBJ_CLASS (opal_btl_usnic_large_send_frag_t ),
21292160 0 , /* payload size */
@@ -2141,7 +2172,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
21412172 OBJ_CONSTRUCT (& module -> put_dest_frags , opal_free_list_t );
21422173 rc = usnic_compat_free_list_init (& module -> put_dest_frags ,
21432174 sizeof (opal_btl_usnic_put_dest_frag_t ) +
2144- mca_btl_usnic_component .transport_header_len ,
2175+ mca_btl_usnic_component .prefix_send_offset ,
21452176 opal_cache_line_size ,
21462177 OBJ_CLASS (opal_btl_usnic_put_dest_frag_t ),
21472178 0 , /* payload size */
@@ -2160,7 +2191,7 @@ static void init_freelists(opal_btl_usnic_module_t *module)
21602191 OBJ_CONSTRUCT (& module -> chunk_segs , opal_free_list_t );
21612192 rc = usnic_compat_free_list_init (& module -> chunk_segs ,
21622193 sizeof (opal_btl_usnic_chunk_segment_t ) +
2163- mca_btl_usnic_component .transport_header_len ,
2194+ mca_btl_usnic_component .prefix_send_offset ,
21642195 opal_cache_line_size ,
21652196 OBJ_CLASS (opal_btl_usnic_chunk_segment_t ),
21662197 segsize ,
@@ -2178,12 +2209,11 @@ static void init_freelists(opal_btl_usnic_module_t *module)
21782209 /* ACK segments freelist */
21792210 uint32_t ack_segment_len ;
21802211 ack_segment_len = (sizeof (opal_btl_usnic_btl_header_t ) +
2181- module -> fabric_info -> ep_attr -> msg_prefix_size +
21822212 opal_cache_line_size - 1 ) & ~(opal_cache_line_size - 1 );
21832213 OBJ_CONSTRUCT (& module -> ack_segs , opal_free_list_t );
21842214 rc = usnic_compat_free_list_init (& module -> ack_segs ,
21852215 sizeof (opal_btl_usnic_ack_segment_t ) +
2186- mca_btl_usnic_component .transport_header_len ,
2216+ mca_btl_usnic_component .prefix_send_offset ,
21872217 opal_cache_line_size ,
21882218 OBJ_CLASS (opal_btl_usnic_ack_segment_t ),
21892219 ack_segment_len ,
0 commit comments