1414 * Copyright (c) 2006-2008 University of Houston. All rights reserved.
1515 * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1616 * Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
17- * Copyright (c) 2015 Research Organization for Information Science
17+ * Copyright (c) 2015-2016 Research Organization for Information Science
1818 * and Technology (RIST). All rights reserved.
1919 * $COPYRIGHT$
2020 *
@@ -142,44 +142,62 @@ static int component_register (void)
142142 NULL , 0 , 0 , OPAL_INFO_LVL_9 , MCA_BASE_VAR_SCOPE_READONLY ,
143143 & mca_osc_pt2pt_component .buffer_size );
144144
145+ mca_osc_pt2pt_component .receive_count = 4 ;
146+ (void ) mca_base_component_var_register (& mca_osc_pt2pt_component .super .osc_version , "receive_count" ,
147+ "Number of receives to post for each window for incoming fragments "
148+ "(default: 4)" , MCA_BASE_VAR_TYPE_UNSIGNED_INT , NULL , 0 , 0 , OPAL_INFO_LVL_4 ,
149+ MCA_BASE_VAR_SCOPE_READONLY , & mca_osc_pt2pt_component .receive_count );
150+
145151 return OMPI_SUCCESS ;
146152}
147153
148154static int component_progress (void )
149155{
150- int count = opal_list_get_size (& mca_osc_pt2pt_component .pending_operations );
156+ int pending_count = opal_list_get_size (& mca_osc_pt2pt_component .pending_operations );
157+ int recv_count = opal_list_get_size (& mca_osc_pt2pt_component .pending_receives );
151158 ompi_osc_pt2pt_pending_t * pending , * next ;
152159
153- if (0 == count ) {
154- return 0 ;
160+ if (recv_count ) {
161+ for (int i = 0 ; i < recv_count ; ++ i ) {
162+ OPAL_THREAD_LOCK (& mca_osc_pt2pt_component .pending_receives_lock );
163+ ompi_osc_pt2pt_receive_t * recv = (ompi_osc_pt2pt_receive_t * ) opal_list_remove_first (& mca_osc_pt2pt_component .pending_receives );
164+ OPAL_THREAD_UNLOCK (& mca_osc_pt2pt_component .pending_receives_lock );
165+ if (NULL == recv ) {
166+ break ;
167+ }
168+
169+ (void ) ompi_osc_pt2pt_process_receive (recv );
170+ }
155171 }
156172
157173 /* process one incoming request */
158- OPAL_THREAD_LOCK (& mca_osc_pt2pt_component .pending_operations_lock );
159- OPAL_LIST_FOREACH_SAFE (pending , next , & mca_osc_pt2pt_component .pending_operations , ompi_osc_pt2pt_pending_t ) {
160- int ret ;
161-
162- switch (pending -> header .base .type ) {
163- case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ :
164- ret = ompi_osc_pt2pt_process_flush (pending -> module , pending -> source ,
165- & pending -> header .flush );
166- break ;
167- case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ :
168- ret = ompi_osc_pt2pt_process_unlock (pending -> module , pending -> source ,
169- & pending -> header .unlock );
170- break ;
171- default :
172- /* shouldn't happen */
173- assert (0 );
174- abort ();
175- }
176-
177- if (OMPI_SUCCESS == ret ) {
178- opal_list_remove_item (& mca_osc_pt2pt_component .pending_operations , & pending -> super );
179- OBJ_RELEASE (pending );
180- }
174+ if (pending_count ) {
175+ OPAL_THREAD_LOCK (& mca_osc_pt2pt_component .pending_operations_lock );
176+ OPAL_LIST_FOREACH_SAFE (pending , next , & mca_osc_pt2pt_component .pending_operations , ompi_osc_pt2pt_pending_t ) {
177+ int ret ;
178+
179+ switch (pending -> header .base .type ) {
180+ case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ :
181+ ret = ompi_osc_pt2pt_process_flush (pending -> module , pending -> source ,
182+ & pending -> header .flush );
183+ break ;
184+ case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ :
185+ ret = ompi_osc_pt2pt_process_unlock (pending -> module , pending -> source ,
186+ & pending -> header .unlock );
187+ break ;
188+ default :
189+ /* shouldn't happen */
190+ assert (0 );
191+ abort ();
192+ }
193+
194+ if (OMPI_SUCCESS == ret ) {
195+ opal_list_remove_item (& mca_osc_pt2pt_component .pending_operations , & pending -> super );
196+ OBJ_RELEASE (pending );
197+ }
198+ }
199+ OPAL_THREAD_UNLOCK (& mca_osc_pt2pt_component .pending_operations_lock );
181200 }
182- OPAL_THREAD_UNLOCK (& mca_osc_pt2pt_component .pending_operations_lock );
183201
184202 return 1 ;
185203}
@@ -193,6 +211,8 @@ component_init(bool enable_progress_threads,
193211 OBJ_CONSTRUCT (& mca_osc_pt2pt_component .lock , opal_mutex_t );
194212 OBJ_CONSTRUCT (& mca_osc_pt2pt_component .pending_operations , opal_list_t );
195213 OBJ_CONSTRUCT (& mca_osc_pt2pt_component .pending_operations_lock , opal_mutex_t );
214+ OBJ_CONSTRUCT (& mca_osc_pt2pt_component .pending_receives , opal_list_t );
215+ OBJ_CONSTRUCT (& mca_osc_pt2pt_component .pending_receives_lock , opal_mutex_t );
196216
197217 OBJ_CONSTRUCT (& mca_osc_pt2pt_component .modules ,
198218 opal_hash_table_t );
@@ -253,6 +273,8 @@ component_finalize(void)
253273 OBJ_DESTRUCT (& mca_osc_pt2pt_component .requests );
254274 OBJ_DESTRUCT (& mca_osc_pt2pt_component .pending_operations );
255275 OBJ_DESTRUCT (& mca_osc_pt2pt_component .pending_operations_lock );
276+ OBJ_DESTRUCT (& mca_osc_pt2pt_component .pending_receives );
277+ OBJ_DESTRUCT (& mca_osc_pt2pt_component .pending_receives_lock );
256278
257279 return OMPI_SUCCESS ;
258280}
@@ -385,11 +407,6 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
385407 /* sync memory - make sure all initialization completed */
386408 opal_atomic_mb ();
387409
388- module -> incoming_buffer = malloc (mca_osc_pt2pt_component .buffer_size + sizeof (ompi_osc_pt2pt_frag_header_t ));
389- if (OPAL_UNLIKELY (NULL == module -> incoming_buffer )) {
390- goto cleanup ;
391- }
392-
393410 ret = ompi_osc_pt2pt_frag_start_receive (module );
394411 if (OPAL_UNLIKELY (OMPI_SUCCESS != ret )) {
395412 goto cleanup ;
@@ -449,13 +466,33 @@ ompi_osc_pt2pt_get_info(struct ompi_win_t *win, struct ompi_info_t **info_used)
449466
450467OBJ_CLASS_INSTANCE (ompi_osc_pt2pt_pending_t , opal_list_item_t , NULL , NULL );
451468
469+ static void ompi_osc_pt2pt_receive_construct (ompi_osc_pt2pt_receive_t * recv )
470+ {
471+ recv -> buffer = NULL ;
472+ recv -> pml_request = NULL ;
473+ }
474+
475+ static void ompi_osc_pt2pt_receive_destruct (ompi_osc_pt2pt_receive_t * recv )
476+ {
477+ free (recv -> buffer );
478+ if (recv -> pml_request && MPI_REQUEST_NULL != recv -> pml_request ) {
479+ recv -> pml_request -> req_complete_cb = NULL ;
480+ ompi_request_cancel (recv -> pml_request );
481+ ompi_request_free (& recv -> pml_request );
482+ }
483+ }
484+
485+ OBJ_CLASS_INSTANCE (ompi_osc_pt2pt_receive_t , opal_list_item_t ,
486+ ompi_osc_pt2pt_receive_construct ,
487+ ompi_osc_pt2pt_receive_destruct );
488+
452489static void ompi_osc_pt2pt_peer_construct (ompi_osc_pt2pt_peer_t * peer )
453490{
454491 OBJ_CONSTRUCT (& peer -> queued_frags , opal_list_t );
455492 OBJ_CONSTRUCT (& peer -> lock , opal_mutex_t );
456493 peer -> active_frag = NULL ;
457494 peer -> passive_incoming_frag_count = 0 ;
458- peer -> unexpected_post = false ;
495+ peer -> flags = 0 ;
459496}
460497
461498static void ompi_osc_pt2pt_peer_destruct (ompi_osc_pt2pt_peer_t * peer )
0 commit comments