octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45890] Sparse A*x and A+B are a bit slow


From: Ceral Paquet
Subject: [Octave-bug-tracker] [bug #45890] Sparse A*x and A+B are a bit slow
Date: Sun, 06 Sep 2015 20:39:56 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0

URL:
  <http://savannah.gnu.org/bugs/?45890>

                 Summary: Sparse A*x and A+B are a bit slow
                 Project: GNU Octave
            Submitted by: octavebugs
            Submitted on: Sun 06 Sep 2015 08:39:55 PM GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I just was doing some comparisons of sparse matrix operations and noticed some
seem a bit slower than Matlab. Not serious but kind of odd considering they
are probably using very similar C++ code.

=== Octave results ===
N=1000000 NNZ=20000000 NRUNS=5
 sparse: 2.709228 (0.011811)
 2*A   : 0.222145 (0.000448)
 A'    : 1.776688 (0.044113)
 A+B   : 1.081774 (0.007834)
 A*x   : 0.652453 (0.002009)
 A'*x  : 0.292271 (0.000704)

=== Matlab results ===
N=1000000 NNZ=20000000 NRUNS=5
 sparse: 8.625574 (0.008490)
 2*A   : 0.169647 (0.002336)
 A'    : 2.126985 (0.025129)
 A+B   : 0.543265 (0.001062)
 A*x   : 0.426534 (0.002292)
 A'*x  : 0.290045 (0.001137)

=== Code ===

function prog()

N = 1000000;
NNZ = 20*N;
NRUNS = 5;

for j = 1:NRUNS

r = randi(N,NNZ,1);
c = randi(N,NNZ,1);
v = randn(NNZ,1);
x = randn(N,1);

tic; A = sparse(r,c,v,N,N); t(1,j) = toc;
tic; B = 2*A;               t(2,j) = toc;
tic; A = A';                t(3,j) = toc;
tic; B = A+B;               t(4,j) = toc;
tic; y = A*x;               t(5,j) = toc;
tic; y = A'*x;              t(6,j) = toc;

end

% ignore 1st run
av = mean(t(:,2:end),2);
sd = std(t(:,2:end),0,2);

ver
fprintf('\nN=%i NNZ=%i NRUNS=%i\n',N,NNZ,NRUNS);
fprintf(' sparse: %f (%f)\n', av(1),sd(1))
fprintf(' 2*A   : %f (%f)\n', av(2),sd(2))
fprintf(' A''    : %f (%f)\n',av(3),sd(3))
fprintf(' A+B   : %f (%f)\n', av(4),sd(4))
fprintf(' A*x   : %f (%f)\n', av(5),sd(5))
fprintf(' A''*x  : %f (%f)\n',av(6),sd(6))

end






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45890>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]