std.math.pow produces incorrect results when used with std.parallelism
Johannes Pfau
nospam at example.com
Sun Jun 2 01:28:39 PDT 2013
Am Sun, 02 Jun 2013 07:17:12 +0200
schrieb "finalpatch" <fengli at gmail.com>:
> the following code compiled with GDC shows the bug
> (I'm using the gcc 4.8 windows mingw32 version from
> https://bitbucket.org/goshawk/gdc/downloads)
>
> import std.math;
> import std.stdio;
> import std.range;
> import std.parallelism;
>
> void main()
> {
> enum n = 1000;
> float step = 1.0f/n;
>
> float[n] results_singlethreaded;
> float[n] results_multithreaded;
>
> foreach(i; iota(n))
> results_singlethreaded[i] = pow(step * i, 0.4545f);
> foreach(i; parallel(iota(n)))
> results_multithreaded[i] = pow(step * i, 0.4545f);
> foreach(i; iota(n))
> assert(results_singlethreaded[i] ==
> results_multithreaded[i]);
> }
>
> ~/Desktop $ ./test.exe
> core.exception.AssertError at test.d(26): Assertion failure
>
> The same code passes without assertion when compiled with DMD.
Please file a bug report on bugzilla.gdcproject.org
I can't reproduce this on linux/posix. Could you use feqrel to check
the number of equal bits of the single/multithreaded results?
More information about the D.gnu
mailing list