In my application, I use a texture bind to a CUDA array 2D. I access the CUDA array using tex2D function in my kernel.
With texture of width<=16384, there is no problem. Beyond 16385, my kernel returns strange results. Indeed, if my kernel works
with texture of 100 columns, it should work with texture of 30000 columns. I know the limit of texture is 65536 columns
and 32768 rows.
So, I’ve written a short code doing the following task. In the following, “array” denotes a standard “float *”.
- Randomly initialize on HOST an array of size WIDTHxHEIGHT. This array is denoted by “A”.
- Copy the memory from A to a CUDA array of size WIDTHxHEIGHT. This CUDA array is denoted by “B”.
- Define a 2D texture. This texture is denoted by “C”.
- Bind texture C to CUDA array B.
- Define an array of size WIDTHxHEIGHT on DEVICE. This array is denoted by “D”.
- Call the kernel. This kernel copy C to D using tex2D.
- Define an array of size WIDTHxHEIGHT on HOST. This array is denoted by “E”.
- Copy memory from D to E.
- Compare A and E.
A and E should be equal. With WIDTH<=16384, there is no problems. With WIDTH>16384, the extremities are differents:
- with HEIGHT=10 and WIDTH=16385, first and last columns are differents.
- with HEIGHT=10 and WIDTH=16386, first 2 and last 2 columns are differents.
I join to this message the code allowing to verify this behavior.
Compile with “make”.
Run with “make run”.
Change the constant “WIDTH” to 16384 => there is no errors.
Change the constant “WIDTH” to 16385 => there is 20 errors (2HEIGHT).
Change the constant “WIDTH” to 16386 => there is 40 errors (4HEIGHT).
TextureProblem.zip (1.37 KB)