Hi, I may be wrong be doing a sum of 400 values on a GPU doesn't really mean anything, transfering the data will kill the computing time!! On my system your code start to get advantage of the GPU with 100 000 000 values..... , which, for a sum is not stupid (again for my point of view). Pierre.
Le lundi 09 avril 2012 à 14:05 -0700, Serra, Mr. Efren, Contractor, Code 7542 a écrit : > import numpy > """ > """ > import pycuda.driver as cuda > import pycuda.tools > import pycuda.gpuarray as gpuarray > import pycuda.autoinit, pycuda.compiler > > a=numpy.arange(400) > a_gpu=gpuarray.arange(400,dtype=numpy.float32) > > start=cuda.Event() > end=cuda.Event() > start.record() > gpuarray.sum(a_gpu).get()/a.size > end.record() > end.synchronize() > print "GPU array time: %fs" %(start.time_till(end)*1e-3) > > start.record() > numpy.sum(a)/a.size > end.record() > end.synchronize() > print "numpy array time: %fs" %(start.time_till(end)*1e-3) > > GPU array time: 0.000377s > numpy array time: 0.000001s > > Efren A. Serra (Contractor) > DeVine Consulting, Inc. > Naval Research Laboratory > Marine Meteorology Division > 7 Grace Hopper Ave., STOP 2 > Monterey, CA 93943 > Code 7542 > Office: 831-656-4650 > > > _______________________________________________ > PyCUDA mailing list > [email protected] > http://lists.tiker.net/listinfo/pycuda _______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
