[J3] [EXTERNAL] Re: Limitations of SELECT RANK?

Thomas König tk at tkoenig.net
Tue Oct 20 17:23:06 EDT 2020


Am 20.10.20 um 18:21 schrieb Steidel, Jon L via J3:

 > While there may be use cases that have duplicate text in multiple
 > SELECT RANK case blocks, many involving whole array arithmetic,
 > the code generated for each of the blocks is very different due
 > to the difference in the array ranks between the two blocks.
 > The compiler would have to replicate the block for each possible
 > rank and generate a separate block for each rank.

Just a minor point: While this is quite possible that a compiler
might do just that, there are also other way this could be implemented.

For example, if the array is viewed as a sequence of storage locations,
it is possible to take a one-dimensional view of it and apply an
odometer algorithm to select the next index to store to.  Increase the
lowest dimenion first; then, if it is at the limit, increase the
next one etc. until you hit the end of the array

This is used extensively, for example, in the libgfortran library
to avoid combinatorical explosions from having to have a separate
function for each permissible rank.

Best regards

     Thomas


More information about the J3 mailing list