copy string from host to string


I would like to know a way to copy array of string data (char**) from host to string. and then do some manipulation on these data elements.

char** ss={“Hello”, “Hello1”, and so on}

I want to copy them to device from host

I could copy a character array into device from host. However, i am not able to do with char**.

Please help in solving this problem.

I greatly appreciate your help.


global memory dereferencing is not allowed in kernel, you may pad each ss[i] into uniform-length prior to the kernel, and unpack them after copying them back.

It is allowed, you just need to be very careful how you construct your list of pointers on the host. It is usually much easier and less bug prone to allocate a 2D like data structure with padding, as you suggest.

Thank you so much for all your kind suggestions.

What does pad each ss[i] means? Could you kindly give some more details?

I really appreciate all your kind help and support.

I was trying to copy the pointers as it is into the device memory and the pointer are lost cause the pointers are pointing to the host memory, however, i am looking into the device memory.

Say your maximum string size is 32. Resize all of your strings so they contain 32 elements, and voila, you don’t even need pointers to each individual element–pass a pointer to the start of the array and the number of elements, and you can easily figure out where a string starts.