PDA

View Full Version : arguments to kernel functions



bony
04-06-2010, 04:02 AM
Can I pass to kernel function pointer to structure like this:

structure My {
int x1;
int x2;
my_structure_type1 *ps1;
my_structure_type2 *ps2;
}
where my_structure_type1 and my_structure_type2 are my own defined types from other structures.

Psch
04-06-2010, 08:07 AM
Hi,

I am not sure if I understand you correctly, but if you have situation, where you fill the variable of My structure with data on host(your program using OpenCL) and then you pass this struct (or pointer to it) via buffer to kernel like this:


__kernel void myKernel(__global My* myVar)
{
...
}


...then the pointer members of My structure (ps1, ps2) will still contain address which points somewhere to host memory, while the kernel is (I presume) executed on GPU, in completely different address space.

I remember getting myself into similar trap, resulting in various side effects like freezing up the PC.

So, in my opinion it is not possible to do it this way.


Petr