Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

PARAMETER affecting debug line numbers

iklassen
Beginner
1,144 Views
I've come across something a little bit strange when debugging code that contains parameters.

Here's the test code:

subroutine tnmenu (ipltflg,iwin,angl_in)
real HALF2
parameter (HALF2 = 0.5)
c HALF2 = 0.5


if (irot .lt. 1) then
cenx = cenx + HALF2
ceny = ceny + HALF2
end if
return
end

Here's the assembly when NOT using a parameter:

if (irot .lt. 1) then
00412AE3 mov eax,dword ptr [IROT]
00412AE6 test eax,eax
00412AE8 jg TNMENU+2Ch (412B00h)
cenx = cenx + HALF2
00412AEA fld dword ptr [CENX]
00412AED fld dword ptr [HALF2]
00412AF0 faddp st(1),st
00412AF2 fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AF5 fld dword ptr [CENY]
00412AF8 fld dword ptr [HALF2]
00412AFB faddp st(1),st
00412AFD fstp dword ptr [CENY]
end if

It works properly. But, when I use the PARAMETER statement, here's what I get:

if (irot .lt. 1) then
00412ADA mov eax,dword ptr [IROT]
00412ADD test eax,eax
00412ADF jg TNMENU+29h (412AFDh)
cenx = cenx + HALF2
00412AE1 fld dword ptr [CENX]
ceny = ceny + HALF2
00412AE4 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
cenx = cenx + HALF2
00412AEA faddp st(1),st
00412AEC fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AEF fld dword ptr [CENY]
00412AF2 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
00412AF8 faddp st(1),st
00412AFA fstp dword ptr [CENY]
end if

When I step through the program in Visual Studio 2003 it runs through the statements twice (although it only executes them once).

I used the following compile options:
ifort /debug-parameters out:tnmenu.obj /Zi /Od /iface:cvf /traceback /check:bounds /libs:dll /threads /c tnmenu.for
Version: W_FC_C_9.0.025

I tried other options as well but nothing seemed to correct the problem.

Ideas?

Ian
0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,144 Views
You're getting some optimization with "constant folding" when using PARAMETERs, and this can allow some instructions to move around. The apparent repeat is an artifact of the way the debug line numbers are associated with instructions. There are many other places you can see what looks like jumping around when the compiler has reordered the instructions.
0 Kudos
iklassen
Beginner
1,144 Views
Is there a way that I can disable this optimization? I thought that in debug all optimizations were off. This is a simple scenario that I set up to demonstrate this issue, but in my application I get line jumping throughout the program which can make it tedious to debug.
0 Kudos
Steven_L_Intel1
Employee
1,144 Views
Not that I know of - sorry.
0 Kudos
iklassen
Beginner
1,144 Views
Would it be possible to submit this as a bug?
0 Kudos
Steven_L_Intel1
Employee
1,144 Views
You can certainly submit a complaint about it. I'm unsure it qualifies as a bug, but the complaint will be passed on to development and perhaps there's something that can be done about it.

I will say, though, from past experience on a different compiler, that this is a hard problem to solve when the debug language is relatively simplistic about how source line correlation is done.
0 Kudos
iklassen
Beginner
1,144 Views
If something could be done that would be great. Perhaps it would be easier to just have an option to disable that optimization. In any case, what's the process for submitting that?
0 Kudos
Steven_L_Intel1
Employee
1,144 Views
Specify "Feature Request" in Intel Premier Support.
0 Kudos
iklassen
Beginner
1,144 Views
Perfect. Thank you for all of your help.
0 Kudos
Reply