- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
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?
링크가 복사됨
4 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Anything that changes the code can cause a different order of arithmetic operations, and this could cause a rounding difference.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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)
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
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
