🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.fortran
Article #4464

Re: Fast I/O

#4464
From: J. Giles
Date: Fri, 22 Jan 1993 18:10
37 lines
2139 bytes
In article <1993Jan21.081105.4047@molene.ifremer.fr>, molagnon@ditigo.ifremer.fr (Michel Olagnon, Ifremer DITI GO, 98.22.41.44) writes:
|> [...]
|> Many Fortran compilers are not efficient on I/O with implied DO loops.
|> Replacing 
|>       write (lu) (a (j), j=LO,HI)		![generalize your case a bit]
|> with
|>       call fstwrt (lu, a(LO), HI-LO+1)	![similar generalization]
|>          .
|>          .
|>       subroutine fstwrt (lu, a, n)
|>       double precision a (n)
|>       write (lu) a
|>       return
|> usually gives dramatic improvement.
|> 
|> I have a follow-up question : why don't compilers execute this optimization ?

I asked Cray for something similar to this more than 5 years ago.
In fact, they actually had an interface to the I/O library defined
which not only passed the array and the length, but the stride as
well.  This would have permitted buffered I/O for even strided
data to run as fast as the example you gave.  (It doesn't help
unbuffered I/O unless the stride is exactly one - in which case
you get the same thing as you just posted.)  For some reason,
even though Cray had the interface defined and the hooks in the
compiler to implement it, they never did.  I estimated that it
would have sped some I/O bound code by several times.

The reason for the speedup is that most implementations compile
the implied loop into a tight loop around the I/O library call.
The above made a separate trip through the I/O routines for each
element of the array.  The whole-array write only takes a single
trip through the library for the whole array.  The call/return 
overhead often dominates for I/O on single elements.

-- 
J. Giles
Technical Details
Message-ID: <1993Jan22.181029.12646@newshost.lanl.gov>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
References: <1jhqkhINNno3@bigboote.WPI.EDU> <1993Jan21.081105.4047@molene.ifremer.fr>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.fortran
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
From: jlg@cochiti.lanl.gov (J. Giles)
Subject: Re: Fast I/O
Message-ID: <1993Jan22.181029.12646@newshost.lanl.gov>
Sender: news@newshost.lanl.gov
Organization: Los Alamos National Laboratory
References: <1jhqkhINNno3@bigboote.WPI.EDU> <1993Jan21.081105.4047@molene.ifremer.fr>
Date: Fri, 22 Jan 1993 18:10:29 GMT
Lines: 37