Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define accesses to UPC shared bit fields as atomic with respect to accesses to adjacent fields. #35

Open
GoogleCodeExporter opened this issue Jul 2, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

This issue is responsive to item 52 on the open issues list.

52. For bit-fields of shared struct types, are there any guarantees regarding 
what  happens if two threads each write two different bit-fields within the 
same struct?  At least two implementations implement shared bit-field writes by 
fetching the entire struct (or at least a word), modifying the data, then 
writing it back.  This approach potentially throws away concurrent updates by 
other threads to conceptually distinct bit-fields.

The C99 specification does not define any constraints on the required behavior 
for bit-field accesses.  The GCC documentation offers the following guidance 
when the "volatile" qualifier is applied to bit-field accesses:
http://gcc.gnu.org/onlinedocs/gcc/Volatiles.html
"As bitfields are not individually addressable, volatile bitfields may be 
implicitly read when written to, or when adjacent bitfields are accessed. 
Bitfield operations may be optimized such that adjacent bitfields are only 
partially accessed, if they straddle a storage unit boundary. For these reasons 
it is unwise to use volatile bitfields to access hardware."

In an idealized implementation, accesses to bitfields within a UPC shared 
'struct' or 'union' would be atomic with respect to adjacent bit fields that 
reside within the same containing storage unit.  Although desirable in some 
situations, over-constraining the implementation in this way may impact 
performance when this level of atomicity is not needed.  Yet, if the principal 
of "least surprise" was followed here, atomic bitfield accesses would provide 
the most intuitive and predictable bitfield access behavior.

This proposal recommends that UPC shared bitfield accesses are defined as being 
atomic with respect to accesses to adjacent bitfields within the same 
(implementation-defined) containing storage unit.

Original issue reported on code.google.com by gary.funck on 22 May 2012 at 4:58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant