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.

Submitter:  Philipp Kutin <pkutin>
Submitted:  Thu 28 Nov 2013 11:02:12 AM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

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-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.

Philipp Kutin <pkutin>

 

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

Attach Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by pkutin (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-07 lachlan CategoryNone Core : other
    2013-11-28 pkutin Attached 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.14-f13d.
    Corresponding source code