bugGNU Octave - Bugs: bug #49667, Computing integer powers of...

 
 

bug #49667: Computing integer powers of complex numbers in 4.2.0 is slower than in 4.0.3 with GCC 4.8

Submitted by:  Marco Caliari <caliari>
Submitted on:  Tue 22 Nov 2016 09:13:13 AM UTC  
 
Category: PerformanceSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Performance
Status: Wont FixAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.2.0Operating System: GNU/Linux

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)

Wed 23 Nov 2016 06:12:01 PM UTC, comment #7:

The PPA is a backport of whatever is in the development release. So once 4.2.0 appears in the "zesty" release or whatever comes after, then I will backport it into the PPA. And it probably will have this problem, unless there is an easy way to pull in a newer gcc.

Mike Miller <mtmiller>
Project Administrator
Wed 23 Nov 2016 07:59:13 AM UTC, comment #6:

Mike, I agree with your analysis. Are you going to make a PPA version for Ubuntu 14.04? In that case, will it have the same problem?

Marco Caliari <caliari>
Project Member
Tue 22 Nov 2016 08:22:04 PM UTC, comment #5:

Correct, I believe it is because the std::pow(std::complex<T>, int) overload was conditionally compiled out of existence in earlier versions of gcc when using the -std=gnu++11 or -std=gnu++0x command-line option, but was available when building in (previously the default) C++98 mode.

With gcc 5, the specialization was reinstated when building in C++11 mode, and the performance is as it was.

I think a user on Ubuntu 14.04 or Mint 17 could confirm this by using gdb or perf and showing that the inline function std::__complex_pow_unsigned is not being called at all. But I've looked at this for about a half hour now and I'm pretty convinced by inspection that this is the case.

Mike Miller <mtmiller>
Project Administrator
Tue 22 Nov 2016 08:05:52 PM UTC, comment #4:

So the problem only appears if using an older GCC? In that case, I don't think there is anything we should do about this problem in Octave.

John W. Eaton <jwe>
Project Administrator
Tue 22 Nov 2016 07:51:32 PM UTC, comment #3:

Avinoam - I think it's pretty clear this is related to the older toolchain on Ubuntu 14.04 / Mint 17, but thanks for confirming anyway.

Related: http://stackoverflow.com/q/5627030/384593, bug #38142

Compare the definition of std::pow(std::complex<double>, int) in gcc 4.8.4 (the version in Ubuntu 14.04)

https://github.com/gcc-mirror/gcc/blob/gcc-4_8_4-release/libstdc%2B%2B-v3/include/std/complex#L975

with the same function in gcc 5 / 6

https://github.com/gcc-mirror/gcc/blob/gcc-5_1_0-release/libstdc%2B%2B-v3/include/std/complex#L976

So yes, I would say that this performance degradation is a defect in gcc 4.8 running in C++11 mode.

Mike Miller <mtmiller>
Project Administrator
Tue 22 Nov 2016 07:29:44 PM UTC, comment #2:

Checking on Win-10 32 bit:

4.0.3:

4.2.0:

There is no noticeable difference.

Avinoam Kalma <avinoam>
Project Member
Tue 22 Nov 2016 07:11:40 PM UTC, comment #1:

If it's only a problem on Ubuntu 14.04 / Mint 17, then it looks like you are arguing that it's not an Octave bug. It's very possible that some of the C++11 math functions that we started using in 4.2 have some problems with an older toolchain of gcc/libc/libm/libstdc++. Maybe using perf or valgrind --tool=callgrind can help shed some light on what underlying library calls are different for you between 4.0 and 4.2. That might help demonstrate that it is the system libraries to blame for the performance difference, not necessarily that we may do anything about this in Octave.

For what it's worth, on Debian with gcc 6 and glibc 2.24, I get just about identical performance between 3.6.4 and 4.2.0.

Mike Miller <mtmiller>
Project Administrator
Tue 22 Nov 2016 09:13:13 AM UTC, original submission:

Dear all,

I compiled from scratch 4.0.3 and 4.2.0 and observe the following

So, it seems that integer powers of complex numbers are now treated as double powers. I'm on Mint 17.3 (Ubuntu 14.04). A user in chat showed me that 4.2.0 behaves like 4.0.3 on Ubuntu 16.04. So, it is an Ubuntu 14.04 related problem.

Marco Caliari <caliari>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

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 avinoam (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by caliari (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 project members can vote.

     

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

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 22 Nov 2016 09:36:57 PM UTCmtmillerOpen/ClosedOpen=>Closed
      SummaryComputing powers of complex numbers in 4.2.0 is slower than in 4.0.3=>Computing integer powers of complex numbers in 4.2.0 is slower than in 4.0.3 with GCC 4.8
    Tue 22 Nov 2016 09:36:56 PM UTCmtmillerStatusNeed Info=>Wont Fix
    Tue 22 Nov 2016 07:11:40 PM UTCmtmillerItem GroupRegression=>Performance
      StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1