This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] Unformatted array IO performance improvement


after much talk on the mailing list, I'm happy to present a coarse
grained interface to the IO library. The operating principle is to
pass an array descriptor to the library instead of generating code to
loop over the scalar transfer functions. Then in the library, in case
the innermost dimension has stride 1, it can read/write in chunks of
the innermost dimension size, thus avoiding the heavy overhead of
executing scalar transfers.

Currently only unformatted read/write benefits from this; the
formatted transfer functions simply loop over the old scalar

The performance improvements are rather dramatic. For rdiska.f
(PR23363), in combination with the recent chucking of mmap, 4.1 + this
patch is about 350 times faster than 4.0. Yes, you read that
correctly: 350 times. Performance is roughly on par with g77 (a little
bit slower, actually).

For PR 16339, runtime drops from about 1.25 seconds to 0.20 seconds, a
factor of 6 improvement for a very common usage scenario. By
comparison, a C program with a single fwrite() does the same in
roughly 0.13 seconds, g77 0.77 seconds, and ifort 9.0 0.06 seconds.

Currently, implied do loops are still handled the old-fashioned
way. Also, arrays as components of derived type also use the scalar
transfer function. It should be relatively easy to allow array
transfers for derived type components, but the problem is that one
needs the gfc_conv_expr_descriptor() function which needs gfc_expr as
an argument, but in transfer_array_component gfc_expr is no longer
available. I don't think it would be very hard to fix somehow, but
with 4.1 drawing close I'd very much like to see this committed before
embarking on anything fancy.

The patch has been regtested on i686-Linux.

Janne Blomqvist

Attachment: ChangeLog
Description: Text document

Attachment: array-io.diff
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]