[Numpy-discussion] Threading question for Travis

Charles R Harris charlesr.harris@gmail....
Sat Apr 26 19:25:28 CDT 2008


On Sat, Apr 26, 2008 at 11:21 AM, Travis E. Oliphant <oliphant@enthought.com>
wrote:

> Charles R Harris wrote:
> > Travis,
> >
> > Is this correct?
> >
> Yes.
> >     NPY_LOOP_BEGIN_THREADS;
> >     switch(loop->meth) {
> >     case ONE_UFUNCLOOP:
> >         /*
> >          * Everything is contiguous, notswapped, aligned,
> >          * and of the right type.  -- Fastest.
> >          * Or if not contiguous, then a single-stride
> >          * increment moves through the entire array.
> >          */
> >         /*fprintf(stderr, "ONE...%d\n", loop->size);*/
> >         loop->function((char **)loop->bufptr, &(loop->size),
> >                 loop->steps, loop->funcdata);
> >         UFUNC_CHECK_ERROR(loop);
> >         break;
> >
> > Note that UFUNC_CHECK_ERROR calls PyErr_Occurred. That doesn't seem
> > thread safe to me. Or maybe there is something special about that
> > function I'm missing.
> Check the definition of the macro.   It only calls PyErr_Occurred if the
> obj variable is non-zero on the loop structure, indicating an
> OBJECT-array loop.    In that case, the NPY_LOOP_BEGIN_THREADS does not
> actually release the GIL either.
>

I'm still bothered by the fact that moving the check fixed ticket #733 on
python2.6, whereas in python2.5 the error was caught, just too late to be
useful. I'm also not sure why the x |= x loop goes through a buffer loop.
With a nice contiguous array it should have gone straight through the fast
loop.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080426/8c4d8384/attachment-0001.html 


More information about the Numpy-discussion mailing list