[Numpy-discussion] Vectorizing code, for loops, and all that
Albert Strasheim
fullung at gmail.com
Tue Oct 3 04:12:02 CDT 2006
Hello all
> -----Original Message-----
> From: Travis Oliphant [mailto:oliphant at ee.byu.edu]
> Sent: 03 October 2006 03:51
> To: Discussion of Numerical Python; Albert Strasheim
> Subject: Re: ***[Possible UCE]*** Re: [Numpy-discussion] Vectorizing code,
> for loops, and all that
>
> <snip>
> >Meanwhile, I can confirm that the NOBUFFER_UFUNCLOOP case in
> >PyUFunc_GenericFunction is getting exercised in the slower case. Here's
> some
> >info on what's happening, courtesy of Rational Quantify:
> >
> >case NOBUFFER_UFUNCLOOP:
> >while (loop->index < loop->size) {
> > for (i=0; i<self->nargs; i++)
> > loop->bufptr[i] = loop->iters[i]->dataptr; [1]
> >
> > loop->function((char **)loop->bufptr, &(loop->bufcnt),
> > loop->steps, loop->funcdata); [2]
> > UFUNC_CHECK_ERROR(loop);
> >
> > for (i=0; i<self->nargs; i++) {
> > PyArray_ITER_NEXT(loop->iters[i]); [3]
> > }
> > loop->index++;
> >}
> >break;
> >
> >[1] 12.97% of function time
> >[2] 8.65% of functiont ime
> >[3] 62.14% of function time
> >
> >If statistics from elsewhere in the code would be helpful, let me know,
> and
> >I'll see if I can convince Quantify to cough it up.
> >
> Please run the same test but using
>
> x1 = N.random.rand(39,2000)
> x2 = N.random.rand(39,64,1)
>
> z1 = x1[:,N.newaxis,:] - x2
Very similar results to what I had previously:
[1] 10.88%
[2] 7.25%
[3] 68.25%
Cheers,
Albert
More information about the Numpy-discussion
mailing list