[SciPy-User] Speed-up simple function
Nicolau Werneck
nwerneck at gmail.com
Mon Jan 10 12:57:18 EST 2011
Great suggestion. I have tried just modifying the original numpy
expression replacing the S**1.5 for S*sqrt(S), and just by doing that
I already got a 2x speedup.
In the Cython version, using S*sqrt(S) gives a 7.3 speedup. Much
better than using exponentiation. Using the approximate rsqrt will
probably bring that closer to 10x.
++nic
On Mon, Jan 10, 2011 at 10:30:57AM -0700, Charles R Harris wrote:
> On Mon, Jan 10, 2011 at 10:22 AM, Nicolau Werneck <nwerneck at gmail.com>
> wrote:
>
> That is one excellent suggestion, using multiple cores is probably the
> best thing to do. I have tried a basic Cython implementation (because
> it's such a basic and interesting problem), but I couldn't yet reach a
> speedup of even 2.0.
>
> The big villain in the expression is the 'S**1.5'. Removing that from
> my Cython code gives a 12x speedup. Avoiding that exponentiation can
> be probably beneficial to other techniques too...
>
> The square root itself should be fast so I suspect that a log is being
> used. What happens if you use S*sqrt(S) instead?
>
> <snip>
>
> Chuck
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
--
Nicolau Werneck <nwerneck at gmail.com> C3CF E29F 5350 5DAA 3705
http://www.lti.pcs.usp.br/~nwerneck 7B9E D6C4 37BB DA64 6F15
Linux user #460716
"I wanted to change the world. But I have found that the only thing one can be sure of changing is oneself."
-- Aldous Huxley
More information about the SciPy-User
mailing list