Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] MPI_Request_get_status and opal_progress [PATCH]
From: Shaun Jackman (sjackman_at_[hidden])
Date: 2009-09-24 18:32:38


Hi Jeff,

Attached is an updated patch, which moves the loop label before
opal_atomic_mb as is done in req_test.c.

Cheers,
Shaun

Jeff Squyres wrote:
> On Sep 14, 2009, at 5:12 PM, Shaun Jackman wrote:
>
>> Two questions. Should the loop label recheck_request_status come
>> before or after the call to opal_atomic_mb?
>>
>
> I believe that a 2nd mb is necessary. But I think it could be put
> into the "if" block at the end, and leave the label where it is. But
> see below.
>
>> Is it necessary to check
>> request->req_state a second time, or is it only necessary to check
>> request->req_complete the second time?
>>
>
> In THREAD_MULTIPLE, I guess the state could change. But in non-
> THREAD_MULTIPLE, it's superfluous to check a 2nd time because a
> request can't have changed into INACTIVE simply due to a call to
> opal_progress(). I notice that req_test.c checks the whole enchilada
> again (including the mb and state change). Since we're currently not
> distinguishing between THREAD_MULTIPLE and not in these functions, I
> think we need to be conservative and check the state again.
>
> I think this means that our TEST/WAIT functions are not well-tuned for
> threading (or, at least, there are optimizations that could be made
> based on the thread level).
>
> George / Brian -- got opinions here?
>

2009-09-14 Shaun Jackman <sjackman_at_[hidden]>

        * ompi/mpi/c/request_get_status.c (MPI_Request_get_status):
        If opal_progress is called then check the status of the request
        before returning. opal_progress is called only once. This logic
        parallels MPI_Test (ompi_request_default_test).

--- ompi/mpi/c/request_get_status.c.orig 2008-11-04 12:56:27.000000000 -0800
+++ ompi/mpi/c/request_get_status.c 2009-09-24 15:30:09.995850000 -0700
@@ -41,6 +41,10 @@
 int MPI_Request_get_status(MPI_Request request, int *flag,
                            MPI_Status *status)
 {
+#if OMPI_ENABLE_PROGRESS_THREADS == 0
+ int do_it_once = 0;
+#endif
+
     MEMCHECKER(
         memchecker_request(&request);
     );
@@ -57,6 +61,9 @@
         }
     }
 
+#if OMPI_ENABLE_PROGRESS_THREADS == 0
+ recheck_request_status:
+#endif
     opal_atomic_mb();
     if( (request == MPI_REQUEST_NULL) || (request->req_state == OMPI_REQUEST_INACTIVE) ) {
         *flag = true;
@@ -78,9 +85,17 @@
         }
         return MPI_SUCCESS;
     }
- *flag = false;
 #if OMPI_ENABLE_PROGRESS_THREADS == 0
- opal_progress();
+ if( 0 == do_it_once ) {
+ /**
+ * If we run the opal_progress then check the status of the request before
+ * leaving. We will call the opal_progress only once per call.
+ */
+ opal_progress();
+ do_it_once++;
+ goto recheck_request_status;
+ }
 #endif
+ *flag = false;
     return MPI_SUCCESS;
 }