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

Explicit Do Loop Write

jdr147
Beginner
1,080 Views
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
0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,080 Views
Can you give an example? I'm uncertain what is it your code does.
Have you tried opening the file with BUFFERED='YES'?
0 Kudos
jdr147
Beginner
1,080 Views

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.

Thanks

PROGRAM test

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)

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

close(10)

END PROGRAM test
0 Kudos
Steven_L_Intel1
Employee
1,080 Views
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.
0 Kudos
jdr147
Beginner
1,080 Views

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.

0 Kudos
Steven_L_Intel1
Employee
1,080 Views
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.
0 Kudos
Reply