I am having trouble working with double pointer using cuda. The following source is returning SIGSEGV, however, if compile with -deviceemu the program runs normally.
Your problems is that you allocate N ints device side, and then you attempt to allocate again on the allocated adresses.
You are trying to write directly to device memory from the host side, this is not allowed.
I have a c++ template that helps with sorting that out, but I also suspecting that it may be the cause of a problem I’m having, so I can’t recommend using it until I’ve figured out why my code segfaults.
Let me know if you wanna look at it.
It’s quite possible for you to solve this yourself using c only. It just requires some thinking.
First you need to allocate two arrays of N size. N is your number of arrays. One array host side (A) and one device side (B)
Then to each host side element, cudamalloc.
Lastly, copy the content from A to B, and send B into the kernel.
Yes, helped. Actually my problem, in real case, is similar to what was shown. however i have an array of pointers and must initially allocate an array of poiters and then allocate a struct for each poiters in the array. however each pointer in array have a address in device and this generate a segfault on host. Then i have to think a solution to store temporaly the poiters. Tank’s !!!