Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: rmT116609 Date: 12/03/2003 A DESCRIPTION OF THE REQUEST : As per the Java Language Specification, section 10.4, all array access in Java is done by using an int as index. Since an int is a signed 32bit value, this limits the total number of addressable elements of an array to 2**31 (about 2 billion). It should be possible to address an array using 64bit values. JUSTIFICATION : While having access to 2 billion entries may seem sufficient, there are very compelling performance reasons to be able to use more in a single array. As an example, consider a square n*n matrix, stored as an array (either row or column major, doesn't matter which). Since an array stores at most 2**31 entries, this means that n=sqrt(2**31)=46341, thus the matrix cannot be very large. For multidimensional arrays this is an even more severe limitation (3d Tensors could at most be of size 1290). A workaround is to use an array of arrays (ie. double[][]). However there is no guarantee that successive rows will be laid of linearly in memory, and therefore performance may be severly penalized. Experimentally, performance may suffer by a factor of over 2, often far greater. Also, most existing matrix packages (ie. LAPACK) assumes linear storage, and are thus incompatible with a double[][] storage (requires double[]). Calling a LAPACK routine with a jagged storage thus requires extra array copying and memory allocation, and can further decrease performance and increase memory requirements. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - It should be possible to address arrays using 64bit integers (long?), as this provides a seamless transition for users of 64bit computers. ACTUAL - Cannot address more than 2**31 elements of an array. CUSTOMER SUBMITTED WORKAROUND : Use of array of array constructs (use double[][] instead of double[]) (Incident Review ID: 227911) ======================================================================
|