[fortran,patch] BLAS-enabled matmul

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Tue Apr 4 07:29:00 GMT 2006


> Now there's one thing slightly subtle about all this: suppose a user 
> compiles some code that calls DGEMM, and forgets to link in his favorite 
> BLAS library. Well, the program will compile and link fine, because we 
> provided a symbol called dgemm_ in our libgfortran_blas library. But 
> since this later is only a minimalist implementation, it does not handle 
> all possibles cases (for example, it asserts that alpha=1 and beta=0), 
> so this is very bad.

My solution would be to not provide stripped down BLAS implementation in 
libgfortran, but simply compile two different versions of libgfortran: 
once for BLAS using the same code as now, and once for no BLAS using 
DGEMM.  Chances are that the current code is even better than the netlib 
BLAS, and it costs nothing to keep the current code.

Then, instead of having -fexternal-blas="aaa", just have -fblas (linking 
-lgfortran_blas) vs. -fno-blas (linking -lgfortran).  It's up to the 
user to link in a suitable BLAS library, or he/she will get undefined 
references.  The default is obviously -fno-blas, and I can see people 
writing configure tests like:

AC_CHECK_LIB (atlas, dgemm_,
[FFLAGS="$FFLAGS -fblas -llapack -lcblas -lf77blas -latlas"], [],
[-llapack -lcblas -lf77blas])

Paolo



More information about the Gcc-patches mailing list