- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I noticed that the topic of fp:precise has come up before. At
http://software.intel.com/en-us/forums/showpost.php?p=79322 Steve Lionel says
"Ok - that means that your program depends on computations being carried out in greater than declared precision - not a good thing for long-term reliability, especially as this extra precision is not predictable."
I suspect I might have that situation. If I run a win64 excutable (built with 11.1 compiler) via a combination of .bat and perl scripts, I get one set of results. If I run the same executable directly in a DOS prompt, I get another slightly different result. They are basically the same answer - there are some very minor numerical differences. But why I am even getting them?
I rebuild the exe with fp:/precise and do the same test. This time I get the same answers for both runs.
Could the "extra precision not being predictable" explain what I am seeing here?
Thanks!
Tony
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve. My initial suspicion was an un-initialised variable, but we not found any (yet). So your second theory sounds more plausable. By "alignment difference" do youmean similar issues to those with MKL whereby one must align dynamically allocated memory to 16byte boundaries to get repeatable results (I posted a question on this very topic on the MKL quite recently to clarify that it applies to both 32 and 64bit).
We are using a lot of Fortran dynamic allocations - if we ensured all arrays were 16 btye boundary aligned, would that solve the problem? Or am I completely barking up the wrong tree here?
Thanks so much,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Third-party controls that wrap a Fortran program have a tendency to change floating point behavior. I even remember getting a different set of answers on Win2k vs WinXP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes - we are calling some third party C++ routines to do some formatting file writing.
We also have someinternal components that havea C++ wrapper but in this particilar case we are running, they are not being called.
So it possible that our Fortran code might be getting the exactly same values, but when those values are passed to the C++ file writing third party code, there is some effect of roundoff or extended precision corruption happening?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To clarify, we are starting a windows process at the command line, e.g. test.exe -runthisone -more options. But test.exe calls some C++ libraries underneath, though all of the numerical computations are in Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
unsigned int iOldFloatingPointFlag;
_controlfp_s(&iOldFloatingPointFlag, 0, 0);
And then compare the values you get for iOldFloatingPointFlag, either print them on a screen, or write them to a file, or something. That was the flag that third-party components would mess up for me.
There's supposed to be a Fortran2008 equivalent, but I've never used it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So basically I should be looking at the C++<->Fortran calls for being the culprit? But this seems somewhat inconsistent with Steve's first comment about optimisation perhaps being the cause?
I guess I would like to understand how either of these, especially optimization, might result in unpredictable results. Maybe there is a white paper, or documentation you could point me to please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://software.intel.com/en-us/articles/consistency-of-floating-point-results-using-the-intel-compiler/
Whilst it is indeed possible for third party code (Fortran as well as C++) to change floating-point settings, things like different optimization settings are a much more likely cause. If getting exactly the same results is important to you, then using the /fp:precise switch is the recommended way to go about this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This helped a lot - thank you for that article. However, my investigations have continued and this is what I now find:
(1) Run my exe. Save the results.
(2) Set a nonsense environment variable of a fairly long length of characters. Run the exe a second time. Save the results
The results from run (2) are DIFFERENT to those of run (1). So adding an enviroment changes my results!!!!!!!!!! Can you think of any reason why this might be the case as this seems almost unbelievable!!!
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve! So we should be looking at variables stored on the stack as the cause (i.e. not heap allocated arrays)?
I guess in the back of my mind I am unsure whether our heap allocated arrays - using the ALLOCATE statement - should be 16byte boundary aligned or not to get reproducable results (even though we not using MKL in this particular test case) - when -O2 (and no fp:precise) is being used. Do you have any opinion on that please?
Thanks again,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keep in mind that local scalars will be stack-allocated by default, or in registers, with unpredictable initial contents. You may be referencing an uninitialized variable somewhere. As an experiment, try compiling with /Qsave /Qzero and see if the results change.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page