Move duplicated code all over the code to a single function ompi_request_wait_completion().
This commit was SVN r16494.
Этот коммит содержится в:
родитель
807f49ed7f
Коммит
e0a3a7e53e
@ -3857,13 +3857,7 @@ static int coord_request_wait_all( size_t count,
|
|||||||
static int coord_request_wait( ompi_request_t * req,
|
static int coord_request_wait( ompi_request_t * req,
|
||||||
ompi_status_public_t * status)
|
ompi_status_public_t * status)
|
||||||
{
|
{
|
||||||
OPAL_THREAD_LOCK(&ompi_request_lock);
|
ompi_request_wait_completion(req);
|
||||||
ompi_request_waiting++;
|
|
||||||
while (req->req_complete == false) {
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
}
|
|
||||||
ompi_request_waiting--;
|
|
||||||
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
||||||
|
|
||||||
if( MPI_STATUS_IGNORE != status ) {
|
if( MPI_STATUS_IGNORE != status ) {
|
||||||
status->MPI_TAG = req->req_status.MPI_TAG;
|
status->MPI_TAG = req->req_status.MPI_TAG;
|
||||||
|
@ -112,22 +112,7 @@ mca_pml_cm_recv(void *addr,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recvreq->req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&recvreq->req_base.req_ompi);
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != status) { /* return status */
|
if (NULL != status) { /* return status */
|
||||||
*status = recvreq->req_base.req_ompi.req_status;
|
*status = recvreq->req_base.req_ompi.req_status;
|
||||||
|
@ -176,22 +176,7 @@ mca_pml_cm_send(void *buf,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ompi_request_free( (ompi_request_t**)&sendreq );
|
ompi_request_free( (ompi_request_t**)&sendreq );
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,22 +64,7 @@ int mca_pml_dr_probe(int src,
|
|||||||
MCA_PML_DR_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char, src, tag, comm, true);
|
MCA_PML_DR_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char, src, tag, comm, true);
|
||||||
MCA_PML_DR_RECV_REQUEST_START(&recvreq);
|
MCA_PML_DR_RECV_REQUEST_START(&recvreq);
|
||||||
|
|
||||||
if (recvreq.req_recv.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&recvreq.req_recv.req_base.req_ompi);
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq.req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq.req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != status) {
|
if (NULL != status) {
|
||||||
*status = recvreq.req_recv.req_base.req_ompi.req_status;
|
*status = recvreq.req_recv.req_base.req_ompi.req_status;
|
||||||
@ -87,4 +72,3 @@ int mca_pml_dr_probe(int src,
|
|||||||
MCA_PML_BASE_RECV_REQUEST_FINI( &recvreq.req_recv );
|
MCA_PML_BASE_RECV_REQUEST_FINI( &recvreq.req_recv );
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,32 +87,7 @@ int mca_pml_dr_recv(void *addr,
|
|||||||
count, datatype, src, tag, comm, false);
|
count, datatype, src, tag, comm, false);
|
||||||
|
|
||||||
MCA_PML_DR_RECV_REQUEST_START(recvreq);
|
MCA_PML_DR_RECV_REQUEST_START(recvreq);
|
||||||
if (recvreq->req_recv.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&recvreq->req_recv.req_base.req_ompi);
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
if(opal_progress_spin(&recvreq->req_recv.req_base.req_ompi.req_complete)) {
|
|
||||||
goto finished;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
finished:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (NULL != status) { /* return status */
|
if (NULL != status) { /* return status */
|
||||||
*status = recvreq->req_recv.req_base.req_ompi.req_status;
|
*status = recvreq->req_recv.req_base.req_ompi.req_status;
|
||||||
|
@ -105,33 +105,10 @@ int mca_pml_dr_send(void *buf,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
if(opal_progress_spin(&sendreq->req_send.req_base.req_ompi.req_complete)) {
|
|
||||||
ompi_request_free( (ompi_request_t**)&sendreq );
|
|
||||||
return OMPI_SUCCESS;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return request to pool */
|
/* return request to pool */
|
||||||
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
|
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
|
||||||
ompi_request_free((ompi_request_t **) & sendreq);
|
ompi_request_free((ompi_request_t **) & sendreq);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,22 +64,7 @@ int mca_pml_ob1_probe(int src,
|
|||||||
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char, src, tag, comm, true);
|
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char, src, tag, comm, true);
|
||||||
MCA_PML_OB1_RECV_REQUEST_START(&recvreq);
|
MCA_PML_OB1_RECV_REQUEST_START(&recvreq);
|
||||||
|
|
||||||
if (recvreq.req_recv.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&recvreq.req_recv.req_base.req_ompi);
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq.req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq.req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != status) {
|
if (NULL != status) {
|
||||||
*status = recvreq.req_recv.req_base.req_ompi.req_status;
|
*status = recvreq.req_recv.req_base.req_ompi.req_status;
|
||||||
@ -87,4 +72,3 @@ int mca_pml_ob1_probe(int src,
|
|||||||
MCA_PML_BASE_RECV_REQUEST_FINI( &recvreq.req_recv );
|
MCA_PML_BASE_RECV_REQUEST_FINI( &recvreq.req_recv );
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,37 +101,7 @@ int mca_pml_ob1_recv(void *addr,
|
|||||||
PERUSE_RECV);
|
PERUSE_RECV);
|
||||||
|
|
||||||
MCA_PML_OB1_RECV_REQUEST_START(recvreq);
|
MCA_PML_OB1_RECV_REQUEST_START(recvreq);
|
||||||
if (recvreq->req_recv.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&recvreq->req_recv.req_base.req_ompi);
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
if(opal_progress_spin(&recvreq->req_recv.req_base.req_ompi.req_complete)) {
|
|
||||||
goto finished;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
#if OMPI_ENABLE_DEBUG && !OMPI_HAVE_THREAD_SUPPORT
|
|
||||||
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
||||||
#endif
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (recvreq->req_recv.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
#if OMPI_ENABLE_DEBUG && !OMPI_HAVE_THREAD_SUPPORT
|
|
||||||
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
finished:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (NULL != status) { /* return status */
|
if (NULL != status) { /* return status */
|
||||||
*status = recvreq->req_recv.req_base.req_ompi.req_status;
|
*status = recvreq->req_recv.req_base.req_ompi.req_status;
|
||||||
|
@ -120,38 +120,9 @@ int mca_pml_ob1_send(void *buf,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
|
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
if(opal_progress_spin(&sendreq->req_send.req_base.req_ompi.req_complete)) {
|
|
||||||
ompi_request_free( (ompi_request_t**)&sendreq );
|
|
||||||
return OMPI_SUCCESS;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* give up and sleep until completion */
|
|
||||||
if (opal_using_threads()) {
|
|
||||||
opal_mutex_lock(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
opal_mutex_unlock(&ompi_request_lock);
|
|
||||||
} else {
|
|
||||||
#if OMPI_ENABLE_DEBUG && !OMPI_HAVE_THREAD_SUPPORT
|
|
||||||
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
||||||
#endif
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (sendreq->req_send.req_base.req_ompi.req_complete == false)
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
ompi_request_waiting--;
|
|
||||||
#if OMPI_ENABLE_DEBUG && !OMPI_HAVE_THREAD_SUPPORT
|
|
||||||
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
|
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
|
||||||
ompi_request_free( (ompi_request_t**)&sendreq );
|
ompi_request_free( (ompi_request_t**)&sendreq );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,27 +31,7 @@ int ompi_request_wait(
|
|||||||
{
|
{
|
||||||
ompi_request_t *req = *req_ptr;
|
ompi_request_t *req = *req_ptr;
|
||||||
|
|
||||||
if(req->req_complete == false) {
|
ompi_request_wait_completion(req);
|
||||||
|
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
/* poll for completion */
|
|
||||||
if(opal_progress_spin(&req->req_complete))
|
|
||||||
goto finished;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* give up and sleep until completion */
|
|
||||||
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
||||||
ompi_request_waiting++;
|
|
||||||
while (req->req_complete == false) {
|
|
||||||
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
||||||
}
|
|
||||||
ompi_request_waiting--;
|
|
||||||
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
||||||
finished:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if OPAL_ENABLE_FT == 1
|
#if OPAL_ENABLE_FT == 1
|
||||||
OMPI_CRCP_REQUEST_COMPLETE(req);
|
OMPI_CRCP_REQUEST_COMPLETE(req);
|
||||||
|
@ -374,7 +374,24 @@ OMPI_DECLSPEC int ompi_request_wait_some(
|
|||||||
int * indices,
|
int * indices,
|
||||||
ompi_status_public_t * statuses);
|
ompi_status_public_t * statuses);
|
||||||
|
|
||||||
|
static inline void ompi_request_wait_completion(ompi_request_t *req)
|
||||||
|
{
|
||||||
|
if(false == req->req_complete) {
|
||||||
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
||||||
|
if(opal_progress_spin(&req->req_complete)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
||||||
|
ompi_request_waiting++;
|
||||||
|
while(false == req->req_complete) {
|
||||||
|
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
||||||
|
}
|
||||||
|
ompi_request_waiting--;
|
||||||
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user