![]() |
MAGMA
1.6.3
Matrix Algebra for GPU and Multicore Architectures
|
Here are general guidelines for variable names; there are of course exceptions to these.
Typically, the order of arguments is:
LAPACK and MAGMA use column-major matrices. For matrix X with dimension (lda,n), element X(i, j) is X[ i + j*lda ]. For symmetric, Hermitian, and triangular matrices, only the lower or upper triangle is accessed, as specified by the uplo argument; the other triangle is ignored.
lda is the leading dimension of matrix A; similarly ldb for B, ldda for dA, etc. It should immediately follow the matrix pointer in the argument list. The leading dimension can be the number of rows, or if A is a sub-matrix of a larger parent matrix, lda is the leading dimension (e.g., rows) of the parent matrix.
On the GPU, it is often beneficial to round the leading dimension up to a multiple of 32, to provide better performance. This aligns memory reads so they are coalesced. This is provided by the magma_roundup function:
ldda = magma_roundup( m, 32 );
The formula ((m + 31)/32)*32 also works, relying on floored integer division, but the roundup function is clearer to use.
On the CPU, it is often beneficial to ensure that the leading dimension is not a multiple of the page size (often 4 KiB), to minimize TLB misses.
For vectors, incx is the increment or stride between elements of vector x. In all cases, incx != 0. In most cases, if incx < 0, then the vector is indexed in reverse order, for instance, using Matlab notation,
incx = 1 means x( 1 : 1 : n ) incx = 2 means x( 1 : 2 : 2*n-1 )
while
incx = -1 means x( n : -1 : 1 ) incx = -2 means x( 2*n-1 : -2 : 1 )
For several routines (amax, amin, asum, nrm2, scal), the order is irrelevant, so negative incx are not allowed; incx > 0.