patchGNU Octave - Patches: patch #8248, In (element-wise) power op....

 
 

patch #8248: In (element-wise) power op. functions, do range check before casting to int.

Submitted by:  Philipp Kutin <pkutin>
Submitted on:  Thu 28 Nov 2013 11:02:12 AM UTC  
 
Category: NonePriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 28 Nov 2013 11:02:12 AM UTC, original submission:
  • 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-sm-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.

Philipp Kutin <pkutin>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #29725:  pow-range-checks.patch added by pkutin (7kB - text/x-patch)
file #29726:  xisint.cc added by pkutin (2kB - text/x-c++src)
file #29727:  xpow_tests.m added by pkutin (6kB - application/vnd.wolfram.mathematica.package)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by pkutin (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 28 Nov 2013 11:02:12 AM UTCpkutinAttached File-=>Added pow-range-checks.patch, #29725
      Attached File-=>Added xisint.cc, #29726
      Attached File-=>Added xpow_tests.m, #29727

    Back to the top


    Powered by Savane 3.1-cleanup