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

 
 

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

Submitter:  A.R. Burgers <arb>
Submitted:  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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code