hi i'm trying to implement the distance vector program in open CL ..
basically i'm having problems with passing an array of structures into the kernel as an argument ..
my structure definition is this
typedef struct
{
int a[nodes][4];
}node;
node * srcA;
after allocating the memory for this .. i have bundled it into a buffer object using this code
// allocate the buffer memory objects
memobjs1 = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
sizeof(node) * n, srcA, NULL);
if (memobjs1 == (cl_mem)0)
{
printf("ERROR: Failed to create Buffer...mem[0]\n");
clReleaseCommandQueue(cmd_queue);
clReleaseContext(context);
return -1;
}
and my kernel argument is set like this
err = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &memobjs1);
now i want to pass this array of structs ( i.e. pointed by srcA ) into the kernel i have done this ..
const char *ocl_test_programs[] = {\
"__kernel void disvec (__global node *x,__global int *p)"\
"{"\
"int i=1,r=1,n;"\
"r=p[1]; "\
"n=p[0];"\
//"for(i=1;i<=n;i++) "\
"{"\
"if(x[r].a[i][2]!=999 && x[r].a[i][2]!=0)"\
"{"\
"int j = get_global_id(0); "\
/* "int k=x[r].a[i][2] + x[i].a[j][2];"\
"if(x[r].a[j][2]>k)"\
"{ "\
" x[r].a[j][2] = k;"\
"x[r].a[j][3] = i; } "\ */
//" } "\
" } "\
" } "\
" } "
};
when i run this program it says node type not defined ... do i have to keep in mind some other parameters to pass ?? what are the changes i shud make .. ?? if someone can atleast give me a simple code to illustrate struct passing into the kernel with a simple example it will be much appreciated .. thanks a lot :)