[Numpy-discussion] UFUNC_CHECK_STATUS cpu hog
Thomas Grill
grrrr.org@gmail....
Sat Mar 1 19:56:04 CST 2008
Hi all,
i did some profiling on OS X/Intel 10.5 (numpy 1.0.4) and was
surprised to find calls to the system function feclearexcept to be by
far the biggest cpu hog, taking away about 30% of the cpu in my case.
Would it be possible to change UFUNC_CHECK_STATUS in ufuncobject.h in
a way that feclearexcept is only called when necessary (fpstatus !=
0), like in
ufuncobject.h, line 292....
#define UFUNC_CHECK_STATUS(ret)
{ \
int fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW | \
FE_UNDERFLOW | FE_INVALID); \
if(__builtin_expect(fpstatus,0)) \
ret = 0; \
else { \
ret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO :
0) \
| ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \
| ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \
| ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \
(void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW | \
FE_UNDERFLOW | FE_INVALID); \
} \
}
greetings, Thomas
--
Thomas Grill
http://grrrr.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2407 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080302/f168ef98/attachment.bin
More information about the Numpy-discussion
mailing list