Boost logo

Ublas :

Subject: Re: [ublas] question about a binding of ublas
From: Kaveh Kohan (kaveh.kohan_at_[hidden])
Date: 2010-11-02 14:54:20

Hi Rutger,

Thank you very much for your reply.

I think the version of boost I am using is quite old (1.35.0) and it seems that
there have been significant changes with respect to the current version (is it
1.6?). For example I came to realize and you also pointed out that atlas is not
a binding anymore and it seems that its functionalities are provided via BLAS
and LAPACK bindings as you said. Now my question is that do we need to link with to use the functionalities or in enough (in case one
wants to use ATLAS).

Here is my specific question:
Please correct me if I am wrong but it seems that there is a significant
performance difference between, for example, matrix-matrix multiplication if one
uses ublas comparing to atlas. Here is an example I am using to compare them:

kaevh_at_kavehpc:~/code/test_folder/cpp_test/boost_test1$ g++ test1.cpp -o test1
-Wall -O3 -DNDEBUG -lcblas
kaevh_at_kavehpc:~/code/test_folder/cpp_test/boost_test1$ ./test1 1000 1000 1000
ublas default implementation in blas
Time : 1.77262
default implementation in atlas
Time : 0.519718

------------------------------------------------ CODE
#include <iostream>
//#include <valarray>

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/timer.hpp>

#include <boost/numeric/bindings/atlas/cblas3.hpp>
#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
namespace atlas = boost::numeric::bindings::atlas;

# include <sys/time.h>

namespace ublas = boost::numeric::ublas;
using namespace std;

double gettime() {
struct timeval t;
gettimeofday(&t, NULL);
return (double)t.tv_sec+t.tv_usec*0.000001;

void initmatrix(ublas::matrix<double>& A) {
 for(size_t i = 0; i<A.size1(); i++)
  for(size_t j = 0; j<A.size2(); j++)
   A(i,j) = 1.0*rand();
void initmatrix(ublas::matrix<double,ublas::column_major>& A) {
 for(size_t i = 0; i<A.size1(); i++)
  for(size_t j = 0; j<A.size2(); j++)
   A(i,j) = 1.0*rand();

int main(int argc, char *argv[])
long int D,r,n ;

//std::clock_t start;
//double diff;
double t1,t2 ;

//D = 1000 ;
D = atoi(argv[1]) ;
//r = 1000 ;
r = atoi(argv[2]) ;
//n = 1000 ;
n = atoi(argv[3]) ;

   cout << "ublas ";

   ublas::matrix<double> A(D,r);
   ublas::matrix<double,ublas::column_major> B(r,n);
   ublas::matrix<double> X(D,n);

   cout << "default implementation in blas" << endl ;
   t1 = gettime() ;
   //X = ublas::prod< ublas::matrix<double> >(A,B);
   noalias(X) = ublas::prod(A,B) ;
   t2 = gettime() ;
   cout << "Time : " << t2 - t1 << endl;


    ublas::matrix<double, ublas::column_major> A(D,r),B(r,n),C(D,n);
   cout << "default implementation in atlas" << endl ;
   t1 = gettime() ;
   t2 = gettime() ;
   cout << "Time : " << t2 - t1 << endl;


From: Rutger ter Borg <rutger_at_[hidden]>
To: ublas_at_[hidden]
Sent: Tue, November 2, 2010 3:42:37 AM
Subject: Re: [ublas] question about a binding of ublas

On 2010-11-02 04:12, Kaveh Kohan wrote:
> Hi Everyone,
> I would be thankful if anyone direct me to any documentation about
> bindings of ublas, more specifically I would like to know available
> functionalities available in atlas binding of the ublas. Unfortunately,
> I was unable to find them by googeling!
> Thanks,
> Kaveh

erm... I'll try that again.

Documentation is progressing slowly, and is at

The bindings themselves may be checked out with subversion at

ATLAS is supported through the BLAS bindings interface, enable them by

ATLAS' lapack functionality is supported, too, through the LAPACK
interface, enable them by defining BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK



ublas mailing list
Sent to: kaveh.kohan_at_[hidden]