pointer and Memcpy problem

hey

i’m trying to implement a cuda based sorting in one of my c++ project but i got a problem with Memcpy function.

extern "C" void bitonic(int** values, int argc, char argv)

{

    CUT_DEVICE_INIT();

   int * dvalues;

    CUDA_SAFE_CALL(cudaMalloc((void**)&dvalues, sizeof(int) * NUM));

    CUDA_SAFE_CALL(cudaMemcpy(dvalues, *values, sizeof(int) * NUM, cudaMemcpyHostToDevice));

it seems that for some reason just the first value in the values variable is copied. it might be a mess with pointers but i can’t find where :">

thank you for any ideas.

hi,

what’s your datastructure for int **values. int **values can be a pointer to one array of int’s… but it can also be an array of pointers to arrays of ints. Latter means that your data is probably not stored continuous - so your routine copies only the values[0] and not values[1] to values[end].

If you are passing a “double dimensional” array which was declared as “array[NUM][NUM]” then you canNOT pass it as “int **”. The way the compiler generates code for “int **” is different from what it generates for “int ”. Try passing that array as “int values

the datastructure for int** values is a pointer to array of int but although it seems that the data ist’t stored in memory continous … and it wae declared as int** … i try to use a temporary array whithout a pointer to pass it …

I am sorry But I really cant decipher what you are coming to say.