Generic API Functions#
nvpl_sparse_spmv()#
nvpl_sparse_status_t
nvpl_sparse_spmv_buffer_size(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
const void* beta,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_dn_vec_descr_t vec_Z,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spmv_alg_t alg,
nvpl_sparse_spmv_descr_t spmv_descr,
size_t* buffer_size)
nvpl_sparse_status_t
nvpl_sparse_spmv_analysis(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
const void* beta,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_dn_vec_descr_t vec_Z,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spmv_alg_t alg,
nvpl_sparse_spmv_descr_t spmv_descr,
void* external_buffer)
nvpl_sparse_status_t
nvpl_sparse_spmv(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
const void* beta,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_dn_vec_descr_t vec_Z,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spmv_alg_t alg,
nvpl_sparse_spmv_descr_t spmv_descr)
This function performs the multiplication of a sparse matrix mat_A and a dense vector vec_X
\(\mathbf{Z} = \alpha op\left( \mathbf{A} \right) \cdot \mathbf{X} + \beta\mathbf{Y}\) |
where
op(A)is a sparse matrix of size \(m \times k\)Xis a dense vector of size \(k\)Yis a dense vector of size \(m\)Zis a dense vector of size \(m\)\(\alpha\) and \(\beta\) are scalars
Also, for matrix A
\(\text{op}(A) == \begin{cases} A & \text{if op(A) == NVPL_SPARSE_OPERATION_NON_TRANSPOSE} \\ A^{T} & \text{if op(A) == NVPL_SPARSE_OPERATION_TRANSPOSE} \\ A^{H} & \text{if op(A) ==NVPL_SPARSE_OPERATION_CONJUGATE_TRANSPOSE} \\ \end{cases}\)
The function nvpl_sparse_spmv_buffer_size() returns the size of the workspace needed by nvpl_sparse_spmv_analysis()
Param. |
In/out |
Meaning |
|---|---|---|
|
IN |
Handle to the NVPL Sparse library context |
|
IN |
Operation |
|
IN |
\(\alpha\) scalar used for multiplication of type |
|
IN |
Sparse matrix |
|
IN |
Dense vector |
|
IN |
\(\beta\) scalar used for multiplication of type |
|
IN |
Dense vector |
|
OUT |
Dense vector |
|
IN |
Datatype in which the computation is executed |
|
IN |
Algorithm for the computation |
|
OUT |
Number of bytes of workspace needed by |
|
IN/OUT |
Pointer to a workspace buffer of at least |
|
IN/OUT |
Opaque descriptor for storing internal data used across the three steps |
The sparse matrix formats currently supported are listed below:
NVPL_SPARSE_FORMAT_COONVPL_SPARSE_FORMAT_CSRNVPL_SPARSE_FORMAT_CSCNVPL_SPARSE_FORMAT_SLICED_ELL
nvpl_sparse_spmv supports the following index type for representing the sparse matrix mat_A:
32-bit indices (
NVPL_SPARSE_INDEX_32I)64-bit indices (
NVPL_SPARSE_INDEX_64I)
nvpl_sparse_spmv() supports the following data types:
Uniform-precision computation:
|
|---|
|
|
|
|
nvpl_sparse_spmv() supports the following algorithms:
Algorithm |
Notes |
|---|---|
|
Default algorithm for any sparse matrix format. |
|
Default algorithm for COO sparse matrix format. May produce slightly different results during different runs with the same input parameters. |
|
Default algorithm for CSR/CSC sparse matrix format. May produce slightly different results during different runs with the same input parameters. |
|
Default algorithm for Sliced Ellpack sparse matrix format. Provides deterministic (bit-wise) results for each run. |
Performance notes:
NVPL_SPARSE_SPMV_CSR_ALG1provide higher performance thanNVPL_SPARSE_SPMV_COO_ALG1.
nvpl_sparse_spmv() has the following properties:
The routine requires extra storage for CSR/CSC format.
The routine allows the indices of
matAto be unsorted.
See nvpl_sparse_status_t for the description of the return status.
nvpl_sparse_spsv()#
nvpl_sparse_status_t
nvpl_sparse_spsv_create_descr(nvpl_sparse_spsv_descr_t* descr)
nvpl_sparse_status_t
nvpl_sparse_spsv_destroy_descr(nvpl_sparse_spsv_descr_t descr)
nvpl_sparse_status_t
nvpl_sparse_spsv_buffer_size(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spsv_alg_t alg,
nvpl_sparse_spsv_descr_t spsv_descr,
size_t* buffer_size)
nvpl_sparse_status_t
nvpl_sparse_spsv_analysis(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spsv_alg_t alg,
nvpl_sparse_spsv_descr_t spsv_descr,
void* external_buffer)
nvpl_sparse_status_t
nvpl_sparse_spsv_solve(nvpl_sparse_handle_t handle,
nvpl_sparse_operation_t op_A,
const void* alpha,
nvpl_sparse_const_sp_mat_descr_t mat_A,
nvpl_sparse_const_dn_vec_descr_t vec_X,
nvpl_sparse_dn_vec_descr_t vec_Y,
nvpl_sparse_data_type_t compute_type,
nvpl_sparse_spsv_alg_t alg,
nvpl_sparse_spsv_descr_t spsv_descr)
nvpl_sparse_status_t
nvpl_sparse_spsv_update_matrix(nvpl_sparse_handle_t handle,
nvpl_sparse_spsv_descr_t spsv_descr,
void* new_values,
nvpl_sparse_spsv_update_t update_part)
The function solves a system of linear equations whose coefficients are represented in a sparse triangular matrix:
\(op\left( \mathbf{A} \right) \cdot \mathbf{Y} = \alpha\mathbf{X}\) |
where
op(A)is a sparse square matrix of size \(m \times m\)Xis a dense vector of size \(m\)Yis a dense vector of size \(m\)\(\alpha\) is a scalar
Also, for matrix A
\(\text{op}(A) = \begin{cases} A & \text{if op(A) == NVPL_SPARSE_OPERATION_NON_TRANSPOSE} \\ A^{T} & \text{if op(A) == NVPL_SPARSE_OPERATION_TRANSPOSE} \\ A^{H} & \text{if op(A) == NVPL_SPARSE_OPERATION_CONJUGATE_TRANSPOSE} \\ \end{cases}\)
The function nvpl_sparse_spsv_buffer_size() returns the size of the workspace needed by nvpl_sparse_spsv_analysis() and nvpl_sparse_spsv_solve().
The function nvpl_sparse_spsv_analysis() performs the analysis phase, while nvpl_sparse_spsv_solve() executes the solve phase for a sparse triangular linear system.
The opaque data structure spsv_descr is used to share information among all functions.
The function nvpl_sparse_spsv_update_matrix() updates spsv_descr with new matrix values.
The routine supports arbitrary sparsity for the input matrix, but only the upper or lower triangular part is taken into account in the computation.
NOTE: all parameters must be consistent across nvpl_sparse_spsv API calls and the matrix descriptions and external_buffer must not be modified between nvpl_sparse_spsv_analysis() and nvpl_sparse_spsv_solve(). The function nvpl_sparse_spsv_update_matrix() can be used to update the values on the sparse matrix stored inside the opaque data structure spsv_descr
Param. |
Memory |
Meaning |
|---|---|---|
|
IN |
Handle to the NVPL Sparse library context |
|
IN |
Operation |
|
IN |
\(\alpha\) scalar used for multiplication of type |
|
IN |
Sparse matrix |
|
IN |
Dense vector |
|
IN/OUT |
Dense vector |
|
IN |
Datatype in which the computation is executed |
|
IN |
Algorithm for the computation |
|
OUT |
Number of bytes of workspace needed by |
|
IN/OUT |
Pointer to a workspace buffer of at least |
|
IN/OUT |
Opaque descriptor for storing internal data used across the three steps |
The sparse matrix formats currently supported are listed below:
NVPL_SPARSE_FORMAT_CSRNVPL_SPARSE_FORMAT_COONVPL_SPARSE_FORMAT_SLICED_ELL
The nvpl_sparse_spsv supports the following shapes and properties:
NVPL_SPARSE_FILL_MODE_LOWERandNVPL_SPARSE_FILL_MODE_UPPERfill modesNVPL_SPARSE_DIAG_TYPE_NON_UNITandNVPL_SPARSE_DIAG_TYPE_UNITdiagonal types
nvpl_sparse_spsv supports the following index type for representing the sparse matrix mat_A:
32-bit indices (
NVPL_SPARSE_INDEX_32I)64-bit indices (
NVPL_SPARSE_INDEX_64I)
nvpl_sparse_spsv supports the following data types:
Uniform-precision computation:
|
|---|
|
|
|
|
nvpl_sparse_spsv supports the following algorithms:
Algorithm |
Notes |
|---|---|
|
Default algorithm |
nvpl_sparse_spsv has the following properties:
The routine requires extra storage for the analysis phase which is proportional to number of non-zero entries of the sparse matrix
Provides deterministic (bit-wise) results for each run for the solving phase
nvpl_sparse_spsv_solve()The routine supports in-place operation
nvpl_sparse_spsv_buffer_size()andnvpl_sparse_spsv_analysis()routines acceptNULLforvec_Xandvec_YThe routine allows the indices of
mat_Ato be unsorted
nvpl_sparse_spsv_update_matrix() updates the sparse matrix after calling the analysis phase. This functions supports the following update strategies (update_part):
Strategy |
Notes |
|---|---|
|
Updates the sparse matrix values with values of |
|
Updates the diagonal part of the matrix with diagonal values stored in |
See nvpl_sparse_status_t for the description of the return status.