PDA

View Full Version : How to pass complex structures to kernel?



chanakya.sun
07-21-2011, 10:07 PM
Hi,

1) I have a small problem while copying the data to my kernel
I need to pass the structures NODE_ab which is the node of a tree.
I am confused on how to pass the tree to my kernel



typedef struct _list
{
int data;
struct _list *next;
}_list;
typedef struct _list * LIST;

typedef struct NODE_ab
{
int count;
LIST marks;
char data;
struct NODE_ab* right;
struct NODE_ab* left;
} NODE_ab;

2) Is it possible to do a clCreateBuffer with in the kernel?
because the data is dynamic in nature and i don't want to create a large buffer
and also my structures are complex as defined above.

:roll:

Regards

david.garcia
07-22-2011, 04:11 AM
Instead of pointers, use offsets from the start of the buffer.

For more details, please see these previous replies:

viewtopic.php?f=37&t=2900 (http://www.khronos.org/message_boards/viewtopic.php?f=37&t=2900)

viewtopic.php?f=37&t=3777 (http://www.khronos.org/message_boards/viewtopic.php?f=37&t=3777)

david.garcia
07-22-2011, 04:21 AM
2) Is it possible to do a clCreateBuffer with in the kernel?
because the data is dynamic in nature and i don't want to create a large buffer
and also my structures are complex as defined above.

No, it's not possible to allocate memory dynamically inside a kernel. People will usually allocate one large buffer and divide it into smaller pieces inside the kernel.