bugGNU Octave - Bugs: bug #60361, division on double data with...

 
 

bug #60361: division on double data with single precision diagonal matrix very slow

Submitted by:  A.R. Burgers <arb>
Submitted on:  Fri 09 Apr 2021 09:41:35 AM UTC  
 
Category:  Performance Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 09 Apr 2021 09:41:35 AM UTC, original submission:  

The script below produces these timings:

double: 0.000715971
single: 1.07861
single (no diag): 0.000701904

division of double data by single diagonal matrix is very slow.
Came across this when using pchip function on double precision x and single precision y. Applying this diff to pchip, avoiding the single precision diagonal matrix, makes pchip a lot faster for the mixed precision case.

<   h = diag (h);
---
>   hr = 1.0 ./ h;
120,122c120,122
<   delta = diff (y, 1, 2) / h;
<   del1 = (d1 - delta) / h;
<   del2 = (d2 - delta) / h;
---
>   delta = diff (y, 1, 2) .* hr;
>   del1 = (d1 - delta) .* hr;
>   del2 = (d2 - delta) .* hr;
125c125
<   c3 /= h;
---
>   c3 .*= hr;

a=rand(1,1500);
a_single = single(a);
b_single=diag(a_single);
b_double=diag(a);
nrep = 100;

tic;
for i = 1 : nrep
  c = a / b_double;
end
fprintf('double: %g\n', toc);

tic;
for i = 1 : nrep
  c = a / b_single;
end
fprintf('single: %g\n', toc);

tic;
for i = 1 : nrep
  c = a ./ a_single;
end
fprintf('single (no diag): %g\n', toc);

A.R. Burgers <arb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.6