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: Carlo de Falco
Subject: [Octave-bug-tracker] [bug #45890] Sparse A*x and A+B are a bit slow
Date: Tue, 08 Sep 2015 10:30:56 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:40.0) Gecko/20100101 Firefox/40.0

Follow-up Comment #7, bug #45890 (project octave):

FYI here is a comparison of your benchmark using octave's sparse and
sparsersb:



GNU Octave Version: 4.1.0+
prog (@sparsersb)

N=1000000 NNZ=20000000 NRUNS=5
 sparse: 0.733759 (0.023204)
 2*A   : 0.023806 (0.000919)
 A'    : 0.049507 (0.001497)
 A+B   : 0.028259 (0.002406)
 A*x   : 0.003106 (0.000072)
 A'*x  : 0.024023 (0.001079)


GNU Octave Version: 4.1.0+
prog (@sparse)

N=1000000 NNZ=20000000 NRUNS=5
 sparse: 1.120718 (0.011892)
 2*A   : 0.002711 (0.000525)
 A'    : 0.002250 (0.000305)
 A+B   : 0.007880 (0.000594)
 A*x   : 0.005876 (0.000045)
 A'*x  : 0.003467 (0.000029)



In order to run these tests I modified your
benchmark code as follows:


function prog (sparsefun = @sparse)

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 = sparsefun (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]