This example illustrates the use of the hipSOLVER LU factorization functionality. The hipSOLVER getrf
computes the LU decomposition of an
-
getrf()
: This is the blocked Level-3-BLAS version of the LU factorization algorithm. An optimized internal implementation without rocBLAS calls could be executed with mid-size matrices. -
$A$ is the$m \times n$ input matrix. -
$P$ is an$m \times m$ permutation matrix, in this example stored as an array of row indicesvector<int> Ipiv
of sizemin(m, n)
. -
$L$ is:- an
$m \times m$ lower triangular matrix, when$m \leq n$ . - an
$m \times n$ lower trapezoidal matrix, when$m > n$ .
- an
-
$U$ is:- an
$m \times n$ upper trapezoidal matrix, when$m < n$ . - an
$n \times n$ upper tridiagonal matrix, when$m \geq n$
- an
- Parse command line arguments for the dimension of the input matrix.
- Declare and initialize a number of constants for the input and output matrices and vectors.
- Allocate and initialize the host matrices and vectors.
- Allocate device memory.
- Copy input data from host to device.
- Create a
hipsolverHandle_t
handle. - Invoke the hipSOLVER
getrf
function with double precision. - Copy the results from device to host.
- Print trace messages.
- Free device memory and the hipSOLVER handle.
-
hipsolver[SDCZ]getrf
computes the LU factorization of an$m \times n$ input matrix$A$ . The correct function signature should be chosen, based on the datatype of the input matrix:-
S
(single-precision:float
) -
D
(double-precision:double
) -
C
(single-precision complex:hipFloatComplex
) -
Z
(double-precision complex:hipDoubleComplex
).
Input parameters for the precision used in this example (double-precision):
hipsolverHandle_t handle
-
const int m
: number of rows of$A$ -
const int n
: number of columns of$A$ -
double *A
: pointer to matrix$A$ -
const int lda
: leading dimension of matrix$A$ -
double *Ipiv
: pointer to vector$Ipiv$ -
int *info
: result of the LU factorization. If 0, the factorization succeeded, if greater than 0 then$U$ is singular and$U[info,info]$ is the first zero pivot.
Return type:
hipsolverStatus_t
-
-
hipsolver[SDCZ]getrf_bufferSize
allows to obtain the size (in bytes) needed for the working space for thehipsolver[SDCZ]getrf
function. The character matched in[SDCZ]
coincides with the one inhipsolver[SDCZ]getrf
.This function accepts the following input parameters:
hipsolverHandle_t handle
-
int m
number of rows of$A$ -
int n
number of columns of$A$ -
double *A
pointer to matrix$A$ -
int lda
leading dimension of matrix$A$ -
int *lwork
returns the size of the working space required The return type ishipsolverStatus_t
.
hipsolverHandle_t
hipsolverCreate
hipsolverDestroy
hipsolverDgetrf_bufferSize
hipsolverDgetrf
hipFree
hipMalloc
hipMemcpy
hipMemcpyHostToDevice
hipMemcpyDeviceToHost