yk-choi-yk / cusp-library

Automatically exported from code.google.com/p/cusp-library
Apache License 2.0
0 stars 0 forks source link

Calculation difference between GPU and CPU #99

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm enhancing an algorithm that I implemented in C  . In this algorithm, I use 
the following code for some matrix calculation:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  cusp::transpose(T, Tt);

  cusp::multiply(Tt,i1,Temp1);
  cusp::multiply(Tt,i2,Temp2);
  cusp::multiply(Tt,i3,Temp3);

  cusp::multiply(Tt,T,A);
  cusp::add(G,A,Aux);

  cusp::convergence_monitor<float> monitor1(Temp1, 200, 1e-4);
  cusp::convergence_monitor<float> monitor2(Temp2, 200, 1e-4);
  cusp::convergence_monitor<float> monitor3(Temp3, 200, 1e-4);

  cusp::identity_operator<float,device_memory> M(Aux.num_rows, Aux.num_cols);

  cusp::krylov::bicgstab(Aux, res1, Temp1, monitor1,M);
  monitor1.print();
  cusp::krylov::bicgstab(Aux, res2, Temp2, monitor2,M);
  monitor2.print();
  cusp::krylov::bicgstab(Aux, res3, Temp3, monitor3,M);
  monitor3.print();

///////////////////////////////////////////////////////////////////////////////
Where T and G are large sparse matrix and i1,i2,i3 and res1, res2, res3 are 
vectors. So I tested this part with GPU code using CUSP and the same operations 
using Eigen on CPU. With Eigen, those calculation are done in 14 s on my datas. 
For CUSP, I ve done those calculation in 22.94 s. I though that matrix 
operation are faster on GPU than CPU. May be my implementation is really bad 
(this is my first code on GPU). Do you have advice to speed up this code ?

Your faithfully,

Julien

Original issue reported on code.google.com by StormTur...@gmail.com on 4 Oct 2012 at 8:54