How can I:
- Associates cudaMallocPitch floating memory with a two-dimensional texture link
- Copy some host data to a 2D array on the device
- Add one link to the texture and write either.) Pitch 2D array OR b.) Write to a linear memory array
- Read the answer and show it.
Below is the code that should execute this. Please note that for NxN array sizes, my code works. For NxM, where N! = M, my code bites dust (not the correct result). If you can solve this problem, I will give you 1 Internet (limited offer). Maybe I'm crazy, but according to the documentation, this should work (and it works for square arrays!). The attached code should work with "nvcc whateveryoucallit.cu -o runit".
Help is appreciated!
#include<stdio.h>
Edit October 17th: I still have not found a solution to this problem. Nvidia was quite silent, it seems that the world too. I found a workaround using shared mem, but if someone has a texture solution, I would really like it.
Edit Octoboer 26: still no interlocutor, but still interested in one if anyone knows.
Edit July 26: Wow 9 months passed - and all the time I did not notice the correct answer. The trick was:
if ( idx < width && idy < height){
As previously stated. Thanks to everyone who contributed!
c ++ cuda textures
Marm0t
source share