[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #10139] interpreter: static instead of dyn
From: |
Petter Tomner |
Subject: |
[Octave-patch-tracker] [patch #10139] interpreter: static instead of dynamic casts for speed |
Date: |
Sun, 21 Nov 2021 11:56:23 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 |
URL:
<https://savannah.gnu.org/patch/?10139>
Summary: interpreter: static instead of dynamic casts for
speed
Project: GNU Octave
Submitted by: petter
Submitted on: Sun 21 Nov 2021 04:56:21 PM UTC
Category: Core : other
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Hi!
I've made a patch trying to speed up the interpreter by replacing dynamic_cast
with static_cast.
I added a configure flag "--enable-internal-checks" which could be used to
enable expensive runtime checks.
In ops.h I added a macro DYNORSTAT_CAST that is static_cast by default and
dynamic_cast if Octave is built with "internal-checks".
In the operator cc-files a changed all the dynamic_cast of references to
DYNORSTAT_CAST.
As I understand the code, the objects used by the operators are not supposed
to be of the wrong kind. A std::bad_cast is thrown currently which terminates
Octave, if that is the case, but with this patch any type error would silently
corrupt memory etc.
For scalar heavy code with many ops the speedup is quite substantial. E.g.
some silly:
function i = foo ()
tic;
for i = 1:10e6
i = 0.5 * i / 0.9 + 1 - 8;
end
toc;
end
Has a speedup of about 15% on my machine.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Sun 21 Nov 2021 04:56:21 PM UTC Name: staticcast_tomner.patch Size:
231KiB By: petter
<http://savannah.gnu.org/patch/download.php?file_id=52315>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/patch/?10139>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-patch-tracker] [patch #10139] interpreter: static instead of dynamic casts for speed,
Petter Tomner <=