Expression templates

Christian Kamm kamm at nospam.de
Thu Dec 14 02:04:36 PST 2006


> I'm making some headway on an nd-array class that uses BLAS/LAPACK under  
> the hood. It would be nifty if I could somehow get this:
>
>       R = A * x + y
>
> to be groked and translated to a single call to of BLAS's  
> saxpy/daxpy/caxpy/zaxpy routines.

This would be fabulous! (and shouldn't it work similarly to the way Don's  
code detects constant folding? If there's a matrix-vector product and one  
uses opAdd with another vector, modify the call to xGEMV accordingly)
I would definitely use something that makes accessing the BLAS routines as  
easy as that. It should also be possible to automatically use the calls  
for symmetric, hermitian, etc. matrices, if the matrix type reflects these  
properties...

> The theory with BLAS anyway, is that you'll have access to a hand-tuned  
> version for the platform you're on, so it'll be hard to beat with any  
> kind of register-level compile-time micromanagement.

I agree. Writing near-optimal assembler code might be doable for vector  
operations (and a pretty cool thing too), but for matrix-vector and  
matrix-matrix operations, I'd go with the functions from BLAS level 2 and  
3.

Please keep us updated on your progress or make it a project on dsource -  
I'd want to check it out and contribute, if time allows.

Cheers,
Christian



More information about the Digitalmars-d mailing list