Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 10:58:32AM +0200, Thomas Schwinge wrote: > So, something in spirit of what has been implemented in > gcc/config/i386/gmm_malloc.h. Yeah, though don't take that literally, gmm_malloc.h e.g. isn't very secure, _mm_malloc (-16384, 32768); might very well result in heap corrupt

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Tobias Burnus
[Some quote of mine] On Wed, Oct 22, 2014 at 10:37:02AM +0200, Jakub Jelinek wrote: > But it is the frontend that can know this, not the middle-end. > Having to compute the old size and using some intrinsic unconditionally > on all targets just because the code might be offloaded (and lowering that

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Thomas Schwinge
Hi! On Wed, 22 Oct 2014 10:04:48 +0200, Jakub Jelinek 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 a

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 10:32:26AM +0200, Tobias Burnus wrote: > b) (Re)allocation on assignment, i.e. > A = ... > where A is allocatable. The compiler then allocates the left-hand side if > unallocated or reallocates it if the array shape, dynamic type or a length > type parameter on the right d

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Tobias Burnus
Hmm, for some reasons my first email didn't come through - I have to check at home why. Thus, writing anew: Regarding: > The Fortran frontend likes to generate calls to realloc, but in one case it > seems > like we can compute the old size, and call a function that does > malloc/memcpy/free inste

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 09:45:29AM +0200, FX wrote: > I’m afraid I don’t understand the reasoning here: > > > Since malloc and free are magically provided by the ptx environment, but > > realloc is missing, it's nontrivial to provide an implementation for it. > > The Fortran frontend likes to ge

Re: Avoid calls to realloc for nvptx

2014-10-22 Thread FX
Hi Bernd, I’m afraid I don’t understand the reasoning here: > Since malloc and free are magically provided by the ptx environment, but > realloc is missing, it's nontrivial to provide an implementation for it. The > Fortran frontend likes to generate calls to realloc, but in one case it seems

Avoid calls to realloc for nvptx

2014-10-21 Thread Bernd Schmidt
This is a followup patch for the nvptx port. Since malloc and free are magically provided by the ptx environment, but realloc is missing, it's nontrivial to provide an implementation for it. The Fortran frontend likes to generate calls to realloc, but in one case it seems like we can compute th