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

opposite change between 'Debug' and 'Release' in program efficiency of time consuming

jackmwl
Beginner
863 Views
Hi everyone

I have been trying to improve the program efficiency in time and memory andmake tradeoff between them. CPUTIME is used to measure the time consuming, but efficiency in memory isevaluated by experience. The effortswere focused on the procedure which would be called ten thounds times when executing the program.

The original codes are shown as follows,
!...
REAL(8), INTENT(IN) :: x(n)

!...

REAL(8), DIMENSION(:), ALLOCATABLE :: YYDM, RetL, RetR...

REAL(8), DIMENSION(:,:), ALLOCATABLE :: YYD, YYA, UU...

!...

ALLOCATE(...)
! assign subsection of x to YYD, YYA, UU...
! operations on YYD(:,j), YYA(:,j), ...,YYDM,RetL,RetR...
!...
DEALLOCATE(...)
!...

The improved codes are

!...

REAL(8), INTENT(IN) :: x(n)

!...

TYPE :: opter

REAL(8), DIMENSION(Nd) :: YY

REAL(8), DIMENSION(Nu) :: UU

REAL(8), DIMENSION(Nd) :: Ret

END TYPE opter

TYPE (opter) :: optmid

TYPE (opter), TARGET :: optlft, optrgt

TYPE (opter), POINTER :: prtlft, prtrgt, prttmp

!...

NULLIFY(prttmp)

prtlft => optlft

prtrgt => optrgt

!...

DO ...
! assign subsection of x to prtlft,prtrgt,optmid
! operations on prtlft,prtrgt,optmid

!...

prttmp => prtlft

prtlft => prtrgt

prtrgt => prttmp

END DO

!...

NULLIFY(prtlft, prtrgt, prttmp)
!...

The original and improved program cost 50 seconds and 35 seconds in 'Debug', respectively. However,they cost7.5 seconds and 8.0 seconds in 'Release'.So why the improved program costs less time in 'Debug' but more time in 'Release' than the original?

Any help would be highly appreciated!

Best regards

Jack

0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
863 Views
Jack,

It would appear that the compiler opmizations works better on your original code than it does on your "improved" code. IOW your improvements at self optimizations hinder the compiler from fully optimizing your code. Without your code listed it would be hard to guess as to what is going on. One thing to look for is enable/check diagnostic reports to see if your improvements hinder vectorization.

Jim Dempsey
0 Kudos
jackmwl
Beginner
863 Views
Hi Jim,

Thanks for your quick reply!

The original and "improved" code have been attached here.

By the way, what should i do to enable/check diagnostic reports to see if the improvements hinder vectorization?

Best regards

Jack


0 Kudos
jimdempseyatthecove
Honored Contributor III
863 Views
After a quick look (no analysis)...

Your "improved" code is copying data into user defined types (e.g. optmid)whereas the old code is simply remembering the index of where the selected (found) data resided in the original input array (e.g. YYAMID)

I think you are unnecessarily moving data about as opposed to remembering where it resided.

Jim Dempsey
0 Kudos
jackmwl
Beginner
863 Views
Hi Jim,

Thanks for your advice.
I will test the way remembering where it resided.

Best regards

Jack

0 Kudos
Reply