Created attachment 1133
Source code for the example showing the problem.
The attached code compiles and runs as expected using gdc on Debian Unstable:
gdc -I. -O3 -c -o pi_d_threadsGlobalState_threadGroup.o
pi_d_threadsGlobalState_threadGroup.d
gdc -I. -O3 -c -o output_d.o output_d.d
gdc -o pi_d_threadsGlobalState_threadGroup
pi_d_threadsGlobalState_threadGroup.o output_d.o
./pi_d_threadsGlobalState_threadGroup
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 1
π = 3.141592653589970752
iteration count = 1000000000
elapse time = 8.610002
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 2
π = 3.141592653589901030
iteration count = 1000000000
elapse time = 4.307193
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 8
π = 3.141592653589769135
iteration count = 1000000000
elapse time = 1.126820
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 32
π = 3.141592653589757145
iteration count = 1000000000
elapse time = 1.103556
number of processors = 8
Using dmd 2.060 installed using the deb on the DLang downloads website:
rdmd pi_d_threadsGlobalState_threadGroup.d
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 1
π = 3.706147513366483626
iteration count = 1000000000
elapse time = 11.192674
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 2
π = 0.000000000000000000
iteration count = 1000000000
elapse time = 0.000162
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 8
π = 3.093593503818492962
iteration count = 1000000000
elapse time = 1.446934
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 32
π = 2.126965177696329423
iteration count = 1000000000
elapse time = 1.436152
number of processors = 8
Comment #1 by russel — 2012-08-04T04:26:20Z
I downgraded to dmd 2.059 using the deb from the FTP site and the problem goes away, so this is very definitely a problem introduce in the 2.059 → 2.060 upgrade.
Comment #2 by russel — 2012-08-04T04:28:40Z
Result using 2.059 (sorry should have put this on previous comment):
rdmd -O -release pi_d_threadsGlobalState_threadGroup.d
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 1
π = 3.141592653589970752
iteration count = 1000000000
elapse time = 8.608373
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 2
π = 3.141592653589901030
iteration count = 1000000000
elapse time = 4.307447
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 8
π = 3.141592653589768691
iteration count = 1000000000
elapse time = 1.103842
number of processors = 8
======================== pi_d_threadsGlobalState_threadGroup.d, task count: 32
π = 3.141592653589756257
iteration count = 1000000000
elapse time = 1.117225
number of processors = 8
Comment #3 by dmitry.olsh — 2012-12-27T03:52:06Z
Works in the latest 2.061alpha.
The root case is a closure bug fixed in issue #8774.
*** This issue has been marked as a duplicate of issue 8774 ***