[gfortran,patch] MATMUL using BLAS gemm routines
François-Xavier Coudert
fxcoudert@gmail.com
Mon Sep 25 08:56:00 GMT 2006
Hi all,
I've come up with another idea to implement the optional use of BLAS
gemm routines for gfortran MATMULtiplication. I still have some
testing and fine-tuning to do (using lots of different vendor BLAS
libraries, like IBM's ESSL, Intel MKL, etc), but here's the current
version of the patch anyhow, along with some explanations of how it
works. I think this approach is simple, easy to use and understand,
and opens the way for modification of other array routines.
Here's how it works: the library function libgfortran_matmul_r8 (I
included this generated file in the diff, because it's easier to read
than m4 for some of us :) gets 3 new arguments: int try_blas, which
tells it if a BLAS call should be made if possible; int blas_limit,
the size above which BLAS will be used; and gemm, a pointer to the
BLAS function to be called.
The front-end function gfc_conv_function_call() is added an extra
argument, append_args, which is a list of tree args to be appended at
the end of the function call. All calls to gfc_conv_function_call() in
the front-end set append_args = NULL_TREE. The one exception is
gfc_conv_intrinsic_funcall() which, if it's translating a MATMUL call
(recognized by its expr->value.function.isym->generic_id), appends the
three arguments we talked about earlier (try_blas, blas_limit and
function pointer).
One note: I would have liked to special case the MATMUL calls right
inside gfc_conv_function_call(), but I didn't find a way to recognize
them there. The good thing about the new append_args mechanism is that
we could use it for other things, like passing flags about runtime
bounds-checking.
Another note: it is assumed that sgemm is for default real kind, dgemm
for double precision real kind, and likewise for complex routines. If
you feel I should hardcode sgemm to real(kind=4) and dgemm to
real(kind=8), or provide a flag for the user to specify the mapping,
please say so.
I'm open to all suggestions before I finalize the patch and submit it
formally next saturday. After submission, I unfortunately won't have
time to change it significantly any more.
Thanks for reading this long mail,
FX
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blas_matmul2.diff
Type: text/x-patch
Size: 17019 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060925/c4a562df/attachment.bin>
More information about the Fortran
mailing list