New issue 2344: PyPy2-5.3.1-linux64 slower running array element add with 
numpy, comparing with CPython
https://bitbucket.org/pypy/pypy/issues/2344/pypy2-531-linux64-slower-running-array

Peter Wang:

Hi,

We are seeing 22x slower running PyPy2-5.3.1-linux64 with the alpha-0 numpy 
releases for pypy, when performing array element add.  See results and code 
below.  This was running on Ubuntu 14.04.1 LTS.

Before we spend more effort to investigate, I’d like to know if this is a known 
issue, and if any details are already available.  

Thanks,

Peter


$ /opt/pypy2-v5.3.1-linux64/bin/pypy ./vectoradd.py
N = 3200000
NumPy initialization took 0.003146 seconds
C[:5] = [ 2.  2.  2.  2.  2.]
C[-5:] = [ 2.  2.  2.  2.  2.]
VectorAdd took 24.797032 seconds

$ /usr/bin/python2.7 ./vectoradd.py
N = 3200000
NumPy initialization took 0.004292 seconds
C[:5] = [ 2.  2.  2.  2.  2.]
C[-5:] = [ 2.  2.  2.  2.  2.]
VectorAdd took 1.085233 seconds



$ cat vectoradd.py
import numpy as np
from timeit import default_timer as timer

def VectorAdd(a, b, c):
        for i in xrange(a.size):
                c[i] = a[i] + b[i]

def main():
        N = 320000000 # number of elements per Array
        N = 3200000

        start = timer()
        A = np.ones(N, dtype=np.float32)
        B = np.ones(N, dtype=np.float32)
        C = np.zeros(N, dtype=np.float32)
        print("N = %d" % N)
        print("NumPy initialization took %f seconds" % (timer() - start))

        start = timer()
        VectorAdd(A, B, C)
        vectoradd_time = timer() - start

        print("C[:5] = " + str(C[:5]))
        print("C[-5:] = " + str(C[-5:]))

        print("VectorAdd took %f seconds" % vectoradd_time)

if __name__ == '__main__':
        main()



_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to