www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - meaning of 64bit: not only large memory, but large atomic integer

reply redsea <redsea 163.com> writes:
When I implement some high performance program in linux 32bit, 32bit atomic if
often not sufficient, for example, If I want to hold a index & a timestamp to a
atomic variable, 32bit is not enough,  in 64bit environment, I can do that.
Jan 07 2009
next sibling parent reply "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Wed, Jan 7, 2009 at 10:47 AM, redsea <redsea 163.com> wrote:
 When I implement some high performance program in linux 32bit, 32bit atomic if
often not sufficient, for example, If I want to hold a index & a timestamp to a
atomic variable, 32bit is not enough,  in 64bit environment, I can do that.

..Congratulations?
Jan 07 2009
parent redsea <redsea 163.com> writes:
Jarrett Billingsley Wrote:

 On Wed, Jan 7, 2009 at 10:47 AM, redsea <redsea 163.com> wrote:
 When I implement some high performance program in linux 32bit, 32bit atomic if
often not sufficient, for example, If I want to hold a index & a timestamp to a
atomic variable, 32bit is not enough,  in 64bit environment, I can do that.

..Congratulations?

You mean scope & RAII ? Yes, it works, very well, thanks Walter. I test some dstress fail test case too, according to http://www.incasoftware.de/~kamm/ldc/tests/dmd-1.038-dstress1601/fail.html scope_06_M is also fixed, but some case with goto still failed. scope_06_M in run/s/scope_06_M.d ok now scope_13_A in run/s/scope_13_A.d still no ok, but Walter said it is not a bug. scope_14_A in run/s/scope_14_A.d scope_14_B in run/s/scope_14_B.d scope_14_C in run/s/scope_14_C.d scope_14_E in run/s/scope_14_E.d scope_17_A in run/s/scope_17_A.d failed scope_17_C in run/s/scope_17_C.d failed scope_17_D in run/s/scope_17_D.d other ones can not pass compile (so I wouldn't be afraid of them). And 17_A, 17_C is using goto combine scope/RAII, so, if we avoid the use of goto, we could be safe.
Jan 07 2009
prev sibling next sibling parent "Robert Jacques" <sandford jhu.edu> writes:
On Wed, 07 Jan 2009 10:47:03 -0500, redsea <redsea 163.com> wrote:

 When I implement some high performance program in linux 32bit, 32bit  
 atomic if often not sufficient, for example, If I want to hold a index &  
 a timestamp to a atomic variable, 32bit is not enough,  in 64bit  
 environment, I can do that.

and Swap operation is availible, which allows you to use the index + tag method to advoid the ABA problem. However, a decent number of 64-bit systems don't support this operation leaving the vast majority of lock-free algorithms high and dry. (While there are high order bits you could hide a tag in, kernel developers are already using them for OS stuff). Of course, if you're referring to indexing into an array, you can use two shorts, etc. on 32-bit machines for much the same effect.
Jan 07 2009
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
== Quote from redsea (redsea 163.com)'s article
 When I implement some high performance program in linux 32bit, 32bit atomic if
often not sufficient,

environment, I can do that. The IA-32 instruction set contains a 64-bit CAS operation in addition to the 32-bit CAS. You don't even need a 64-bit machine to do it! The atomics module in Tango supports 64-bit storeIf operations on 32-bit Intel platforms. Sean
Jan 07 2009
parent redsea <redsea 163.com> writes:
Sean Kelly Wrote:
 The IA-32 instruction set contains a 64-bit CAS operation in addition to
 the 32-bit CAS.  You don't even need a 64-bit machine to do it!  The
 atomics module in Tango supports 64-bit storeIf operations on 32-bit
 Intel platforms.

Thanks Sean Kelly and Robert Jacques for teaching me. I read following in linux kernel code, so I think x86 32 can not support 64 CAS. I'm going to read tango atomic code :) #ifdef CONFIG_X86_32 # include "atomic_32.h" #else # include "atomic_64.h" #endif
Jan 07 2009