[cpp-threads] Slightly revised memory model proposal (D2300)

Raul Silvera rauls at ca.ibm.com
Wed Jun 6 15:08:15 BST 2007


Hans, I mentioned this privately, but I wanted to make sure it is voiced on
the list as well.

I think it is a mistake to disallow Peter Dimov's example (for reference):

Thread 1                      Thread 2                            Thread 3
x=1                           y=1                                 if
(load_acquire(&v)==2)
fetch_add_release(&v,1)             fetch_add_release(&v,1)
   assert (x+y==2)

I think this is too counterintuitive and borders on unusable. Also, it
makes fetch_add_release(&v, 0) different from a noop.

Furthermore, I believe it is unnecessary, since PPC (which I assume is the
architecture that is triggering this change) has mechanisms to efficiently
implement this particular situation. Basically, dependence ordering on the
fetch_add_release causes a cheap acquire between the load and store of v.
On other architectures, I suspect the acquire is implied or at least it is
cheap enough that it can always be introduced.

My proposal is to single out RMW operations and indicate they must at least
have a local order between their load and store, which is I believe all
that is needed for this example to fit the model. Note that this doesn't
require a change to the memory model, but to the definition of the RMW
operations.

--
Raúl E. Silvera         IBM Toronto Lab   Team Lead, Toronto Portable
Optimizer (TPO)
Tel: 905-413-4188 T/L: 969-4188           Fax: 905-413-4854
D2/KC9/8200/MKM



                                                                           
             "Boehm, Hans"                                                 
             <hans.boehm at hp.co                                             
             m>                                                         To 
             Sent by:                  <paulmck at linux.vnet.ibm.com>,       
             cpp-threads-bounc         <cpp-threads at decadentplace.org.uk>  
             es at decadentplace.                                          cc 
             org.uk                                                        
                                                                   Subject 
                                       [cpp-threads] Slightly revised      
             06/04/07 07:43 PM         memory model proposal (D2300)       
                                                                           
                                                                           
             Please respond to                                             
                C++ threads                                                
              standardisation                                              
             <cpp-threads at deca                                             
             dentplace.org.uk>                                             
                                                                           
                                                                           




Attached is an early draft of a document with just the threads changes
from N2171, adjusted a little as a result of feedback from Paul and
others.

Note that the "D" in D2300 indicates that this is not stable, and
multiple versions of this document will share the same number.
Hopefully I will remember to update the date.  This will eventually turn
into N2300.

Hans
(See attached file: D2300.html)--
cpp-threads mailing list
cpp-threads at decadentplace.org.uk
http://www.decadentplace.org.uk/cgi-bin/mailman/listinfo/cpp-threads
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.decadentplace.org.uk/pipermail/cpp-threads/attachments/20070606/ea87e5b2/D2300-0001.html


More information about the cpp-threads mailing list