[PATCH] [OPENMP] Codegen for 'atomic capture'.

John McCall rjmccall at gmail.com
Wed Apr 22 10:31:33 PDT 2015


In http://reviews.llvm.org/D9049#159824, @ABataev wrote:

> John, according to the standard 'Only the read and write of
>  the location designated by x are performed mutually atomically. Neither the evaluation
>  of expr or expr_list, nor the write to the location designated by v need be atomic with
>  respect to the read or write of the location designated by x.'
>  I think this means, that store to 'v' must be atomic too, but it does not required to be synchronized with read/update of 'x'. So, I think we can use atomic load of 'x' after atomicrmw for 'x' and we can use atomic store of old/new value of 'x' to 'v' after atomic update of 'x'.


I pulled up the standard, and it doesn't make any atomicity guarantees about 'v' at all.  That's what that paragraph is trying to say: that the only atomicity requirement here is that all of the operations on 'x' have to appear as if they were executed atomically.  There's no reason to make the store to 'v' atomic.

The whole point of "atomic capture" is that 'v' gets either the result or the original value of x, atomically as part of the evaluation of the operation; otherwise you wouldn't need a separate form for this.  That means it has to be evaluated as part of the actual operation, not as a separate load.  If atomicrmw doesn't generate that information, you'll have to expand it to a compare-and-swap yourself.


http://reviews.llvm.org/D9049

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list