Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-10-10 12:31:51

On Tuesday 10 October 2006 15:05, Vadim Zborovskii wrote:
> In the Fortran90 this is done straightforward
> DO I=1,N
> K1=IA(I)
> K2=IA(I+1)-1
> Y(I)=DOTPRODUCT(A(K1:K2),X(JA(K1:K2)))

This code is nice, but unfortunately very special. Thus the general ublas
prod(A,x) and g++ can not produce the same short routine. If you really want
the same efficiency you have to write a specialized version of you products.
Good references are the axpy_prod() in operation.hpp.

> I'd like to know whether this kind of optimization is done for uBlas.
> I've compiled the corresponding code with gcc
> using -O2 and -DNDEBUG but the resulting assembler code seemed too
> complex for me. So I suspect that the variables analogous to K1 and K2
> are computed in the inner loop too. Am I right ? Is this optimization
> done by compilers other than gcc?

AFAIK the are very few compilers that are good in this field. The best I saw
was KAI which was bought by intel an disappeared. icc usually gives better
results than gcc (if it compiles). Maybe someone else knows more.