This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: really slow ALLOCATE / MOVE_ALLOC
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Thomas Breuel" <tmbdev at gmail dot com>
- Cc: "Janne Blomqvist" <blomqvist dot janne at gmail dot com>, fortran at gcc dot gnu dot org
- Date: Mon, 10 Nov 2008 10:02:36 +0100
- Subject: Re: really slow ALLOCATE / MOVE_ALLOC
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=TmYTBPeGLVRtX4qpaHF1lb6RvDBaytahh8PyDi5bk3A=; b=NXUA+/D1LZ69z/DWOlHtyWjX5iC6tkHINZAqfoVhpHX5jEtXpDzfN6aEGQIzmRD3uD KqwfFXo7P1w9YETGR3Fi/hBsGECGZBDAn7kfNTig973l7X0Vz+715jEaptT4t8ex4fal J6fRspROZySA/A6Ku/H0nvGi6O0XjAyhH9dzY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=nZRl/p/bppzkaiJ0Ei0By783xLV0UTEl5s5kCb1sbOtaiz+2uPTflITLtItUa/uPmF n9BdM3WnQ7oXjumUS4Sks1BwDhIloeAQ+Yu/xRz34hZploiZsDb+IUIuPLtEBnIV8bNh 5BuHlge9gKJxMn9MI0JK9dWIuOLK8tAvNJIgE=
- References: <7e51d15d0811060750x733284afy748cb4eef230a658@mail.gmail.com> <339c37f20811061145q6c944794h93e00157f88e5ed3@mail.gmail.com> <7e51d15d0811061440x4aa12c84h3bd07aeff59d4293@mail.gmail.com>
Tom,
> What can't be addressed with a library routine is optimizing
> temporaries, either removing them completely, or reallocating them
> using realloc. That's where gfortran developers need to pay
> attention. There are many situations that can be optimized; the
> section of the Fortran standard you cite no more prohibits optimizing
> temporary storage than other parts prohibit CSE.
I agree with you entirely about temporaries. gfortran's performance
will almost certainly improve markedly if temporaries are not freed
but are kept for reuse via realloc.. One of the reasons why gfortran
does as well as it does, in comparison with commercial products, is
that we have paid a lot of attention to reducing temporary usage, via
fairly rigorous dependency analysis. We could go further by deploying
loop reversal (patch available), loop order rearrangement(present in
gfortran but commented out because it doesn't work correctly yet) and
breaking up long loops but I rather think that memory management is
the next most effective step.
>
>> Ultimately, of course, the programmer is obliged, if all else fails,
>> to use the same strategy as realloc; allocate oversize and only
>> de-allocate/allocate when needed.
>
> Good implementations of malloc use VM hardware and page remapping,
> rather than reserve extra space. Look at the mremap system call on
> Linux.
I understand this but reducing the number of system calls by
allocating oversize will certainly result in a performance
improvement.
>
>> This will become and issue when we implement automatic allocation for
>> allocatable arrays, a la f2003.
>
> Well, I think it's important that whoever works on that have a good
> understanding of dynamic memory management strategies, in addition to
> what actual malloc implementations do. There seem to be a lot of
> prejudices and misconceptions people have about memory management.
True but a naive application with realloc would be a good start:-)
>
> Efficient memory management is at least as hard as good numerics, and
> just as important for high performance computing. The good news is
> that the Fortran compiler can potentially do a lot more for the
> programmer automatically than C compilers can.
>
Agreed - Paul
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy