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

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

[Octave-bug-tracker] [bug #60361] division on double data with single pr


From: A.R. Burgers
Subject: [Octave-bug-tracker] [bug #60361] division on double data with single precision diagonal matrix very slow
Date: Fri, 9 Apr 2021 05:41:37 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36 Edg/89.0.774.48

URL:
  <https://savannah.gnu.org/bugs/?60361>

                 Summary: division on double data with single precision
diagonal matrix very slow
                 Project: GNU Octave
            Submitted by: 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: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60361>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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