Math calls to libc-2.23 compiled with g++ 5.3.1 (Ubuntu 16.04) process 2.5 time slower compared to libc-2.19 compiled with g++ 4.8.4 (Ubuntu 14.04)

Bug #1598618 reported by Alex
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

I started to use Ubuntu 16.04 with gcc 5.3.1-14ubuntu2.1, libc 2.23-0ubuntu3.
And I wrote a simple program:

#include <cmath>
#include <iostream>
#include <chrono>

#define CYCLE_NUM 1E+7

using namespace std;
using namespace std::chrono;

int main()
{
    double sum = 0.0;

    auto t1 = high_resolution_clock::now();
    for(int i = 1; i < CYCLE_NUM; i++)
    {
        sum += sin((double)(i)) / (double)(i);
    }
    auto t2 = high_resolution_clock::now();

    microseconds::rep t = duration_cast<microseconds>(t2-t1).count();

    cout << "sum = " << sum << endl;
    cout << "time = " << (double)(t) / 1.E+6 << endl;

    return 0;
}

which compiled with command:

g++ -std=c++11 -O3 main.cpp -o sum

This program work 2.5 times slower than the same program in Ubuntu 14.04.3 with gcc 4.8.4 libc-2.19 compiled with the same command.

I've tried to compile the same code in VS C++ 2015 with the same level of optimization and I've got almost the same time as I've got in Ubuntu 14.04 (gcc 4.8.4 libc-2.19).

My proc is i7-5820, haswell.

It seems that math functions (no only sin, also cos, exp) now process significantly slower compared to older versions of c++ libraries or compiler.

I've created topic on stackoverflow.com :
http://stackoverflow.com/questions/38172066/the-program-works-3-times-slower-compiled-with-g-5-3-1-than-the-same-program-c

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: libc-bin 2.23-0ubuntu3
ProcVersionSignature: Ubuntu 4.4.0-28.47-generic 4.4.13
Uname: Linux 4.4.0-28-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia_modeset nvidia
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: Unity
Date: Sun Jul 3 23:24:33 2016
Dependencies:
 gcc-6-base 6.0.1-0ubuntu1
 libc6 2.23-0ubuntu3
 libgcc1 1:6.0.1-0ubuntu1
InstallationDate: Installed on 2016-07-02 (1 days ago)
InstallationMedia: Ubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
SourcePackage: glibc
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Alex (mediev) wrote :
Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

I am going to mark this as a duplicate of https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1663280 even though you reported the bug significantly earlier. The other bug reported has a bunch of additional information, though, and it has explanations and workarounds.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.