digitalmars.D - DIP20: Volatile read/write intrinsics
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (10/10) Oct 10 2012 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20
- deadalnix (5/11) Oct 10 2012 We discussed it quite a lot already, but I still think volatile must be
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (8/23) Oct 10 2012 I have no problem with counter-proposals so long as we get the ball
- Adam D. Ruppe (12/14) Oct 10 2012 I barely know anything about this, but couldn't that be done as a
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (18/32) Oct 10 2012 Good observation!
- David Nadlinger (6/15) Oct 10 2012 Function calls are never allowed to be reordered. In D, there
- Chad J (8/14) Oct 10 2012 Since this can affect semantics but might not always be available, is
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (7/25) Oct 10 2012 I suppose a simple D_Volatile version identifier will do, like we have
- Chad J (2/4) Oct 11 2012 Cool.
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (6/12) Oct 11 2012 OK, updated.
- Chad J (6/16) Oct 11 2012 I read this as meaning:
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (6/26) Oct 11 2012 Oops. It should be clearer now.
- Chad J (2/3) Oct 11 2012 It is!
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20 This supersedes DIP17. The primary reason to use intrinsics instead of something built into the language is that the latter is too complex for current (and likely also future) compiler implementations. Destroy! -- Alex Rønne Petersen alex lycus.org http://lycus.org
Oct 10 2012
Le 10/10/2012 20:31, Alex Rønne Petersen a écrit :http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20 This supersedes DIP17. The primary reason to use intrinsics instead of something built into the language is that the latter is too complex for current (and likely also future) compiler implementations. Destroy!We discussed it quite a lot already, but I still think volatile must be a qualifier of the memory, and not of the statement. In other terms, volatile should alter the way memory is read and written, on every access to that memory. Not on a specific statement.
Oct 10 2012
On 10-10-2012 20:45, deadalnix wrote:Le 10/10/2012 20:31, Alex Rønne Petersen a écrit :I have no problem with counter-proposals so long as we get the ball rolling. Can you write up a counter-DIP with your idea so we can get the various approaches clarified and figure out which one is better? -- Alex Rønne Petersen alex lycus.org http://lycus.orghttp://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20 This supersedes DIP17. The primary reason to use intrinsics instead of something built into the language is that the latter is too complex for current (and likely also future) compiler implementations. Destroy!We discussed it quite a lot already, but I still think volatile must be a qualifier of the memory, and not of the statement. In other terms, volatile should alter the way memory is read and written, on every access to that memory. Not on a specific statement.
Oct 10 2012
On Wednesday, 10 October 2012 at 19:09:34 UTC, deadalnix wrote:We discussed it quite a lot already, but I still think volatile must be a qualifier of the memory, and not of the statement.I barely know anything about this, but couldn't that be done as a library type? Something like a smart pointer. This does bring me to a question though. What if you had: void foo() { volatile_read(); } foo(); bar(); foo(); Is the call to foo allowed to be reordered? I imagine it has to mark the whole call chain upwards as internally volatile too.
Oct 10 2012
On 10-10-2012 20:57, Adam D. Ruppe wrote:On Wednesday, 10 October 2012 at 19:09:34 UTC, deadalnix wrote:Good observation! So here's the thing: The compiler is only allowed to reorder calls to functions where it knows the source of the function and can thus figure out what it does. So, for functions that it does not have the source code for, it must *never* reorder, *ever*. This is one reason volatileLoad and volatileWrite should not be pure: They directly affect code that surrounds calls to them. For functions where the compiler does have the source code, it can trivially figure out if reordering is OK, based on whether there are any calls to volatileLoad and volatileStore somewhere down the call graph. It gets even easier to do these checks when inlining is involved (since then the volatileLoad/volatileStore calls are readily visible in context). -- Alex Rønne Petersen alex lycus.org http://lycus.orgWe discussed it quite a lot already, but I still think volatile must be a qualifier of the memory, and not of the statement.I barely know anything about this, but couldn't that be done as a library type? Something like a smart pointer. This does bring me to a question though. What if you had: void foo() { volatile_read(); } foo(); bar(); foo(); Is the call to foo allowed to be reordered? I imagine it has to mark the whole call chain upwards as internally volatile too.
Oct 10 2012
On Wednesday, 10 October 2012 at 19:21:24 UTC, Adam D. Ruppe wrote:This does bring me to a question though. What if you had: void foo() { volatile_read(); } foo(); bar(); foo(); Is the call to foo allowed to be reordered? I imagine it has to mark the whole call chain upwards as internally volatile too.Function calls are never allowed to be reordered. In D, there might be some exceptions regarding strong purity, but the volatile instructions just couldn't/wouldn't be pure. David
Oct 10 2012
On 10/10/2012 02:31 PM, Alex Rønne Petersen wrote:http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20 This supersedes DIP17. The primary reason to use intrinsics instead of something built into the language is that the latter is too complex for current (and likely also future) compiler implementations. Destroy!Since this can affect semantics but might not always be available, is there any chance you could add a feature detection intrinsic for this? Maybe a compile-time "haveVolatileOps" identifier would work. Volatility might be absent if: - The backend target can't forward the volatility guarantees, ex: a D compiler that emits JavaScript code. - The compiler has not implemented volatile operations yet.
Oct 10 2012
On 11-10-2012 07:14, Chad J wrote:On 10/10/2012 02:31 PM, Alex Rønne Petersen wrote:I suppose a simple D_Volatile version identifier will do, like we have D_SIMD for core.simd.__simd. -- Alex Rønne Petersen alex lycus.org http://lycus.orghttp://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP20 This supersedes DIP17. The primary reason to use intrinsics instead of something built into the language is that the latter is too complex for current (and likely also future) compiler implementations. Destroy!Since this can affect semantics but might not always be available, is there any chance you could add a feature detection intrinsic for this? Maybe a compile-time "haveVolatileOps" identifier would work. Volatility might be absent if: - The backend target can't forward the volatility guarantees, ex: a D compiler that emits JavaScript code. - The compiler has not implemented volatile operations yet.
Oct 10 2012
On 10/11/2012 01:40 AM, Alex Rønne Petersen wrote:I suppose a simple D_Volatile version identifier will do, like we have D_SIMD for core.simd.__simd.Cool.
Oct 11 2012
On 11-10-2012 14:42, Chad J wrote:On 10/11/2012 01:40 AM, Alex Rønne Petersen wrote:OK, updated. -- Alex Rønne Petersen alex lycus.org http://lycus.orgI suppose a simple D_Volatile version identifier will do, like we have D_SIMD for core.simd.__simd.Cool.
Oct 11 2012
On 10/11/2012 10:35 AM, Alex Rønne Petersen wrote:On 11-10-2012 14:42, Chad J wrote:I do have a critique for your description:On 10/11/2012 01:40 AM, Alex Rønne Petersen wrote:OK, updated.I suppose a simple D_Volatile version identifier will do, like we have D_SIMD for core.simd.__simd.Cool.Compilers that support these intrinsics must define the D_Volatile version identifier. Compilers that do not may support them, but programmers should not rely on it.I read this as meaning: Compilers that support volatile intrinsics must define D_Volatile. Compilers can support volatile intrinsics without defining D_Volatile. And I see a contradiction ;)
Oct 11 2012
On 12-10-2012 04:05, Chad J wrote:On 10/11/2012 10:35 AM, Alex Rønne Petersen wrote:Oops. It should be clearer now. -- Alex Rønne Petersen alex lycus.org http://lycus.orgOn 11-10-2012 14:42, Chad J wrote:I do have a critique for your description:On 10/11/2012 01:40 AM, Alex Rønne Petersen wrote:OK, updated.I suppose a simple D_Volatile version identifier will do, like we have D_SIMD for core.simd.__simd.Cool.Compilers that support these intrinsics must define the D_Volatile version identifier. Compilers that do not may support them, but programmers should not rely on it.I read this as meaning: Compilers that support volatile intrinsics must define D_Volatile. Compilers can support volatile intrinsics without defining D_Volatile. And I see a contradiction ;)
Oct 11 2012
On 10/11/2012 10:18 PM, Alex Rønne Petersen wrote:Oops. It should be clearer now.It is!
Oct 11 2012