Hey Paul,
that code sample is there just for illustration. As it says right
below the it: "This snippet in a working context can be found in
examples/demo_meta_codepy.py."
in that file, dtype is declared to be an numpy.float32
(The code to allocate variables on the GPU and run the kernels is
also in that program.)
hope that helps,
Paul Ivanov
(from SciPy2009)
Paul Rigor (uci), on 2009-08-17 18:58, wrote:
> Hi,
> I'm getting an error trying to run a codepy sample from the documentation:
> http://documen.tician.de/pycuda/metaprog.html#metaprogramming-using-codepy
>
> from codepy.cgen.cuda import CudaGlobalmod = Module([
> Typedef(POD(dtype, "value_type")),
> FunctionBody(
> CudaGlobal(FunctionDeclaration(
> Value("void", "add"),
> [Pointer(POD(dtype, name)) for name in ["result", "op1",
> "op2"]])),
> Block([
> Initializer(
> POD(numpy.int32, "idx"),
> "threadIdx.x + %d*blockIdx.x" %
> (thread_block_size*block_size)),
> ]+[
> Assign("result[idx+%d]" % (o*thread_block_size),
> "op1[idx+%d] + op2[idx+%d]" % (
> o*thread_block_size,
> o*thread_block_size))
> for o in range(block_size)
> ])
> )
> ])
> from pycuda.compiler import SourceModulemod = SourceModule(mod)
>
>
>
> I'm receiving the following error:
> In [3]: mod = Module([
> ...: Typedef(POD(dtype, "value_type")),
> ...: FunctionBody(
> ...: CudaGlobal(FunctionDeclaration(
> ...: Value("void", "add"),
> ...: [Pointer(POD(dtype, name)) for name in ["result", "op1",
> "op2"]])),
> ...: Block([
> ...: Initializer(
> ...: POD(numpy.int32, "idx"),
> ...: "threadIdx.x + %d*blockIdx.x" %
> (thread_block_size*block_size)),
> ...: ]+[
> ...: Assign("result[idx+%d]" % (o*thread_block_size),
> ...: "op1[idx+%d] + op2[idx+%d]" % (
> ...: o*thread_block_size,
> ...: o*thread_block_size))
> ...: for o in range(block_size)
> ...: ])
> ...: )
> ...: ])
> ---------------------------------------------------------------------------
> NameError Traceback (most recent call last)
>
> /home/prigor/projects/pycuda/pycuda-0.93/test/<ipython console> in
> <module>()
>
> *NameError: name 'dtype' is not defined*
>
>
> Has anyone gotten this to work?
> Thanks,
> Paul
>
> --
> Paul Rigor
> http://www.paulrigor.net/
> http://www.ics.uci.edu/~prigor
> _______________________________________________
> PyCUDA mailing list
> [email protected]
> http://tiker.net/mailman/listinfo/pycuda_tiker.net
_______________________________________________
PyCUDA mailing list
[email protected]
http://tiker.net/mailman/listinfo/pycuda_tiker.net