[patch, fortran, RFC] First steps towards inlining matmul
Dominique d'Humières
dominiq@lps.ens.fr
Fri Apr 10 14:15:00 GMT 2015
> Le 10 avr. 2015 à 00:18, Thomas Koenig <tkoenig@netcologne.de> a écrit :
>
> Hello world,
>
> here is an update on the matmul inlining patch. Now, the
> rank one + rank two cases are also handled.
Preliminary tests show that my variant of fatigue.f90 with matmul is as fast (if not faster) as the original test with dot products.
However this causes new failures
FAIL: gfortran.dg/matmul_bounds_4.f90 -O1 execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -O2 execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -O3 -fomit-frame-pointer execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -O3 -fomit-frame-pointer -funroll-loops execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -O3 -g execution test
FAIL: gfortran.dg/matmul_bounds_4.f90 -Os execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O1 execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O2 execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O3 -fomit-frame-pointer execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O3 -fomit-frame-pointer -funroll-loops execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -O3 -g execution test
FAIL: gfortran.dg/matmul_bounds_5.f90 -Os execution test
and may be
FAIL: gfortran.dg/coarray_lib_this_image_2.f90 -O scan-tree-dump-times original "mylbound = parm...dim\\[0\\].stride >= 0 && parm...dim\\[0\\].ubound >= parm...dim\\[0\\].lbound \\|\\| parm...dim\\[0\\].stride < 0 \\?[^\n\r]* parm...dim\\[0\\].lbound : 1;" 1
FAIL: gfortran.dg/dependency_26.f90 -O scan-tree-dump-times original "&a" 1
> Reallocation on assignment also works now.
Confirmed.
>
> Still missing:
>
> 1. Control via an option, BLAS inlining has to take precedence
> 2. handling of matmul(a,b) occurring in the middle of an expression.
> 3. Bounds checking from the front end pass (basically, calling
> gfortran_runtime_error).
> 4. More test cases
>
> What do you think? 1. is straightforward,
I agree if the bounds are known at compile time (it will be nice to use -fblas-matmul-limit=n for the threshold).
However for bounds know at run time only, I don’t see how we can escape some king of versioning.
> we don't really need to do 2. for committing early in stage one.
Agreed: no point to mess with complicated expressions if the simple ones are not properly debugged!
> For 3, we could maybe just issue a STOP.
I have silenced these failures (gfortran.dg/matmul_bounds_*.f90) by adding -fno-frontend-optimize to the list of options. IMO having the same message with/without inlining is needed.
> 4. is required, I need to look at some more corner cases where bugs may still be lurking.
I also see the following failures
FAIL: gfortran.dg/shape_2.f90 -O0 execution test
FAIL: gfortran.dg/shape_2.f90 -O1 execution test
FAIL: gfortran.dg/shape_2.f90 -O2 execution test
FAIL: gfortran.dg/shape_2.f90 -O3 -fomit-frame-pointer execution test
FAIL: gfortran.dg/shape_2.f90 -O3 -fomit-frame-pointer -funroll-loops execution test
FAIL: gfortran.dg/shape_2.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test
FAIL: gfortran.dg/shape_2.f90 -O3 -g execution test
FAIL: gfortran.dg/shape_2.f90 -Os execution test
FAIL: gfortran.dg/shape_2.f90 -g -flto execution test
A reduced test is:
program main
integer, dimension (40, 80) :: a = 1
call test (a)
contains
subroutine test (b)
integer, dimension (11:, -8:), target :: b
integer, dimension (:, :), pointer :: ptr
print *, lbound (b (:, :), 1)
! if (lbound (b (:, :), 1) .ne. 1) call abort
print *, lbound (b (:, :), 2)
! if (lbound (b (:, :), 2) .ne. 1) call abort
print *, lbound (b (20:30:3, 40), 1)
if (lbound (b (20:30:3, 40), 1) .ne. 1) call abort
end subroutine test
end program main
(the other tests in the original file succeed).
Thanks for working of this,
Dominique
> What do you think?
>
> Thomas
>
> <matmul-8.diff>
More information about the Fortran
mailing list