Message ID | 55212B5D.6010309@netcologne.de |
---|---|
State | New |
Headers | show |
On 04/05/2015 05:32 AM, Thomas Koenig wrote: --- snip --- > > So, what do you think about this? > > Thomas I am curious about what performance gain results from this? I can see saving a library call to our runtime libraries. Do you have some timing results? Jerry
Hi Jerry, > I am curious about what performance gain results from this? I can see > saving a library call to our runtime libraries. Do you have some timing > results? The speedup can be quite drastic for small matrices which can be completely unrolled by -O3: b1.f90: program main use b2 implicit none real, dimension(3,3) :: a, b, c integer :: i call random_number(a) call random_number(b) do i=1,10**8 c = matmul(a,b) call bar(b,c) end do end program main b2.f90: module b2 contains subroutine bar(b,c) real, dimension(3,3) :: b,c end subroutine bar end module b2 ig25@linux-fd1f:~/Krempel/Matmul> gfortran -O3 -fno-frontend-optimize b2.f90 b1.f90 && time ./a.out real 0m15.411s user 0m15.404s sys 0m0.001s ig25@linux-fd1f:~/Krempel/Matmul> gfortran -O3 b2.f90 b1.f90 && time ./a.out real 0m1.736s user 0m1.735s sys 0m0.001s
On Sun, 2015-04-05 at 14:32 +0200, Thomas Koenig wrote: > Hello world, > > this is a first draft of a patch to inline matmul (PR 37171). This is (FWIW, the above PR# looks like it should be PR 37131)
Index: simplify.c =================================================================== --- simplify.c (Revision 221757) +++ simplify.c (Arbeitskopie) @@ -3445,6 +3445,25 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gf done: + if (!upper && as->type == AS_ASSUMED_SHAPE && dim) + { + if (dim->expr_type == EXPR_CONSTANT) + { + unsigned long int ndim; + gfc_expr *lower, *res; + + ndim = mpz_get_si (dim->value.integer) - 1; + lower = as->lower[ndim]; + if (lower->expr_type == EXPR_CONSTANT) + { + int nkind = mpz_get_si (kind->value.integer); + res = gfc_copy_expr (lower); + res->ts.kind = nkind; + return res; + } + } + } + if (as && (as->type == AS_DEFERRED || as->type == AS_ASSUMED_SHAPE || as->type == AS_ASSUMED_RANK)) return NULL;