Function Description
LAPACK is originally implemented using the Fortran language and called by the Fortran language. It can also be directly called by the C language. The following explains standard Fortran interfaces using the C syntax.
Some LAPACK interfaces occupy extra memory internally. The extra memory depends on the matrix size and the number of threads (see Table 1). Other interfaces require less extra memory. Therefore, in typical scenarios where the memory is 256 GB, it is recommended that the maximum matrix size be less than or equal to 45,000 (except for the function interfaces in Table 1) to better use the optimized interfaces.
Function |
Extra Memory Space (unit: number of elements) |
Recommended Maximum Matrix Size (for a host with 256 GB memory) |
|---|---|---|
?potri |
6400 x ldb + 640000 |
45000 |
?getri |
2000 x ldb + 40000 x Number of threads + 400000 |
45000 |
?stedc |
(n x n + 8 x n + 10000) x Number of threads + 10000000 |
18000 |
If the matrix size exceeds the recommended value, interfaces with lower performance may be invoked instead of the optimization interfaces. As a result, the final performance deteriorates. If the host memory is large enough to meet the requirement of extra memory, the optimal performance can be achieved even with a large matrix size.
Take dsyevd for example. The dstedc interface needs to be invoked to implement dsyevd. In a typical scenario, assume that the element type is double precision (8 bytes per element), the matrix size is 18000 x 18000, and 96 threads are used. The required memory is calculated as follows:
- Extra memory usage:
((18000 x 18000 + 18000 x 8 + 10000) x 96 + 10000000) x 8 = 249,030,272,000 bytes (about 231.9 GB)
- Mandatory memory usage:
- Memory usage of the matrix: 18000 x 18000 x 8 = 2,592,000,000 bytes (about 2.4 GB)
- Memory usage of the work array work(6n+2n*n + 3+5n): (1 x 6 x 18000 + 2 x 18000 x 18000 + 3 + 5 x 18000) x 8 = 5,185,584,024 bytes (about 4.8 GB)
In this case, the memory required for invoking dsyevd is 231.9 GB + 2.4 GB + 4.8 GB = 239.1 GB.