1
1

ompi_request_complete with signal

Rewrite the ompi_request_complete function to take in account the
with_signal argument. Change the comment to explain the expected
behavior.
Alter all the ompi_request_complete uses to make sure the status of the
request is set before calling ompi_request_complete.

bot🏷️enhancement
Этот коммит содержится в:
George Bosilca 2016-06-02 11:49:12 +09:00
родитель 223d75595d
Коммит 50cec456fb
4 изменённых файлов: 27 добавлений и 20 удалений

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University * Copyright (c) 2004-2016 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -233,9 +233,9 @@ int ompio_io_ompio_file_iread (mca_io_ompio_file_t *fh,
ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE; ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE;
if ( 0 == count ) { if ( 0 == count ) {
ompi_request_complete (&ompio_req->req_ompi, 0);
ompio_req->req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS; ompio_req->req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;
ompio_req->req_ompi.req_status._ucount = 0; ompio_req->req_ompi.req_status._ucount = 0;
ompi_request_complete (&ompio_req->req_ompi, false);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -299,9 +299,9 @@ int ompio_io_ompio_file_iread (mca_io_ompio_file_t *fh,
ompi_status_public_t status; ompi_status_public_t status;
ret = ompio_io_ompio_file_read (fh, buf, count, datatype, &status); ret = ompio_io_ompio_file_read (fh, buf, count, datatype, &status);
ompi_request_complete (&ompio_req->req_ompi, 0);
ompio_req->req_ompi.req_status.MPI_ERROR = ret; ompio_req->req_ompi.req_status.MPI_ERROR = ret;
ompio_req->req_ompi.req_status._ucount = status._ucount; ompio_req->req_ompi.req_status._ucount = status._ucount;
ompi_request_complete (&ompio_req->req_ompi, false);
} }
*request = (ompi_request_t *) ompio_req; *request = (ompi_request_t *) ompio_req;

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University * Copyright (c) 2004-2016 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -225,9 +225,9 @@ int ompio_io_ompio_file_iwrite (mca_io_ompio_file_t *fh,
ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE; ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE;
if ( 0 == count ) { if ( 0 == count ) {
ompi_request_complete (&ompio_req->req_ompi, 0);
ompio_req->req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS; ompio_req->req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;
ompio_req->req_ompi.req_status._ucount = 0; ompio_req->req_ompi.req_status._ucount = 0;
ompi_request_complete (&ompio_req->req_ompi, false);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -288,9 +288,9 @@ int ompio_io_ompio_file_iwrite (mca_io_ompio_file_t *fh,
ompi_status_public_t status; ompi_status_public_t status;
ret = ompio_io_ompio_file_write(fh,buf,count,datatype, &status); ret = ompio_io_ompio_file_write(fh,buf,count,datatype, &status);
ompi_request_complete (&ompio_req->req_ompi, 0);
ompio_req->req_ompi.req_status.MPI_ERROR = ret; ompio_req->req_ompi.req_status.MPI_ERROR = ret;
ompio_req->req_ompi.req_status._ucount = status._ucount; ompio_req->req_ompi.req_status._ucount = status._ucount;
ompi_request_complete (&ompio_req->req_ompi, false);
} }
*request = (ompi_request_t *) ompio_req; *request = (ompi_request_t *) ompio_req;

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

@ -85,7 +85,7 @@ int mca_io_ompio_component_progress ( void )
if ( NULL != req->req_progress_fn ) { if ( NULL != req->req_progress_fn ) {
if ( req->req_progress_fn(req) ) { if ( req->req_progress_fn(req) ) {
completed++; completed++;
ompi_request_complete (&req->req_ompi, 1); ompi_request_complete (&req->req_ompi, true);
/* The fbtl progress function is expected to set the /* The fbtl progress function is expected to set the
* status elements * status elements
*/ */

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

@ -398,12 +398,16 @@ static inline void ompi_request_wait_completion(ompi_request_t *req)
#endif #endif
/** /**
* Signal or mark a request as complete. If with_signal is true this will * Signal or mark a request as complete. If with_signal is true this will
* wake any thread pending on the request and ompi_request_lock should be * wake any thread pending on the request. If with_signal is false, the
* held while calling this function. If with_signal is false, there will * opposite will be true, the request will simply be marked as completed
* signal generated, and no lock required. This is a special case when * and no effort will be made to correctly (atomically) handle the associated
* the function is called from the critical path for small messages, where * synchronization primitive. This is a special case when the function
* we know the current execution flow created the request, and is still * is called from the critical path for small messages, where we know
* in the _START macro. * the current execution flow created the request, and no synchronized wait
* has been set.
* BEWARE: The error code should be set on the request prior to calling
* this function, or the synchronization primitive might not be correctly
* triggered.
*/ */
static inline int ompi_request_complete(ompi_request_t* request, bool with_signal) static inline int ompi_request_complete(ompi_request_t* request, bool with_signal)
{ {
@ -412,13 +416,16 @@ static inline int ompi_request_complete(ompi_request_t* request, bool with_signa
request->req_complete_cb = NULL; request->req_complete_cb = NULL;
} }
if(!OPAL_ATOMIC_CMPSET_PTR(&request->req_complete, REQUEST_PENDING, REQUEST_COMPLETED)) { if( OPAL_LIKELY(with_signal) ) {
ompi_wait_sync_t *tmp_sync = (ompi_wait_sync_t *) OPAL_ATOMIC_SWP_PTR(&request->req_complete, if(!OPAL_ATOMIC_CMPSET_PTR(&request->req_complete, REQUEST_PENDING, REQUEST_COMPLETED)) {
REQUEST_COMPLETED); ompi_wait_sync_t *tmp_sync = (ompi_wait_sync_t *) OPAL_ATOMIC_SWP_PTR(&request->req_complete,
/* In the case where another thread concurrently changed the request to REQUEST_PENDING */ REQUEST_COMPLETED);
if( REQUEST_PENDING != tmp_sync ) /* In the case where another thread concurrently changed the request to REQUEST_PENDING */
wait_sync_update(tmp_sync, 1, request->req_status.MPI_ERROR); if( REQUEST_PENDING != tmp_sync )
} wait_sync_update(tmp_sync, 1, request->req_status.MPI_ERROR);
}
} else
request->req_complete = REQUEST_COMPLETED;
if( OPAL_UNLIKELY(MPI_SUCCESS != request->req_status.MPI_ERROR) ) { if( OPAL_UNLIKELY(MPI_SUCCESS != request->req_status.MPI_ERROR) ) {
ompi_request_failed++; ompi_request_failed++;