[Numpy-discussion] Numpy and OpenMP

Robert Kern robert.kern at gmail.com
Mon Mar 17 13:55:40 EDT 2008


On Mon, Mar 17, 2008 at 12:06 PM, Christopher Barker
<Chris.Barker at noaa.gov> wrote:
> >  > Plus a certain amount of numpy code depends on order of
>  >  > evaluation:
>  >  >
>  >  > a[:-1] = 2*a[1:]
>
>  I'm confused here. My understanding of how it now works is that the
>  above translates to:
>
>  1) create a new array (call it temp1) from a[1:], which shares a's data
>  block.
>  2) create a temp2 array by multiplying 2 times each of the elements in
>  temp1, and writing them into a new array, with a new data block
>  3) copy that temporary array into a[:-1]
>
>  Why couldn't step (2) be parallelized? Why isn't it already with, BLAS?
>  Doesn't BLAS must have such simple routines?

Yes, but they are rarely optimized. We only (optionally) use the BLAS
to accelerate dot(). Using the BLAS in more fundamental parts of numpy
would be problematic from a build standpoint (or conversely a code
complexity standpoint if it remains optional).

>  Also, maybe numexpr could benefit from this?

Possibly. You can answer this definitively by writing the code to try it out.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the NumPy-Discussion mailing list