bugGNU Octave - Bugs: bug #51630, BIST test for log2 fails on Windows

 
 

bug #51630: BIST test for log2 fails on Windows

Submitted by:  Markus Mützel <mmuetzel>
Submitted on:  Mon 31 Jul 2017 05:56:07 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Fri 04 Aug 2017 10:57:54 PM UTC, comment #13:

It can be MSVC, it can also be MinGW's libc.

Both are listed in gnulib as having this specific problem.

Rik <rik5>
Project Administrator
Fri 04 Aug 2017 10:52:45 PM UTC, comment #12:

What provides the standard library function? Is that ultimately a MSVC runtime function?

John W. Eaton <jwe>
Project Administrator
Fri 04 Aug 2017 04:42:50 PM UTC, comment #11:

I am getting strange readings with your test script on Windows.
Running with hg id e56d84a16a2e (frexp from the standard lib), I see:

With hg id 9401e88f63cf (gnulib):

So it executes actually about 8% faster with gnulib than with the standard library function (unless something else overcompensated the slowdown between these changesets). Both examples run with the same vector of 10e6 random doubles.

Markus Mützel <mmuetzel>
Project Member
Wed 02 Aug 2017 04:12:41 PM UTC, comment #10:

@Markus: It might very well be faster. I have uploaded the benchmark script that I used. I'm super busy right now, however, and can't tackle this project myself.

(file #41392)

Rik <rik5>
Project Administrator
Wed 02 Aug 2017 03:11:43 PM UTC, comment #9:

I finished running the test suite on Windows (hg id 9401e88f63cf) and it no longer fails these tests.

Might the approach that Dan suggested be faster (and desired)? Write our own wrapper function for frexp that returns early for +/-Inf (on Windows only) and calls std::frexp otherwise. Or include that logic in log2?

Markus Mützel <mmuetzel>
Project Member
Wed 02 Aug 2017 03:55:42 AM UTC, comment #8:

It's a bummer, but I did some benchmarking and going through gnulib is definitely slower. Perhaps because there is still at least one pointer indirection.

Results:

It's a 42% decrease in runtime from 160 milliseconds to 92 milliseconds. This was on a 10e6 point vector. Maybe it would be worth it to have special code at some point to detect MingW or MSVC in the configure script. I guess that can happen later if we ever get around to it.

Rik <rik5>
Project Administrator
Tue 01 Aug 2017 05:52:03 PM UTC, comment #7:

Fwiw, using g++.exe that comes with MXE Octave, I get:
I also tried to cross-compile with mingw-g++ on Ubuntu 17.04 (gcc 6.2.1) with the same result.

And for completeness as in the BIST test, the result for log2 (0) is:

I am cross-compiling Octave right now and will run the test suite again.

Markus Mützel <mmuetzel>
Project Member
Mon 31 Jul 2017 08:57:29 PM UTC, comment #6:

Reverted here (http://hg.savannah.gnu.org/hgweb/octave/rev/4d11ada80395). Closing report.

Rik <rik5>
Project Administrator
Mon 31 Jul 2017 08:56:39 PM UTC, comment #5:

Checking with gnulib about frexp (https://www.gnu.org/software/gnulib/manual/html_node/frexp.html#frexp) one of the specific things it fixes is

So, it seems to be a known problem with mingw. Grrr. I'll revert the changeset. It shouldn't matter for good systems (like Linux) where gnulib will detect that the C library version is okay and not replace the function.

Rik <rik5>
Project Administrator
Mon 31 Jul 2017 07:46:06 PM UTC, comment #4:

Sorry, I meant log2(0), which is supposed to return 0 0 according to documentation (note I had f/e backward in my original post):

Dan Sebald <sebald>
Mon 31 Jul 2017 07:23:19 PM UTC, comment #3:

Windows returns the same like I get in Linux:

Yes, we could handle +/-Inf conditionally (maybe for Windows only?). But isn't that what gnulib is for?
Maybe it would also help to use a newer gcc? gcc 4.9.4 seems to be out of support now. My "native" gcc is version 6.3.0 on Ubuntu 17.04.
I don't know which "implementation" is referred to by the cppreference site. The compiler? The C libraries? The OS?

Markus Mützel <mmuetzel>
Project Member
Mon 31 Jul 2017 07:08:07 PM UTC, comment #2:

I really hate coding for Windows!

Odds are that this is related to the switch to using frexp from the std library.

According to the reference you provide, while the exponent is implementation dependent, the argument is not and should be Inf. This points to a potential bug upstream in the C library on the platform you are using. Where is the C library coming from? Do we ship that with MXE, is it coming from MingGW, or is it provided by Microsoft?

The following C++ program can be compiled stand-alone to see what the C library returns.

Rik <rik5>
Project Administrator
Mon 31 Jul 2017 06:49:01 PM UTC, comment #1:

An alternative would be to conditionally handle log(x) for the cases of x = +/-Inf.

What does [e f] = log(0) produce in Windows?

Dan Sebald <sebald>
Mon 31 Jul 2017 05:56:07 PM UTC, original submission:

The BIST test for log2 is failing on Windows since a few weeks (tested with hg id e56d84a16a2e):

CC'ing Rik because this might be related to the recent change to use standard library functions:
http://hg.savannah.gnu.org/hgweb/octave/rev/4c048a2792bc

Calling "log2" with one or two output argument gives these results on Windows:

The same on Linux (correct):

The results when calling with one output argument are correct.
The results with two output arguments (effectively calling frexp) fail on Windows.
With 4.2.1 (and a dev build from March I found on my disk, hg id a470f7fee1cf), the results were still correct on Windows.
Should we return to use gnulib for frexp?

According to [1], behaviour for +/-Inf is implementation specific. Is mingw/gcc/glibc/Windows not IEC 60559 compliant?

[1] http://en.cppreference.com/w/cpp/numeric/math/frexp

Markus Mützel <mmuetzel>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #41392:  bm_log2.m added by rik5 (316B - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by sebald (Posted a comment)
  • -unavailable- added by mmuetzel (Submitted the item)
  • -unavailable- added by mmuetzel
  •  

    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 project members can vote.

     

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

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 02 Aug 2017 04:12:41 PM UTCrik5Attached File-=>Added bm_log2.m, #41392
    Mon 31 Jul 2017 08:57:29 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Mon 31 Jul 2017 05:56:07 PM UTCmmuetzelCarbon-Copy-=>Added rik5

    Back to the top


    Powered by Savane 3.1-cleanup1