diff options
author | torvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-20 20:56:56 +0000 |
---|---|---|
committer | torvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-20 20:56:56 +0000 |
commit | 62e1cffcdd1dd7356a2c90ed62d36ef493f96c7b (patch) | |
tree | eecdab57a37716f23f733bcc7296e45e68124beb /libitm | |
parent | dd6f37d576b7d571475b79da9c1e2098ffae1279 (diff) | |
download | gcc-62e1cffcdd1dd7356a2c90ed62d36ef493f96c7b.tar.gz |
libitm: Optimize memory order requiremens in gl_wt pre_write.
libtim/
* method-gl.cc (gl_wt_dispatch::pre_write): Optimize memory orders.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184400 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libitm')
-rw-r--r-- | libitm/ChangeLog | 4 | ||||
-rw-r--r-- | libitm/method-gl.cc | 17 |
2 files changed, 18 insertions, 3 deletions
diff --git a/libitm/ChangeLog b/libitm/ChangeLog index 75410f52ed1..0a06bfec7f4 100644 --- a/libitm/ChangeLog +++ b/libitm/ChangeLog @@ -1,5 +1,9 @@ 2012-02-20 Torvald Riegel <triegel@redhat.com> + * method-gl.cc (gl_wt_dispatch::pre_write): Optimize memory orders. + +2012-02-20 Torvald Riegel <triegel@redhat.com> + * method-gl.cc (gl_wt_dispatch::memtransfer_static): Add missing undo for RfW src. Optimize number of calls to gtm_thr. diff --git a/libitm/method-gl.cc b/libitm/method-gl.cc index 4a18b62d740..503c19e5921 100644 --- a/libitm/method-gl.cc +++ b/libitm/method-gl.cc @@ -104,16 +104,27 @@ protected: tx->restart(RESTART_VALIDATE_WRITE); // CAS global orec from our snapshot time to the locked state. - // We need acq_rel memory order here to synchronize with other loads - // and modifications of orec. + // We need acquire memory order here to synchronize with other + // (ownership) releases of the orec. We do not need acq_rel order + // because whenever another thread reads from this CAS' + // modification, then it will abort anyway and does not rely on + // any further happens-before relation to be established. + // Also note that unlike in ml_wt's increase of the global time + // base (remember that the global orec is used as time base), we do + // not need require memory order here because we do not need to make + // prior orec acquisitions visible to other threads that try to + // extend their snapshot time. if (!o_gl_mg.orec.compare_exchange_strong (now, gl_mg::set_locked(now), - memory_order_acq_rel)) + memory_order_acquire)) tx->restart(RESTART_LOCKED_WRITE); // We use an explicit fence here to avoid having to use release // memory order for all subsequent data stores. This fence will // synchronize with loads of the data with acquire memory order. See // validate() for why this is necessary. + // Adding require memory order to the prior CAS is not sufficient, + // at least according to the Batty et al. formalization of the + // memory model. atomic_thread_fence(memory_order_release); // Set shared_state to new value. |