Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

exe and dll give different result x*y

billaustralia
Beginner
896 Views
I provide my program both as an exe and a windows dll. The dll gets file names via an argument list; the exe from the command line. I am running a case that should give the same results and getting a difference.
I have tracked the first diff to the following lines of code
RP=DHDT*WDET
write(11,*)'debug sstate2',dhdt,wdet,rp,wm,det
which from the dll produces
debug sstate2 35.9161568013318 1.987095554958044E-007
7.136883553110247E-006 1.703385880906484E-002 85722.3940064850
but from the exe the red 7 is 6
Anyone have a clue why?
0 Kudos
4 Replies
Steven_L_Intel1
Employee
896 Views
Anything that changes the code can cause a different order of arithmetic operations, and this could cause a rounding difference.
0 Kudos
billaustralia
Beginner
896 Views
Thanks but is just changing from producing exe to ddl both with Optimization set to disable enough?
In any case, I now realize that this output does not show the full bit pattern and changed to using z18 format.
So chasing it further back I get a difference in a simple add between exe and dll. The code portion is

Add1=al(7)
Add2=ZI*A(I,7)
write(11,'(a,i3,(6z18))')'debug ssinit',i,Add1,Add2,Add1+Add2,AL(7)+ZI*A(I,7)

A is a single precision array, ZI, Add1, Add2 are double precision, I an integer

from which the exeproduces

debug ssinit 3 3F043F766EF9DB23 3EBC18F01CAC0830 3F05203DEFDF3B64 3F05203DEFDF3B65

The dll is the same but the red 5 is 4

0 Kudos
Steven_L_Intel1
Employee
896 Views
You changed from a program to a subroutine, yes? That will change the code. By default, single-precision operations are carried out in double and then rounded back to single when stored to memory. The compiler may keep intermediate results in registers longer thus delaying the rounding.
0 Kudos
Intel_C_Intel
Employee
896 Views
Hello. Mixing single and double precsion may give surprising rounding effects. If you are concerned about precision I would recommend to use double precision only and also enable the new 64 bit instruction set (SSE2) by means of the compiler options /QxN or /QxP. As it is not easy to check that all parameters have been initiated correctly with "D" in the end, you can use the /fpconstant option to extend precision of single precision constants. If you are very concerned about precision you can also check that the .asm code does not include any single precision instructions (like mulss). We have recently converted everything to full 64 bit SSE2 double precision and checked that the .asm does not include any single precision instructions, and our simulations are now much more stable (less sensitive to changes), in particular for the dynamical case that are nonlinear and chaotic (positive Lyapunov exponents). Best Regards, Lars Petter Endresen
0 Kudos
Reply