Avoid calls to realloc for nvptx
Thomas Schwinge
thomas@codesourcery.com
Wed Oct 22 08:58:00 GMT 2014
Hi!
On Wed, 22 Oct 2014 10:04:48 +0200, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Oct 22, 2014 at 09:45:29AM +0200, FX wrote:
> > > Since malloc and free are magically provided by the ptx environment, but realloc is missing, [...]
> Yeah, I wonder why can't you just wrap the PTX "malloc"/"free" by allocating
> small header in front of the allocated area
Thanks for hitting (at least me) with a clue bat... When we discussed
this internally, I did have the hunch that it ought to be possible to
implement realloc if only malloc and free are available, but I didn't see
the obvious... Now I remember that I'd even seen something like that
recently:
> where your wrapping
> implementation will deal with everything you need (remember the size of the
> allocation, so realloc can work, or if PTX malloc doesn't support alignment,
> also bias so that you can support aligned_alloc or posix_memalign).
So, something in spirit of what has been implemented in
gcc/config/i386/gmm_malloc.h.
> As an optimization, if the compiler could prove that certain allocations are
> never realloced, never need aligned memory etc., you could optimize it to
> avoid the wrappers and use PTX "malloc"/"free" directly.
I guess that if the compiler is able to prove that (no escaping pointers,
basically?), chances are that malloc/free can be eliminated completely?
Grüße,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20141022/be74d00d/attachment.sig>
More information about the Fortran
mailing list