On Tuesday 02 March 2010 06:17:03 pm Ian Ozsvald wrote:
> Continuing my post about a simple speed test from before (thanks Ian!)
> I have a modified version (at the end). This was the original thread:
> http://tiker.net/pipermail/pycuda_tiker.net/2010-January/000940.html
>
> The new code runs a loop on sin() using get_function, using a GPUArray
> and using straight numpy. The get_function version is fastest, then
> the GPUArray (limited I guess by memory copies to/from the device on
> each iteration), then numpy.
Hi Ian,
I would add a comparison the array with a ElementwiseKernel. One of the biggest
overhead of cuda using the GPUArray is due to the kernel startup time and in
not the actual kernel itself. With longer kernels it is not a big deal but with
a repeated small kernel it is quite astonishing how you can kill performances.
Here is the actual ElementwiseKernel which is almost on par with your GPU
version (0.11s vs 0.14s)
############
# Elementwise SECTION
#
from pycuda.elementwise import ElementwiseKernel
kernel = ElementwiseKernel(
"float *a, int niter",
"for(int n = 0; n < niter; n++) { a[i] = sin(a[i]);}",
"sine")
a = numpy.ones(nbr_values).astype(numpy.float32)
a_gpu = gpuarray.to_gpu(a)
start.record()
kernel(a_gpu, numpy.int(n_iter))
end.record()
end.synchronize()
secs = start.time_till(end)*1e-3
print "Elementwise time:", secs
print "Elementwise result starts with...", a_gpu.get()[:3]
> It looks as though the GPU solution (get_function) is 205 times faster
> than the CPU version. Does this make sense?
I believe it does. What make you think 100 time is right and 205 is over?
On my computer ( Intel(R) Xeon(R) CPU 5120 @ 1.86GHz vs GTX280) it is about
120x which is not the standard gain but i would say not uncommon for CPU->GPU.
Cheers,
J-Pascal Mercier
_______________________________________________
PyCUDA mailing list
[email protected]
http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net