Hi all,
I need a suggestion to allocate a particular struct of pointers of
functions used as VTable.
The idea is to get some polymorphism property in CUDA and the
implementation works well with it.
The problem is to adapt the code with pyCUDA because I don't know how
to get a pointer of a function.
I would know how it's possible to allocate a struct and copy a function pointer
into it. Here a simple example:
--------------------------------------------------------------------------------------------
typedef struct _cuobject cuObject;
//pointers to function
typedef int (*comparefunc)(const cuObject*, const cuObject*, int);
typedef struct _cutype{
comparefunc compare;
} cuType;
__host__ __device__ int object_compare(const cuObject* a, const
cuObject* b, int op){
return -1;
}
-------------------------------------------------------------------------------------------------------
I would do something like this but in pyCuda with mem_alloc and mem_cpy:
-----------------------------------------------------------------------------
cuType cuobjecttype = {
object_compare,
};
-----------------------------------------------------------------------------
In this way I associate the function "object_compare" to the struct.
The way to do so in pyCuda could be:
ptr = cuda.mem_alloc(np.intp(0).nbytes) // allocate for cuType
cuda.memcpy_htod_async(ptr, np.int32(0)) // <- how to
specify the function pointer named "object_compare"??? O.o
Thanks a lot for help me.
Filippo
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda