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);
---

---
unsigned int fpu_cw;
 _controlfp_s(&fpu_cw, _PC_53, _MCW_PC);
---

---
unsigned int fpu_cw;
 _controlfp_s(&fpu_cw, _PC_64, _MCW_PC);
---

This does not help. Still the asynchronous thread gives different results. 
Should I use different commands? Which ones?

Actually limiting the fp precision on the main thread would be a solution for 
me, though it feels like a dirty workaround.

-----Ursprüngliche Nachricht-----
Von: K. Frank [mailto:kfrank2...@gmail.com] 
Gesendet: Dienstag, 15. März 2016 22:09
An: mingw64
Betreff: Re: [Mingw-w64-public] Floating-Point Operations Not Deterministic 
When Excecuted Asynchronously

Hi Benjamin!

I have no idea how to patch mingw-w64 to do you you really want, but perhaps I 
have a suggestion for a work-around, below.

On Tue, Mar 15, 2016 at 11:15 AM, Benjamin Bihler 
<benjamin.bih...@compositence.de> wrote:
> I have taken commit d82c6defa723b6e7986091ce0fb74da544b9e0f6 ("Reset thread 
> floating point settings on new thread") from the master branch of the mingw64 
> repository, compiled it and replaced the respective files in the "include" 
> and "lib" folder of the "x86_64-mingw32" folder of my mingww64 5.3.0 
> installation with the newly compiled files.
>
> Then I have compiled my sample file with this modified mingw64 installation. 
> It had no effect, the two threads give different results. I have checked that 
> the executable depends only on the DLLs Kernel32.dll and Msvcrt.dll.
>
> When I add
>
> _fpreset()
>
> as the first command of the method that is run asynchronously, both threads 
> give the same result. But this has already been the case with the unmodified 
> mingw64 compiler (without overwriting the link binaries with those from the 
> new revision), I have checked that.
>
> My sample is a C++ sample, since I am using the gnu++11 features.
>
> It would be painful for me, if I had to add _fpreset() to all methods that I 
> want to run asynchronously, especially since they may be part of other 
> libraries.
>
> Did I patch my mingw64 installation in a wrong way? Otherwise it seems as if 
> the commit mentioned above does not solve my problem.
>
> Does anyone have another idea? Thanks!

Disclaimer: I don't know anything about the patch or the _fpreset() call.  
Also, I am speaking from memory, so I may have some of the details backwards.

Is it essential that you get the better, 80-bit long-double behavior, or can 
you live with 64-bit long doubles as long as all threads behave the same way?

As I understand it, the main thread starts with the 80-bit setting, but 
somebody (mingw?, microsoft?) sets 64-bit behavior on start-up of subsequent 
threads.

Perhaps you could -- just once, in your main thread -- set the 64-bit behavior 
when your program starts up.  Then (hopefully) all new threads that 
automatically get 64-bit behavior will match your main thread.

You would still have to call some sort of "_fpset(...)" once in your main 
thread, but you would no longer have to add _fpreset to all of your 
asynchronous methods.

(You might have to do some reverse engineering or ask on this list to find out 
exactly what floating-point mode you need to set for your main thread in order 
that it match that of the child treads.)

Sorry if this is all nonsense, but maybe it could help.


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
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

Reply via email to