public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33753]  New: gfortran treads known-to-be-contiguous array as having strides
@ 2007-10-12 16:22 burnus at gcc dot gnu dot org
  2007-10-12 20:17 ` [Bug fortran/33753] " jb at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-10-12 16:22 UTC (permalink / raw)
  To: gcc-bugs

Assume a module with the following definitions:
(a)  real, allocatable, dimension(:) :: array
or
(b)  real, dimension(500) :: array

Both arrays are contiguous as one cannot allocate strides
  allocate(array(1:1000:2)) ! invalid
Thus: Only pointers or dummy arguments can have strides.

If one accesses the array in a loop, this can slow down the calculation
considerably.

Test case:

module a
  implicit none
  real, dimension(500) :: array
!  real, allocatable, dimension(:) :: array
contains
  subroutine test(x,n)
    integer :: n, i
    real :: x(n)
!    allocate(array(1:500))
    do i = 1, n
      x(i) = array(i)
    end do
  end subroutine test
end module a
end

>From the dump difference:

-              (*x)[(int8) i + -1] = array[(int8) i + -1];
+              (*x)[(int8) i + -1] = (*(real4[0:] *) array.data)[(int8) i *
array.dim[0].stride + array.offset];

Full example, see:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8fac8fcf6e93fba7/
("Program slowdown when calling function with dynamic arrays" by Paul Hilscher)


-- 
           Summary: gfortran treads known-to-be-contiguous array as having
                    strides
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33753


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug fortran/33753] gfortran treads known-to-be-contiguous array as having strides
  2007-10-12 16:22 [Bug fortran/33753] New: gfortran treads known-to-be-contiguous array as having strides burnus at gcc dot gnu dot org
@ 2007-10-12 20:17 ` jb at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-10-12 20:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jb at gcc dot gnu dot org  2007-10-12 20:17 -------
Gfortran should know that stride==1 for allocatables, as was suggested by Tomas
Koenig in #32131, comment 5.

*** This bug has been marked as a duplicate of 32131 ***


-- 

jb at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33753


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-12 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 16:22 [Bug fortran/33753] New: gfortran treads known-to-be-contiguous array as having strides burnus at gcc dot gnu dot org
2007-10-12 20:17 ` [Bug fortran/33753] " jb at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).