This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: timeline?
Your program doesn't do it; this one does:
$ cat try.f95
program test
integer, parameter :: n = 100
real, allocatable :: a(:),temp(:)
allocate(a(n))
a = 0
allocate(temp(2*size(a)))
temp(1:size(a)) = a
call move_alloc(temp,a)
a = 1
print *,sum(a)
end program
$ gfortran -O3 try.f95
$ ltrace -o log a.out
200.00000
ixion:~$ sort log | uniq -c
...
106 _gfortran_size0(0xbfd8a530, 0x8048c04, 0, 0, 0) = 100
...
$
Nothing in that program should end up calling _gfortran_size0 more
than a couple of times.
Tom
On Thu, Nov 6, 2008 at 13:28, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Thomas, Janne,
>
>>> (Tracing this, I just discovered that statements like temp(1:size(a))
>>> = a make one shared library call to _gfortran_size* for each element
>>> transferred, even on -O3, which would seem to be a potential
>>> performance problem.)
>>
>> Huh? Yeah, that sounds bad.
>
> Really?
>
> integer :: o(100)
> call foo (o, 10)
> contains
> subroutine foo (b, n)
> integer :: a(100), b(n)
> a(1:size(b)) = b
> end subroutine
> end
>
> produces
>
> foo (integer(kind=4)[0:D.657] * b, integer(kind=4) & n)
> {
> integer(kind=4) a[100];
> integer(kind=4) ubound.0;
> integer(kind=4) size.1;
> integer(kind=4) D.657;
> bit_size_type D.658;
> <unnamed-unsigned:32> D.659;
>
> ubound.0 = *n;
> size.1 = NON_LVALUE_EXPR <ubound.0>;
> size.1 = MAX_EXPR <size.1, 0>;
> D.657 = size.1 + -1;
> D.658 = (bit_size_type) (<unnamed-unsigned:32>) size.1 * 32;
> D.659 = (<unnamed-unsigned:32>) size.1 * 4;
> {
> integer(kind=4) D.654;
> struct array01_integer(kind=4) * D.653;
> struct array01_integer(kind=4) parm.2;
> integer(kind=4) D.642;
> integer(kind=4) D.641;
>
> D.641 = ubound.0;
> D.642 = ubound.0;
> parm.2.dtype = 265;
> parm.2.dim[0].lbound = 1;
> parm.2.dim[0].ubound = ubound.0;
> parm.2.dim[0].stride = 1;
> parm.2.data = 0B;
> parm.2.offset = 0;
> D.653 = &parm.2;
> D.654 = _gfortran_size0 (D.653);
> {
> integer(kind=4) S.3;
>
> S.3 = 1;
> while (1)
> {
> if (S.3 > ubound.0) goto L.1;
> a[S.3 + -1] = (*b)[S.3 + -1];
> S.3 = S.3 + 1;
> }
> L.1:;
> }
> }
> }
>
>
> I don't see it. ubound.0 is a temporary to which n has been assigned.
>
> Paul
>