Saturday, September 19, 2015

2d array on gpu

You can dynamically allocate multi-dimensional array on cpu and free it before exiting the program.
However this is not the case for gpu.
When you first allocate pointer, it works fine. Then when you cudamalloc a space for each pointer, it will trigger a segmentation fault.

One solution is creating a contiguous trunk of memory and find a index for each dimension.
Another solution for 2d is use pitch memory.

No comments:

Post a Comment