This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/52473] CSHIFT slow - inline it?


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-16
     Ever confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
I don't have access to pathf95, but the following test (modified for some IDRIS
benchmarks)

  subroutine test_cshift()
    !-----------------------------------------------------------------
    ! Test de la fonction intrinsÃque "cshift"
    !-----------------------------------------------------------------
    implicit none
    integer, parameter             :: n=ordre
    integer                        :: i,j
    integer, dimension(n)          :: vect=(/ (-i, i=1,n) /)
    real(kind=prec),dimension(n,n) :: t,td,t2,t1
    real(kind=prec)                :: cste

    call impression_entete("test_cshift")
    print *, "Order of matrix:", n

    !---- Initialisations --------------------------
    cste=exp(1._prec)
    t(:,:)  = reshape( &
              source=(/ (i*cste,i=1,n*n) /) , shape = (/ n,n /) )

    td(:,:) = 0._prec
    call cpu_time( val_temps(1) )
    td(:,:) = cshift(array=t(:,:), shift=vect(:), dim=1)
    call cpu_time( val_temps(2) )
    t1(:,:)  = td(:,:)

    call temps_consomme("test_cshift> 1) CSHIFT")

    !---- DÃcalage selon les lignes via des boucles --------------------
    td(:,:) = 0._prec
    call cpu_time( val_temps(1) )
    do j=1,n
       do i=n+vect(j),1,-1
          td(i-vect(j),j) = t(i,j)
       end do
       do i=1,-vect(j)
          td(i,j)=t(n+vect(j)+i,j)
       end do
    end do
    call cpu_time( val_temps(2) )
    t2(:,:) = td(:,:)

    call temps_consomme("test__cshift> 2) DO loop")

    if (sum(abs(t2-t1)) /= 0._prec) then
       print *,'Mauvais rÃsultats !!!!',sum(abs(t2-t1))
    else
        print *,'Results OK'
    end if    

  end subroutine test_cshift

gives

====================
 Call to test_cshift
====================

 Order of matrix:        1000
 test_cshift> 1) CSHIFT
                                       Used CPU time ==>         7.624 ms
 test__cshift> 2) DO loop
                                       Used CPU time ==>         4.482 ms
 Results OK

So CSHIFT is 50% slower than the DO loop.

Note that I get similar results for EOSHIFT and RESHAPE:

=====================
 Call to test_eoshift
=====================

 Order of matrix:        1000
 test_eoshift> 1) EOSHIFT
                                       Used CPU time ==>         7.443 ms
 test__eoshift> 2) DO loop
                                       Used CPU time ==>         3.775 ms
 Results OK

=====================
 Call to test_reshape
=====================

 Order of matrix:        1000
 test__reshape> 1) RESHAPE
                                       Used CPU time ==>        10.624 ms
 test__reshape> 2) DO loop
                                       Used CPU time ==>         4.442 ms
 Results OK

PR45689 should probably fixed at the same time.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]