https://wiki.octave.org/wiki/api.php?action=feedcontributions&user=Menix&feedformat=atomOctave - User contributions [en]2020-06-06T11:52:22ZUser contributionsMediaWiki 1.34.1https://wiki.octave.org/wiki/index.php?title=Enable_large_arrays:_Build_octave_such_that_it_can_use_arrays_larger_than_2Gb.&diff=12640Enable large arrays: Build octave such that it can use arrays larger than 2Gb.2020-02-08T17:18:38Z<p>Menix: 5.2.0_1-w64-64 for Windows 64-bit indexing for linear algebra</p>
<hr />
<div>{{Note|The following only applies to systems that have 64-bit pointers (64bit architecture).}}<br />
<br />
Starting with Octave 4.4.0, 64-bit indexing is the default for targets with 64-bit pointers. You can override that default by specifying <code>--disable-64</code> when configuring Octave.<br />
<br />
However, if the configure script determines that the BLAS library uses 32-bit integers, then operations using the following libraries are limited to arrays with dimensions that are smaller than 2^31 elements:<br />
* BLAS<br />
* LAPACK<br />
* QRUPDATE<br />
* SuiteSparse<br />
* ARPACK<br />
<br />
Additionally, the following libraries use "int" internally, so maximum problem sizes are always limited:<br />
* glpk<br />
* Qhull<br />
<br />
To determine the integer size of the BLAS library used by Octave, the following code can be executed:<br />
<br />
<syntaxhighlight lang="Octave"><br />
clear all;<br />
N = 2^31;<br />
## The following line requires about 8 GB of RAM!<br />
a = b = ones (N, 1, "single");<br />
c = a' * b<br />
</syntaxhighlight><br />
<br />
<br />
## GNU Octave has released in January 2020 a 5.2.0_1-w64-64 for Windows which is 64-bit indexing for linear algebra. We are anxiously awaiting same for Linux and Mac. See gnu.org octave/download/windows<br />
<br />
<br />
If the BLAS library uses '''32-bit integers''', an error will be thrown:<br />
<br />
error: integer dimension or index out of range for Fortran INTEGER type<br />
<br />
Otherwise, if the BLAS library uses '''64-bit integers''', the result is:<br />
<br />
c = 2^31 = 2147483648<br />
<br />
Note that the test case above usually requires twice the memory, if <code>a</code> and <code>b</code> are not assigned by <code>a = b = ...</code>.<br />
Note further, that the data type "single" has a precision of about 23 binary bits.<br />
In this particular example no rounding errors occur.<br />
<br />
===Versions prior to Octave 4.4===<br />
On previous versions of Octave, the default is that the size of a single Octave array cannot have more than approximately 2^31 elements, even on systems that use 64-bit pointers. This is because array indices were limited to 32-bit signed integers by default. Trying to create one will produce the following error:<br />
<br />
<pre><br />
>> a = zeros (1024*1024*1024*3, 1, 'int8');<br />
error: out of memory or dimension too large for Octave's index type<br />
</pre><br />
<br />
You will obtain this error even if your system has enough RAM to create this array (3 GB in the above case).<br />
<br />
To use arrays with more than (approximately) <math>2^{31}</math> elements, Octave has to be configured with the option <code>--enable-64</code>. This option is experimental and you are (as always) encouraged to submit bug reports if you find a problem. <br />
With this option, Octave will use internally 64-bit integers for array dimensions and indexing. However, '''all numerical libraries''' used by Octave will need to use also 64-bit integers for array dimensions and indexing, and in most cases they need to be compiled from source.<br />
<br />
For details about how to compile these libraries please read the [http://www.gnu.org/software/octave/doc/interpreter/Compiling-Octave-with-64_002dbit-Indexing.html#Compiling-Octave-with-64_002dbit-Indexing GNU Octave manual], or alternatively you can use [[MXE]] (M Cross Environment) which takes care of the different packages automatically (especially the configure flags <code>--enable-64</code> and <code>--enable-fortran-int64</code>).<br />
<br />
[[Category:Building]]</div>Menix