rocsparse_spvv Interface Reference

rocsparse_spvv Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_spvv Interface Reference
hipfort_rocsparse::rocsparse_spvv Interface Reference

Sparse vector inner dot product. More...

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_spvv_ (handle, trans, x, y, myresult, compute_type, buffer_size, temp_buffer)
 

Detailed Description

Sparse vector inner dot product.

rocsparse_spvv computes the inner dot product of the sparse vector \(x\) with the dense vector \(y\), such that

\[ \text{result} := op(x) \cdot y, \]

with

\[ op(x) = \left\{ \begin{array}{ll} x, & \text{if trans == rocsparse_operation_none} \\% \bar{x}, & \text{if trans == rocsparse_operation_conjugate_transpose} \\% \end{array} \right. \]

result = 0;
for(i = 0; i < nnz; ++i)
{
result += x_val[i] * y[x_ind[i]];
}

Performing the above operation involves two steps. First, call rocsparse_spvv with temp_buffer set to nullptr, which will return the required temporary buffer size in the parameter buffer_size. Then allocate this buffer. Finally, complete the computation by calling rocsparse_spvv a second time with the newly allocated buffer. After the computation is complete, deallocate the buffer.

rocsparse_spvv supports the following uniform and mixed-precision data types for the sparse and dense vectors \(x\) and \(y\) and compute types for the scalar result.

Uniform Precisions:
Uniform Precisions
X / Y / compute_type
rocsparse_datatype_f32_r
rocsparse_datatype_f64_r
rocsparse_datatype_f32_c
rocsparse_datatype_f64_c
Mixed Precisions:
Mixed Precisions
X / Y compute_type / result
rocsparse_datatype_i8_r rocsparse_datatype_i32_r
rocsparse_datatype_i8_r rocsparse_datatype_f32_r
rocsparse_datatype_f16_r rocsparse_datatype_f32_r
rocsparse_datatype_bf16_r rocsparse_datatype_f32_r
Note
This function writes the required allocation size (in bytes) to buffer_size and returns without performing the SpVV operation when a nullptr is passed for temp_buffer.
This function is blocking with respect to the host.
This routine does not support execution in a hipGraph context.
This routine does not support batched computation.
Parameters
[in]handle- handle to the rocSPARSE library context queue.
[in]trans- sparse vector operation type.
[in]x- sparse vector descriptor.
[in]y- dense vector descriptor.
[out]myResult- pointer to the result, which can be in host or device memory.
[in]compute_type- floating point precision for the SpVV computation.
[out]buffer_size- number of bytes of the temporary storage buffer. buffer_size is set when temp_buffer is nullptr.
[in]temp_buffer- temporary storage buffer allocated by the user. When a nullptr is passed, the required allocation size (in bytes) is written to buffer_size and the function returns without performing the SpVV operation.
Return values
rocsparse_status_successthe operation completed successfully.
rocsparse_status_invalid_handlethe library context was not initialized.
rocsparse_status_invalid_pointerx, y, result, or buffer_size pointer is invalid.
rocsparse_status_not_implementedcompute_type is currently not supported.
Example

Member Function/Subroutine Documentation

◆ rocsparse_spvv_()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_spvv::rocsparse_spvv_ ( type(c_ptr), value  handle,
integer(kind(rocsparse_operation_none)), value  trans,
type(c_ptr), value  x,
type(c_ptr), value  y,
type(c_ptr), value  myresult,
integer(kind(rocsparse_datatype_f16_r)), value  compute_type,
integer(c_size_t)  buffer_size,
type(c_ptr), value  temp_buffer 
)

The documentation for this interface was generated from the following file: