@@ -44,6 +44,29 @@ ompi_mtl_portals4_callback(ptl_event_t *ev,
4444 ompi_mtl_portals4_isend_request_t * ptl_request =
4545 (ompi_mtl_portals4_isend_request_t * ) ptl_base_request ;
4646
47+ if (PTL_EVENT_GET == ev -> type ) {
48+ ret = OPAL_THREAD_ADD32 (& (ptl_request -> pending_get ), -1 );
49+ if (ret > 0 ) {
50+ /* wait for other gets */
51+ OPAL_OUTPUT_VERBOSE ((90 , ompi_mtl_base_framework .framework_output , "PTL_EVENT_GET received now pending_get=%d" ,ret ));
52+ return retval ;
53+ }
54+ assert (ptl_request -> pending_get == 0 );
55+
56+ /* last get received */
57+ OPAL_OUTPUT_VERBOSE ((90 , ompi_mtl_base_framework .framework_output , "PTL_EVENT_GET: PtlMEUnlink is called ptl_request->me_h=%d (pending get=%d)" , ptl_request -> me_h , ret ));
58+
59+ if (!PtlHandleIsEqual (ptl_request -> me_h , PTL_INVALID_HANDLE )) {
60+ ret = PtlMEUnlink (ptl_request -> me_h );
61+ if (PTL_OK != ret ) {
62+ opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
63+ "%s:%d: send callback PtlMEUnlink returned %d" ,
64+ __FILE__ , __LINE__ , ret );
65+ }
66+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
67+ }
68+ }
69+
4770#if OMPI_MTL_PORTALS4_FLOW_CONTROL
4871 if (OPAL_UNLIKELY (ev -> ni_fail_type == PTL_NI_PT_DISABLED )) {
4972 ompi_mtl_portals4_pending_request_t * pending =
@@ -66,6 +89,7 @@ ompi_mtl_portals4_callback(ptl_event_t *ev,
6689 "%s:%d: send callback PtlMEUnlink returned %d" ,
6790 __FILE__ , __LINE__ , ret );
6891 }
92+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
6993 }
7094
7195 opal_list_append (& ompi_mtl_portals4 .flowctl .pending_sends ,
@@ -89,6 +113,33 @@ ompi_mtl_portals4_callback(ptl_event_t *ev,
89113 "send %lu got event of type %d" ,
90114 ptl_request -> opcount , ev -> type ));
91115
116+ /* First put achieved successfully (In the Priority List), so it may be necessary to decrement the number of pending get
117+ * If the protocol is eager, just decrement pending_get
118+ * Else (the protocol is rndv), decrement pending_get only if length % max_msg_size <= eager_limit
119+ * (This is the case where the eager part allows to save one get)
120+ */
121+ if ((PTL_EVENT_ACK == ev -> type ) &&
122+ (PTL_PRIORITY_LIST == ev -> ptl_list ) &&
123+ (0 < ptl_request -> pending_get )) {
124+
125+ if ((eager == ompi_mtl_portals4 .protocol ) ||
126+ (ptl_request -> length % ompi_mtl_portals4 .max_msg_size_mtl <= ompi_mtl_portals4 .eager_limit )) {
127+ val = OPAL_THREAD_ADD32 (& (ptl_request -> pending_get ), -1 );
128+ }
129+ if (0 == val ) {
130+ add = 2 ; /* We haven't to wait for any get, so we have to add an extra count to cause the message to complete */
131+ if (!PtlHandleIsEqual (ptl_request -> me_h , PTL_INVALID_HANDLE )) {
132+ ret = PtlMEUnlink (ptl_request -> me_h );
133+ if (PTL_OK != ret ) {
134+ opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
135+ "%s:%d: send callback PtlMEUnlink returned %d" ,
136+ __FILE__ , __LINE__ , ret );
137+ }
138+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
139+ }
140+ }
141+ }
142+
92143 if ((PTL_EVENT_ACK == ev -> type ) &&
93144 (PTL_PRIORITY_LIST == ev -> ptl_list ) &&
94145 (ev -> mlength == ptl_request -> length ) &&
@@ -107,10 +158,10 @@ ompi_mtl_portals4_callback(ptl_event_t *ev,
107158 "%s:%d: send callback PtlMEUnlink returned %d" ,
108159 __FILE__ , __LINE__ , ret );
109160 }
161+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
110162 add ++ ;
111163 }
112164 val = OPAL_THREAD_ADD32 ((int32_t * )& ptl_request -> event_count , add );
113-
114165 assert (val <= 3 );
115166
116167 if (val == 3 ) {
@@ -193,6 +244,7 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
193244
194245 MTL_PORTALS4_SET_HDR_DATA (hdr_data , ptl_request -> opcount , length ,
195246 (MCA_PML_BASE_SEND_SYNCHRONOUS == mode ) ? 1 : 0 );
247+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
196248
197249 if (MCA_PML_BASE_SEND_SYNCHRONOUS == mode ) {
198250 me .start = NULL ;
@@ -219,6 +271,7 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
219271 opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
220272 "%s:%d: PtlMEAppend failed: %d" ,
221273 __FILE__ , __LINE__ , ret );
274+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
222275 return ompi_mtl_portals4_get_error (ret );
223276 }
224277
@@ -227,7 +280,6 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
227280 ptl_request -> opcount , hdr_data , match_bits ));
228281 } else {
229282 ptl_request -> event_count = 1 ;
230- ptl_request -> me_h = PTL_INVALID_HANDLE ;
231283
232284 OPAL_OUTPUT_VERBOSE ((50 , ompi_mtl_base_framework .framework_output ,
233285 "Send %lu short send with hdr_data 0x%lx (0x%lx)" ,
@@ -238,6 +290,7 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
238290 "Send %lu, start: %p" ,
239291 ptl_request -> opcount , start ));
240292
293+ ptl_request -> pending_get = 0 ;
241294 ret = PtlPut (ompi_mtl_portals4 .send_md_h ,
242295 (ptl_size_t ) start ,
243296 length ,
@@ -254,6 +307,7 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
254307 __FILE__ , __LINE__ , ret );
255308 if (MCA_PML_BASE_SEND_SYNCHRONOUS == mode ) {
256309 PtlMEUnlink (ptl_request -> me_h );
310+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
257311 }
258312 return ompi_mtl_portals4_get_error (ret );
259313 }
@@ -285,7 +339,6 @@ ompi_mtl_portals4_long_isend(void *start, size_t length, int contextid, int tag,
285339 me .uid = ompi_mtl_portals4 .uid ;
286340 me .options =
287341 PTL_ME_OP_GET |
288- PTL_ME_USE_ONCE |
289342 PTL_ME_EVENT_LINK_DISABLE |
290343 PTL_ME_EVENT_UNLINK_DISABLE ;
291344 me .match_id = ptl_proc ;
@@ -309,10 +362,32 @@ ompi_mtl_portals4_long_isend(void *start, size_t length, int contextid, int tag,
309362 "Send %lu long send with hdr_data 0x%lx (0x%lx)" ,
310363 ptl_request -> opcount , hdr_data , match_bits ));
311364
312- if ((rndv == ompi_mtl_portals4 .protocol ) && ((ptl_size_t ) length > (ptl_size_t ) ompi_mtl_portals4 .eager_limit ))
313- put_length = (ptl_size_t ) ompi_mtl_portals4 .eager_limit ;
314- else put_length = (ptl_size_t ) length ;
365+ if (rndv == ompi_mtl_portals4 .protocol ) {
366+ ptl_size_t min = (OPAL_LIKELY (ompi_mtl_portals4 .eager_limit < ompi_mtl_portals4 .max_msg_size_mtl )) ?
367+ ompi_mtl_portals4 .eager_limit :
368+ ompi_mtl_portals4 .max_msg_size_mtl ;
369+ if ((ptl_size_t ) length > (ptl_size_t ) min ) {
370+ OPAL_OUTPUT_VERBOSE ((90 , ompi_mtl_base_framework .framework_output ,
371+ "msg truncated by %ld" , length - min ));
372+ put_length = (ptl_size_t ) min ;
373+ }
374+ else
375+ put_length = (ptl_size_t ) length ;
376+ } else { // eager protocol
377+ if (length > ompi_mtl_portals4 .max_msg_size_mtl )
378+ put_length = (ptl_size_t ) ompi_mtl_portals4 .max_msg_size_mtl ;
379+ else
380+ put_length = (ptl_size_t ) length ;
381+ }
382+
383+ /* We have to wait for some GET events.
384+ If the first put falls in overflow list, the number of GET event is egal to:
385+ (length - 1) / ompi_mtl_portals4.max_msg_size_mtl + 1
386+ else we will re-calculate this number when we received the first ACK event (with remote overflow list)
387+ */
315388
389+ ptl_request -> pending_get = (length - 1 ) / ompi_mtl_portals4 .max_msg_size_mtl + 1 ;
390+ OPAL_OUTPUT_VERBOSE ((90 , ompi_mtl_base_framework .framework_output , "pending_get=%d" , ptl_request -> pending_get ));
316391
317392 ret = PtlPut (ompi_mtl_portals4 .send_md_h ,
318393 (ptl_size_t ) start ,
@@ -328,7 +403,8 @@ ompi_mtl_portals4_long_isend(void *start, size_t length, int contextid, int tag,
328403 opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
329404 "%s:%d: PtlPut failed: %d" ,
330405 __FILE__ , __LINE__ , ret );
331- PtlMEUnlink (ptl_request -> me_h );
406+ PtlMEUnlink (ptl_request -> me_h );
407+ ptl_request -> me_h = PTL_INVALID_HANDLE ;
332408 return ompi_mtl_portals4_get_error (ret );
333409 }
334410
0 commit comments