[Top][All Lists]

[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


                 Summary: interpreter: static instead of dynamic casts for
                 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




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

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 ()
        for i = 1:10e6
                i = 0.5 * i / 0.9 + 1 - 8;

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



Reply to this item at:


  Message sent via Savannah

reply via email to

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