[mpich] MPICH primary repository branch, master, updated. v3.1.3-1-g7a36603
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "MPICH primary repository". The branch, master has been updated via 7a36603163cd917fe89a39cad668e5a7b6f917cb (commit) from 835ab3bc2d051a44dc75aadd6ac1f9ace9b43c61 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://git.mpich.org/mpich.git/commitdiff/7a36603163cd917fe89a39cad668e5a7b6... commit 7a36603163cd917fe89a39cad668e5a7b6f917cb Author: Joe Ratterman <[email protected]> Date: Mon May 2 13:00:29 2011 -0500 When decrementing a ref-count to 0, do not bother with atomics. If the ref-count is 1, we *should* be the only thread holding a reference. It is therefore legal to skip atomics. If that is insufficient justificaion, consider that there are only three things a concurrent thread should be doing: 1) Reading: Not a problem, since the store is atomic. 2) Decrementing: Illegal; it would go negative using pure atomics. 3) Incrementing: Illegal; we are about to destroy the object. Add #ifdef guard for use of 'aggressive counter optimizations' (ibm) 20a558c3802fb3e138eb6b3c786a434538efffdd Signed-off-by: Joe Ratterman <[email protected]> Signed-off-by: Michael Blocksome <[email protected]> Updated by Pavan Balaji to use an OPA atomic load instead of a simple load operation. Fixes #1835 Signed-off-by: Pavan Balaji <[email protected]> Signed-off-by: William Gropp <[email protected]> diff --git a/src/include/mpihandlemem.h b/src/include/mpihandlemem.h index 1847031..1ab6752 100644 --- a/src/include/mpihandlemem.h +++ b/src/include/mpihandlemem.h @@ -300,10 +300,25 @@ typedef OPA_int_t MPIU_Handle_ref_count; MPIU_HANDLE_LOG_REFCOUNT_CHANGE(objptr_, "incr"); \ MPIU_HANDLE_CHECK_REFCOUNT(objptr_,"incr"); \ } while (0) + +/* Special optimization: when the reference count touches one, we are + * about to free the object. In this case, it is illegal for another + * thread to either increment the reference (i.e., create a new object + * that depends on this object) or decrement the references (i.e., + * free the object simultaneously). We, however, have to ensure that + * our load is atomic. OPA does this for us, while optimizing it to a + * simple load for cases where the architecture already provides us + * with load atomicity and no need for load memory barriers. */ #define MPIU_Object_release_ref_always(objptr_,inuse_ptr) \ do { \ - int got_zero_ = OPA_decr_and_test_int(&((objptr_)->ref_count)); \ - *(inuse_ptr) = got_zero_ ? 0 : 1; \ + if (likely(OPA_load_int((objptr_)->ref_count.v) == 1)) { \ + (objptr_)->ref_count.v = 0; \ + *(inuse_ptr) = 0; \ + } \ + else { \ + int got_zero_ = OPA_decr_and_test_int(&((objptr_)->ref_count)); \ + *(inuse_ptr) = got_zero_ ? 0 : 1; \ + } \ MPIU_HANDLE_LOG_REFCOUNT_CHANGE(objptr_, "decr"); \ MPIU_HANDLE_CHECK_REFCOUNT(objptr_,"decr"); \ } while (0) ----------------------------------------------------------------------- Summary of changes: src/include/mpihandlemem.h | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) hooks/post-receive -- MPICH primary repository
participants (1)
-
noreply@mpich.org