Boost logo

Ublas :

From: Manuel González Castro (iinmgc00_at_[hidden])
Date: 2007-03-28 13:01:03


my colleague Francisco is out of the office, so I will answer on behalf

Karl Meerbergen wrote:
> I checked the source code. The symbol copy is defined in
> blas1_overload.hpp, but not in blas1.hpp.
> I recall that copy was not implemented because of the
> availability of std::copy(), which should also work well.
> Do you really want to use blas::copy ?

We use uBLAS as core for our multibody dynamics simulation software. Now
we are comparing high-performance BLAS implementations (ATLAS, GotoBLAS,
ACML, MKL) in terms of efficiency. The bindings helped us a lot: we can
change the BLAS implementation transparently from uBLAS to others.

The copy function is used in bottleneck code, and therefore we suspect
than a fast BLAS implementation, which performs better than std::copy,
can help us.

Since detail::copy functions are already defined in blas1_overload.hpp,
the problem can be solved by adding to blas1.hpp the following code for
the "boost::numeric::bindings::blas::copy" function, it is very similar
to "axpy" in the same file (line #37):

------------- start --------------
  // y <- x
  template < typename vector_type_x, typename vector_type_y >
  void copy(const vector_type_x &x, vector_type_y &y )
    BOOST_STATIC_ASSERT( ( is_same< typename traits::vector_traits<
vector_type_y >::value_type, typename traits::vector_traits<
vector_type_x >::value_type >::value ) ) ;
    BOOST_STATIC_ASSERT( ( is_same< typename vector_type_y::value_type,
typename vector_type_x::value_type >::value ) ) ;
    assert( traits::vector_size( x ) == traits::vector_size( y ) ) ;

    const int n = traits::vector_size( x ) ;
    const int stride_x = traits::vector_stride( x ) ;
    const int stride_y = traits::vector_stride( y ) ;
    const value_type *x_ptr = traits::vector_storage( x ) ;
    value_type *y_ptr = traits::vector_storage( y ) ;

    detail::copy( n, x_ptr, stride_x, y_ptr, stride_y ) ;
------------- end --------------