Explicit Do Loop Write

Explicit Do Loop Write

Are there any ifort 8.0 compiler options to optimize explicit do loop writes from a large array using direct access? I know it would be more beneficial to use an implicit loop or write out the array directly, but I found some old code that took about 15 times longer to run using ifort when compared with the portland group compiler. I verified this with a simple program using a 3 nested do loops with a write statement.

Thank you,
Jeremy Ross

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Can you give an example? I'm uncertain what is it your code does.

Have you tried opening the file with BUFFERED='YES'?

Retired 12/31/2016

Belowis an example. I realize this example is not optimal, but the arrays in my real program must be written out in varying orders and may require writig individual elements. Also, I believe the option -assume buffered_io is only for sequential writing.



integer,parameter :: imax=500,jmax=500,kmax=50
real,dimension(imax,jmax,kmax) :: var
integer :: i,j,k,irec

open (UNIT=10, file="test.bin", FORM="unformatted", status="replace", access="direct",recl=4)

do k=1,kmax
do j=1,jmax
do i=1,imax
write (unit=10,rec=irec) var(i,j,k)



Intel Fortran makes no attempt to optimize this. But I think you could accomplish the same thing by opening the file FORM='BINARY' and using sequential writes. Do use BUFFERED='YES' - it should help.

Retired 12/31/2016

Thanks, I will rewrite some of my code to optimize it. I just thought there may be an option that could internally optimize the loops and io like is done with the intrinsic do loop. This may be why the portland compiler is faster for this type of io. Otherwise, for numerical computations I have found ifort to be 20-30% faster than portland group's compiler, nice job intel.

Well, it's not clear to me how one can optimize this automatically- you're writing separate records, which has a different meaning than an implied DO loop in a single WRITE. Doing a lot of small WRITEs can be problematic for performance.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today