Constant or Texture Memory Which is better for my application?

Would texture memory or constant memory be better for my application?

I need to store a 2D array (matrix) that threads will access many times, but the access pattern will be unpredictable (basically random access, I believe). Each thread will access one data value at a time. Each entry of the matrix will likely be an 8-bit signed integer, and the matrix will be on the order of 23X23. The data will only be read, but will be read several times by each block of the kernel.

This matrix will be a substitution matrix (or scoring matrix) as used in the Smith-Waterman protein sequence alignment algorithm.

Because I will be accessing the matrix randomly, I’m not sure if either constant memory or texture memory has an advantage.

Thanks

I’m quite sure constant memory is faster, it’s cached very well (and if in cache, read is just as fast as register). And as your matrix is 23x23 it probably fits entirely into the constant cache.

Neither: use shared memory
See a mini-benchmark I wrote here: http://forums.nvidia.com/index.php?showtop…76&#entry256376

wumpus is correct that constant memory is better than texture memory for this, but constant memory is only fast when every single thread in the warp accesses the same element of constant mem.

Thanks for the responses. I’ll see if I can fit it in shared memory, but it will most likely have to go in constant memory.