This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/13932] x86_64 pow unexpectedly slow for some inputs
- From: "manu at gcc dot gnu.org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 13 Dec 2012 16:44:21 +0000
- Subject: [Bug math/13932] x86_64 pow unexpectedly slow for some inputs
- Auto-submitted: auto-generated
- References: <bug-13932-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=13932
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #1 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-12-13 16:44:21 UTC ---
I can still reproduce it with 2.12
GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.6 20120305 (Red Hat 4.4.6-4).
Compiled on a Linux 2.6.32 system on 2012-07-18.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
A testcase:
#include <math.h>
#ifndef POW
#define POW pow
#endif
#define N 1500
int total[N][N];
double alpha = 2.81;
int n = N;
int main(int argc, char *argv[])
{
int x = 30976397;
x += 0;
double trail = 1. / ( (double) N * (double) x) ;
long i,j;
for ( i = 0 ; i < N ; i++ ) {
for ( j = 0 ; j < i ; j++ ) {
total[i][j] = POW(trail, alpha);
}
}
return 0;
}
$ gcc -o slowpow slowpow.c -lm
$ /usr/bin/time ./slowpow
213.75user 0.04system 3:34.27elapsed 99%CPU (0avgtext+0avgdata
12784maxresident)k
0inputs+0outputs (0major+838minor)pagefaults 0swaps
(Interrupted, it was running forever)
$ gcc -DPOW=powl -o slowpow slowpow.c -lm
$ /usr/bin/time ./slowpow
0.20user 0.01system 0:00.22elapsed 98%CPU (0avgtext+0avgdata 35040maxresident)k
0inputs+0outputs (0major+2229minor)pagefaults 0swaps
$ gcc -DPOW=powf -o slowpow slowpow.c -lm
$ /usr/bin/time ./slowpow
0.23user 0.01system 0:00.25elapsed 95%CPU (0avgtext+0avgdata 35088maxresident)k
160inputs+0outputs (1major+2231minor)pagefaults 0swaps
At least, it would be nice if the man page mentioned this issue and what kind
of inputs may lead to it. It causes a lot of frustration:
http://entropymine.com/imageworsener/slowpow/
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.