Thank you for that hint! Now really the two threads behave equally! ☺
How to continue? Is it a disadvantage to default to FLT_EVAL_METHOD=1 with
mingw-w64? Will the fix be part of the next mingw-w64 release? Then with the
new compiler distribution, my thread will behave the same without linking to
extra fp-related objects?
Thanks for answers and support!
Von: Carl Kleffner [mailto:cmkleff...@gmail.com]
Gesendet: Donnerstag, 17. März 2016 16:09
An: mingw-w64-public@lists.sourceforge.net
Betreff: Re: [Mingw-w64-public] Floating-Point Operations Not Deterministic
When Excecuted Asynchronously
Just link your example with CRT_Fp8.o:
g++ -O2 -std=gnu++11 main.cpp <pathto>\mingw64\x86_64-w64-mingw32\lib\CRT_fp8.o
With that it is ensured that the intermediate precision of the FPU is double
precision even for the main thread. In the C99 standard this is
FLT_EVAL_METHOD=1
The problem with mingw-w64 is that it defaults to FLT_EVAL_METHOD=2
(intermediate precision is long double), but new threads never starts with
FLT_EVAL_METHOD=2 per default on Windows. Hence the difference between main
thread and new thread.
C.
2016-03-17 15:45 GMT+01:00 Benjamin Bihler
<benjamin.bih...@compositence.de<mailto:benjamin.bih...@compositence.de>>:
There is no difference in the results. I have even raised the precision of the
number output, but my call to _controlfp_s seems not to influence the output at
all... what does that mean? That _controlfp_s cannot be a part of the solution?
-----Ursprüngliche Nachricht-----
Von: K. Frank [mailto:kfrank2...@gmail.com<mailto:kfrank2...@gmail.com>]
Gesendet: Donnerstag, 17. März 2016 14:40
An: mingw64
Betreff: Re: [Mingw-w64-public] Floating-Point Operations Not Deterministic
When Excecuted Asynchronously
Hi Benjamin!
On Thu, Mar 17, 2016 at 4:07 AM, Benjamin Bihler
<benjamin.bih...@compositence.de<mailto:benjamin.bih...@compositence.de>> wrote:
> Thank you for the suggestion.
>
> I have tried the following code snippets when the program starts up to set
> the floating-point precision:
>
> ---
> unsigned int fpu_cw;
> _controlfp_s(&fpu_cw, _PC_24, _MCW_PC);
> ---
> ...
> This does not help. Still the asynchronous thread gives different results.
> Should I use different commands? Which ones?
I don't know anything about the details of _controlfp_s, etc., but I do have a
debugging question.
Did any of your versions of calling _controlfp_s have any effect in that they
changed the results produced by the main thread (even if those changed results
did not match the results of the asynchronous thread)?
Or did your main thread still give the same results as without the _controlfp_s
call?
Obviously, until you can change the behavior of the main thread, you can't
change it to match the asynchronous threads.
In any event, hopefully someone on this list could tell you what call to
_controlfp_s you need to match the floating-point environment that is getting
set up for the asynchronous thread. (I certainly can't.)
> Actually limiting the fp precision on the main thread would be a solution for
> me, though it feels like a dirty workaround.
Yeah, you shouldn't have to use the less-favorable precision. But that's the
nature of work-arounds ...
Logically, I do think the idea should work. Sorry i can't give you any detail
on how to make it work.
(Of course, the better approach is to figure out how to make the child threads
behave -- i.e., use the extended precision, and otherwise use a floating-point
environment consistent with that of the main thread.)
Good luck.
K. Frank
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with Intel Data Analytics
Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net<mailto:Mingw-w64-public@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net<mailto:Mingw-w64-public@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public