1
1

Move duplicated code all over the code to a single function ompi_request_wait_completion().

This commit was SVN r16494.
Этот коммит содержится в:
Gleb Natapov 2007-10-18 12:33:21 +00:00
родитель 807f49ed7f
Коммит e0a3a7e53e
11 изменённых файлов: 29 добавлений и 207 удалений

Просмотреть файл

@ -3857,13 +3857,7 @@ static int coord_request_wait_all( size_t count,
static int coord_request_wait( ompi_request_t * req,
ompi_status_public_t * status)
{
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);
ompi_request_wait_completion(req);
if( MPI_STATUS_IGNORE != status ) {
status->MPI_TAG = req->req_status.MPI_TAG;

Просмотреть файл

@ -112,22 +112,7 @@ mca_pml_cm_recv(void *addr,
return ret;
}
if (recvreq->req_base.req_ompi.req_complete == false) {
/* 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--;
}
}
ompi_request_wait_completion(&recvreq->req_base.req_ompi);
if (NULL != status) { /* return status */
*status = recvreq->req_base.req_ompi.req_status;

Просмотреть файл

@ -175,23 +175,8 @@ mca_pml_cm_send(void *buf,
MCA_PML_CM_THIN_SEND_REQUEST_RETURN(sendreq);
return ret;
}
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
/* 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_wait_completion(&sendreq->req_send.req_base.req_ompi);
ompi_request_free( (ompi_request_t**)&sendreq );
} 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_START(&recvreq);
if (recvreq.req_recv.req_base.req_ompi.req_complete == false) {
/* 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--;
}
}
ompi_request_wait_completion(&recvreq.req_recv.req_base.req_ompi);
if (NULL != 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 );
return OMPI_SUCCESS;
}

Просмотреть файл

@ -87,33 +87,8 @@ int mca_pml_dr_recv(void *addr,
count, datatype, src, tag, comm, false);
MCA_PML_DR_RECV_REQUEST_START(recvreq);
if (recvreq->req_recv.req_base.req_ompi.req_complete == false) {
#if OMPI_ENABLE_PROGRESS_THREADS
if(opal_progress_spin(&recvreq->req_recv.req_base.req_ompi.req_complete)) {
goto finished;
}
#endif
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 OMPI_ENABLE_PROGRESS_THREADS
finished:
#endif
if (NULL != status) { /* return status */
*status = recvreq->req_recv.req_base.req_ompi.req_status;
}

Просмотреть файл

@ -105,33 +105,10 @@ int mca_pml_dr_send(void *buf,
return rc;
}
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
#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--;
}
}
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
/* return request to pool */
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
ompi_request_free((ompi_request_t **) & sendreq);
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_START(&recvreq);
if (recvreq.req_recv.req_base.req_ompi.req_complete == false) {
/* 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--;
}
}
ompi_request_wait_completion(&recvreq.req_recv.req_base.req_ompi);
if (NULL != 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 );
return OMPI_SUCCESS;
}

Просмотреть файл

@ -101,37 +101,7 @@ int mca_pml_ob1_recv(void *addr,
PERUSE_RECV);
MCA_PML_OB1_RECV_REQUEST_START(recvreq);
if (recvreq->req_recv.req_base.req_ompi.req_complete == false) {
#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
ompi_request_wait_completion(&recvreq->req_recv.req_base.req_ompi);
if (NULL != status) { /* return status */
*status = recvreq->req_recv.req_base.req_ompi.req_status;

Просмотреть файл

@ -120,38 +120,9 @@ int mca_pml_ob1_send(void *buf,
return rc;
}
if (sendreq->req_send.req_base.req_ompi.req_complete == false) {
#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
}
}
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
ompi_request_free( (ompi_request_t**)&sendreq );
return rc;
}

Просмотреть файл

@ -31,27 +31,7 @@ int ompi_request_wait(
{
ompi_request_t *req = *req_ptr;
if(req->req_complete == false) {
#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
ompi_request_wait_completion(req);
#if OPAL_ENABLE_FT == 1
OMPI_CRCP_REQUEST_COMPLETE(req);

Просмотреть файл

@ -374,7 +374,24 @@ OMPI_DECLSPEC int ompi_request_wait_some(
int * indices,
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
#endif