Quantcast
Channel: Intel® Fortran Composer XE
Viewing all articles
Browse latest Browse all 1424

optimization do loop

$
0
0

I am wondering if in the following DO-loop, the introduction of the new INTEGER variable upper_index in place of the two identical calculations x_index(i,l) + N will have a benefit to the performance?  I have already timed this loop and compared it to the original loop, and the runtime ratio indicates ~1.40 performance gain.

  DO i = 1,N
    upper_index = x_index(i,l)+N
    coef(i) = 0.5 * vz(x_index(i,l),l)
    g2(i) = 2. * ( a(upper_index,k,l) - a(x_index(i,l),k,l) ) / ( dz(x_index(i,l)) * (1.0 + az1(x_index(i,l)) ) )
    IF (s(x_index(i,l),l) <= p1 .OR. s(upper_index,l) <= p1) g2(i)=0.0
  END DO

This loop is nested in loops over K and L

However, when I tested the same idea in the following simple loop, I did not see meaningful difference in the speed of the code.

do i = 1,nloop1
  do j = 1,nloop2
    k = i+j
    variable(k) = k
  end do
end do

Which one of the above two observations I can possibly trust?

Also, I noticed that the use of IF-ELSEIF construct is noticeably less efficient than using multiple IF statements in a DO-loop.  Is this observation correct? I am using Intel Fortran compiler 2015, with O2 optimization flag.

Thanks you in advance,


Viewing all articles
Browse latest Browse all 1424

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>