cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

GPR Usage for private arrays

Suppose I have a private array say:

uint A[80];

Now any decent high end AMD GPU (5870/6970/7970) can store this number of uints in its GPRs. But I suppose the GPRs doesn't have any indirect addressing modes(I am not sure though), so is it still possible to store the array in GPRs?  Would it make any difference if the array indeces are random(like A[tmp] where value of tmp is not predictable) or fixed constant(like A[0],A[1]......or something entirely prdictable)? 

Thanks,

Sayantan

0 Likes
4 Replies

As per my experience, such arrays are not stored in GPRs, but we never what all optimizations they are planning

I would suggest you to check your GPR count with and without having this array in the profiler.

I guess putting something in GPRs or not depends on the compiler and the application it is compiling.

Another suggestion would be to try to use const cache( if the values are constant and known at compile time) .

realhet
Miniboss

There is hw support for indirect access of registers. Check the IL disassembly, there should be a dcl_indexed_temp_array instruction.

notzed
Challenger

Only arrays where [the index of] every access is known at compile time can be registerised (although realhet's comment suggests some hardware can support it, but i'd still be surprised if they did).  i.e. only constant indices.

I use local memory for read/write cases where the indices aren't constant, or constant for read-only data.

Usually local memory is required anyway because once you get arrays of that sort of size serial single-thread algorithms that use them get too slow.  There is usually some parallelism that can be exploited and the gains can be extreme.

So I guess the arrays are sure to be stored in GPRs only if all the indeces are compile time constants. In any other case they end up being stored in Global memory and in very few cases in the GPRs depending upon compilers and application.

0 Likes