Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: X10 2.2.2
-
Fix Version/s: None
-
Component/s: Class Library: Array Library
-
Labels:None
-
Number of attachments :
Description
x10.array.Region defines the method indexOf(Point), which maps each point in the region to a one-dimensional offset in the range 0..(N-1).
When allocating arrays, elements should be laid out in memory in the same order as is defined by this method. One consequence of this is that the array is dense in layout: exactly the same number of array elements are needed to store an array as there are points in its defining region.
Currently, non-rectangular arrays are not dense in layout. For example, the points in a triangular array are actually indexed using a rectangular layout, wasting half the memory.
Non-rectangular arrays should be laid out dense in memory in the manner specified in Region.indexOf(Point) by their defining region. If this is the case, the checks against {rect} in Array.fill(), Array.map(), Array.reduce() and the constructor can be removed. Of course, this has to be balanced against the need for efficient indexing of standard rectangular arrays.
but how do you define dense? Maybe it would be better to expose nnz, number of non-negative zeros, and permit the programmer to specify bounds <,> on arithmetic variables. (This i easy to add, and I hope we will add this real soon now..)
The real issue of course is how to compute nnz. What kind of operations do we need on regions to support sparse regions, and what kind of static reasoning can be done about them.