Adding/subtracting vectors

Barry Smith bsmith at mcs.anl.gov
Sun Aug 12 21:06:59 CDT 2007


  It checks for the 0 case. Otherwise it passes the operation
directly onto BLAS and assumes that BLAS handles the special 
cases efficiently.

   Barry

Here's the thing. Even if the BLAS implementation provided by the
vector did not handle the special cases if we wrote a 
do/for loop directly to handle the special case it may still 
not be faster than then the BLAs since the BLAS may be tuned
much better then the code the compiler can generate, plus the
cost of AXPY is essentially the cost of the loads and stores
not the multiply adds, eliminating the multiplies might not
save you much.

On Sun, 12 Aug 2007, John R. Wicks wrote:

> It seems that the only way to add two vectors is to use VecAXPY(x,1,y);
> likewise, to subtract one must call VecAXPY(x,-1,y).  Are these routines
> optimized to recognize these special cases to avoid the extraneous scalar
> multiplications?
> 
> 




More information about the petsc-users mailing list