Hey guys, thanks for all your help with the last question but another has arose.
i have this funtion
global void ker(int dtotal_vars, int dj, int* dvars, int* dbool_arr, int* dvar_lines, int dl)
{
int i=0;
int inttemp;
int ac;
int keeper;
for(i=0; i< dtotal_vars && !dj; i++)
{
inttemp = dvars[i];
if(dbool_arr[i])
{
inttemp = -inttemp;
}
}
when i compile i get the error: expression must have pointer-to-object type
its from the line keeper = dvar_lines[dl][ac] and it has something to do with calling a multi dimentional array, if i eliminate one of the array elements it compiles.
thanks
CS
Every time you use a , you take off one degree of “pointerness,” and when they’re all taken off you don’t have a pointer anymore. So a float* array1 can be called array1[i], a float** array2 can be called array2[i][j]. If you write array1[i][j], you are basically writing
float element;
element[j];
which is not allowed
A float** is called a jagged array. It’s an array of pointers, each pointer leading to an array. I wouldn’t use them with CUDA, because it makes the cudaMalloc() and cudaMemcpy() process more complex. Important to mention, although confusing to the discussion, is that another type of 2D array in C is a simple “float array3[10][20]”. This is not an array of pointers.