OpenCL: array of arrays as kernel argument.

Hi.
I’ve to pass to the kernel of my OpenCL program a big, sparse graph. I’ve to implement it as an adjacency list, not a square adjacency matrix due to memory limits.
I’ve red that it’s not possible to pass to kernel structures that contain pointers, my argument should be like this:

0 -> {(3,4), (2,5), (4,2)}
1 -> {(5,6), (6,4)}

V -> {(2,6), (3,7), (4,12), (15,9)}

where V is the number of nodes of the graph and e.g. 0->{(3,4) …} means that there is an edge (0,3) of weight 4.
The length of the arrays pointed by the first array is not always the same, as an adjacency list.

The kernel should be something like:

__kernel void kernel_bellman_ford(__global (struct edge) **g, …other arguments)

and

struct edge {
int node;
int weight;
};

Actually there are no struct containing pointers but there’s still a multi-dimension array.
Is there a way to use this graph array successfully as a kernel argument?
Is it possible to write it in another way?

Thanks in advance.

You can put all of the edges into one buffer and structs representing each vertex in another.


struct edge {
int node;
int weight;
};

struct vertex{
int offset; //offset in vertex array
int num; //number of edges
}

“vertex” is effectively a pointer here.

[QUOTE=Salabar;42464]You can put all of the edges into one buffer and structs representing each vertex in another.


struct edge {
int node;
int weight;
};

struct vertex{
int offset; //offset in vertex array
int num; //number of edges
}

“vertex” is effectively a pointer here.[/QUOTE]

Ok, I’ll try it. Thank you very much.