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

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

[Octave-patch-tracker] [patch #8248] In (element-wise) power op. functio


From: Philipp Kutin
Subject: [Octave-patch-tracker] [patch #8248] In (element-wise) power op. functions, do range check before casting to int.
Date: Thu, 28 Nov 2013 11:02:13 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0

URL:
  <http://savannah.gnu.org/patch/?8248>

                 Summary: In (element-wise) power op. functions, do range
check before casting to int.
                 Project: GNU Octave
            Submitted by: pkutin
            Submitted on: Thu 28 Nov 2013 11:02:12 AM GMT
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

* lo-mappers.h: add two "fits-into-int" predicates, one symmetric
  [INT_MIN+1, INT_MAX], the other "regular" [INT_MIN, INT_MAX].
* *xpow.cc, op-s*m-s.cc: use them where appropriate.

----------

As discussed in
https://mailman.cae.wisc.edu/pipermail/octave-maintainers/2013-November/037580.html

Notes:

- Cases where xisint() was used were not touched as they are already correct
(but may be a little too strict). This is for ease of review, plus my
understanding is that the interpreter has now to be kept in sync with the JIT
compiler. Thus, no well-defined behavior should have been changed.
- I only tested an Octave-default build *without* the JIT compiler, as that
one gave build errors for an LLVM from SVN (is Octave following a particular
LLVM build, such as one available with a distro's package management?)
- The predicates use ceil() as that one is declared inline (see below)

Additional attachments:

- xpow_tests.m: an annotated M script containing Sanitizer output before the
cleanup and some other annotations
- xisint.cc: a very simple C++ test file for timing the predicates when run in
a loop. Results: inlining seems to give a noticeable speedup (hence ceil()),
my versions compile to somewhat shorter code.

xpow_test.m also shows something curious: running
 a = -single([1,2;3,4]); b=single([1 1; 1 2^32]); a.^b
calls the
 (const FloatNDArray& a, const FloatNDArray& b)
overload, not the FloatMatrix one. Not a big deal I guess, since the former is
more general, but maybe noteworthy.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 28 Nov 2013 11:02:12 AM GMT  Name: pow-range-checks.patch  Size: 7kB
  By: pkutin

<http://savannah.gnu.org/patch/download.php?file_id=29725>
-------------------------------------------------------
Date: Thu 28 Nov 2013 11:02:12 AM GMT  Name: xisint.cc  Size: 2kB   By: pkutin

<http://savannah.gnu.org/patch/download.php?file_id=29726>
-------------------------------------------------------
Date: Thu 28 Nov 2013 11:02:12 AM GMT  Name: xpow_tests.m  Size: 6kB   By:
pkutin

<http://savannah.gnu.org/patch/download.php?file_id=29727>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8248>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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