May be you can advise me how to create a hierarchical structure in OpenCL. It is easy if you have "new" or "malloc", but I don't know how do it in GPGPU. So I created 3 kernels:
- To send sizeof struct to host.
- To initialize data.
- And kernel which uses data initialized in second kernel.
I have this struct in OpenCL:
typedef struct some some;
struct some{
char data[4];
some* children[8];
};
First kernel says that size of this structure is 36 bytes(4 for data and 32 for pointers).
Next I allocate memory on GPU based on previous information and call second kernel:
kernel void import(global some *buffer){
for(int i=0;i<4;i++){
buffer[0].data[i]=255; //For example, doesn't matter
}
//Now I need to assign pointer to next element of array(buffer) to first element
buffer[0].children[0]=&buffer[1];
}
But kernel not compiles. Also I tried:
*buffer[0].children[0]=buffer[0];
It compiles, but crashes of course. It is logically wrong) Without assignments of pointers everything works fine. Very cool program for 1 element)