Sorry for the patch spamming, but I find easier to break down the
various work I am doing.

This is the first patch that introduces some new functionality.

by using the kernel decorator one could rewrite this code

mod = SourceModule("""
    __global__ void doublify(float *a)
    {
      int idx = threadIdx.x + threadIdx.y*4;
      a[idx] *= 2;
    }
    """)

func = mod.get_function("doublify")
func(a_gpu, block=(4,4,1))

in

from pycuda.decorators import kernel

@kernel
def doublify(a='float *'):
     """
     int idx = threadIdx.x + threadIdx.y*4;
     a[idx] *= 2;
    """

doublify( a_gpu, block=(4,4,1))


you can pass any flag that SourceModule takes with

@kernel(options=['-O2'])

Of course there are caveats:
- the name of the input variables must correspond to the one inside the doc body
- the default value is a string that specifies the type of the var
- # includes are supported for now, all other stuff that should go before the
- no need to specify the __global__ declaration, it gets generated

see the tests for some example

I think this addition to pycuda would be nice, and the code would look
some what cleaner
The real power will be obvious when you see the element-wise kernel
decorator ...

Comments? ideas? Flames?

Fabrizio
--------------------------
Luck favors the prepared mind. (Pasteur)

_______________________________________________
PyCUDA mailing list
pyc...@host304.hostmonster.com
http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net

Reply via email to