Change to the new atomic operations.
This commit was SVN r3388.
Этот коммит содержится в:
родитель
fdaaae5998
Коммит
8c0d5522b1
@ -407,34 +407,22 @@ static inline int ompi_obj_update(ompi_object_t *object, int inc)
|
|||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
int newval;
|
|
||||||
LONG volatile *addr;
|
LONG volatile *addr;
|
||||||
|
|
||||||
addr = (LONG volatile *) &(object->obj_reference_count);
|
addr = (LONG volatile *) &(object->obj_reference_count);
|
||||||
newval = (int) InterlockedExchangeAdd(addr, (LONG) inc) + inc;
|
(void)InterlockedExchangeAdd(addr, (LONG) inc) + inc;
|
||||||
|
|
||||||
#elif OMPI_HAVE_ATOMIC
|
#elif OMPI_HAVE_ATOMIC
|
||||||
|
|
||||||
int newval;
|
ompi_atomic_add(&(object->obj_reference_count), 1 );
|
||||||
int oldval;
|
|
||||||
volatile int *addr;
|
|
||||||
|
|
||||||
addr = (volatile int *) &(object->obj_reference_count);
|
|
||||||
do {
|
|
||||||
oldval = *addr;
|
|
||||||
newval = oldval + inc;
|
|
||||||
} while (ompi_atomic_cmpset_int(addr, oldval, newval) == 0);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int newval;
|
|
||||||
|
|
||||||
object->obj_reference_count += inc;
|
object->obj_reference_count += inc;
|
||||||
newval = object->obj_reference_count;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return newval;
|
return object->obj_reference_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
@ -128,16 +128,13 @@ static inline bool mca_pml_base_send_request_matched(
|
|||||||
*
|
*
|
||||||
* @param request (IN) Send request.
|
* @param request (IN) Send request.
|
||||||
* @param offset (IN) Increment.
|
* @param offset (IN) Increment.
|
||||||
* return TRUE if an ack/match has been received from peer.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void mca_pml_base_send_request_offset(
|
static inline void mca_pml_base_send_request_offset(
|
||||||
mca_pml_base_send_request_t* request,
|
mca_pml_base_send_request_t* request,
|
||||||
size_t offset)
|
size_t offset)
|
||||||
{
|
{
|
||||||
OMPI_THREAD_LOCK(&ompi_request_lock);
|
ompi_atomic_add( &(request->req_offset), offset );
|
||||||
request->req_offset += offset;
|
|
||||||
OMPI_THREAD_UNLOCK(&ompi_request_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(c_plusplus) || defined(__cplusplus)
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
|
@ -119,7 +119,7 @@ static inline void mca_ptl_tcp_recv_frag_progress(mca_ptl_tcp_recv_frag_t* frag)
|
|||||||
|
|
||||||
if((frag)->frag_msg_cnt >= frag->frag_recv.frag_base.frag_header.hdr_frag.hdr_frag_length) {
|
if((frag)->frag_msg_cnt >= frag->frag_recv.frag_base.frag_header.hdr_frag.hdr_frag_length) {
|
||||||
/* make sure this only happens once for threaded case */
|
/* make sure this only happens once for threaded case */
|
||||||
if(ompi_atomic_fetch_and_set_int(&frag->frag_progressed, 1) == 0) {
|
if(ompi_atomic_cmpset(&frag->frag_progressed, 0, 1) == 1) {
|
||||||
mca_pml_base_recv_request_t* request = frag->frag_recv.frag_request;
|
mca_pml_base_recv_request_t* request = frag->frag_recv.frag_request;
|
||||||
if(frag->frag_recv.frag_is_buffered) {
|
if(frag->frag_recv.frag_is_buffered) {
|
||||||
mca_ptl_base_match_header_t* header = &(frag)->frag_recv.frag_base.frag_header.hdr_match;
|
mca_ptl_base_match_header_t* header = &(frag)->frag_recv.frag_base.frag_header.hdr_match;
|
||||||
|
@ -94,7 +94,7 @@ static inline void mca_ptl_tcp_send_frag_progress(mca_ptl_tcp_send_frag_t* frag)
|
|||||||
mca_pml_base_send_request_matched(request))) {
|
mca_pml_base_send_request_matched(request))) {
|
||||||
|
|
||||||
/* make sure this only happens once in threaded case */
|
/* make sure this only happens once in threaded case */
|
||||||
if(ompi_atomic_fetch_and_set_int(&frag->frag_progressed,1) == 0) {
|
if(ompi_atomic_cmpset(&frag->frag_progressed, 0, 1) == 1) {
|
||||||
|
|
||||||
/* update request status */
|
/* update request status */
|
||||||
frag->frag_send.frag_base.frag_owner->ptl_send_progress(
|
frag->frag_send.frag_base.frag_owner->ptl_send_progress(
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user