pub struct SparseMatrixDescriptor<'a> { /* private fields */ }Implementations§
Source§impl<'a> SparseMatrixDescriptor<'a>
impl<'a> SparseMatrixDescriptor<'a>
Sourcepub fn create_csr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
rows: usize,
cols: usize,
nonzero_count: usize,
row_offsets: &'a mut DeviceMemory<Offsets>,
column_indices: &'a mut DeviceMemory<Columns>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
) -> Result<Self>
pub fn create_csr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, row_offsets: &'a mut DeviceMemory<Offsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>
Initializes a sparse matrix descriptor in the CSR format.
The descriptor borrows the row-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.
Sourcepub fn create_csc<Offsets: IndexTypeLike, Rows: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
rows: usize,
cols: usize,
nonzero_count: usize,
column_offsets: &'a mut DeviceMemory<Offsets>,
row_indices: &'a mut DeviceMemory<Rows>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
) -> Result<Self>
pub fn create_csc<Offsets: IndexTypeLike, Rows: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, column_offsets: &'a mut DeviceMemory<Offsets>, row_indices: &'a mut DeviceMemory<Rows>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>
Initializes a sparse matrix descriptor in the CSC format.
The descriptor borrows the column-offset, row-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.
Sourcepub fn create_coo<I: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
rows: usize,
cols: usize,
nonzero_count: usize,
row_indices: &'a mut DeviceMemory<I>,
column_indices: &'a mut DeviceMemory<I>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
) -> Result<Self>
pub fn create_coo<I: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, row_indices: &'a mut DeviceMemory<I>, column_indices: &'a mut DeviceMemory<I>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>
Initializes a sparse matrix descriptor in the COO format (Structure of Arrays layout).
The descriptor borrows the row-index, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.
Sourcepub fn create_bsr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
block_rows: usize,
block_cols: usize,
block_nnz: usize,
row_block_size: usize,
col_block_size: usize,
row_offsets: &'a mut DeviceMemory<Offsets>,
column_indices: &'a mut DeviceMemory<Columns>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
order: Order,
) -> Result<Self>
pub fn create_bsr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, block_rows: usize, block_cols: usize, block_nnz: usize, row_block_size: usize, col_block_size: usize, row_offsets: &'a mut DeviceMemory<Offsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, order: Order, ) -> Result<Self>
Initializes a sparse matrix descriptor for the Block Compressed Row (BSR) format.
The descriptor borrows the block row-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.
Sourcepub fn create_blocked_ell<I: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
rows: usize,
cols: usize,
block_size: usize,
ell_cols: usize,
column_indices: &'a mut DeviceMemory<I>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
) -> Result<Self>
pub fn create_blocked_ell<I: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, block_size: usize, ell_cols: usize, column_indices: &'a mut DeviceMemory<I>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>
Initializes a sparse matrix descriptor for the Blocked-Ellpack (ELL) format.
Blocked-ELL column indices are in the range 0..cols / ell_block_size.
The array can contain -1 values for indicating empty blocks.
The descriptor borrows the column-index and value buffers by pointer;
those buffers must remain valid while the descriptor uses them.
Sourcepub fn create_sliced_ell<SliceOffsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>(
ctx: &Context,
rows: usize,
cols: usize,
nonzero_count: usize,
values_size: usize,
slice_size: usize,
slice_offsets: &'a mut DeviceMemory<SliceOffsets>,
column_indices: &'a mut DeviceMemory<Columns>,
values: &'a mut DeviceMemory<T>,
index_base: IndexBase,
) -> Result<Self>
pub fn create_sliced_ell<SliceOffsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, values_size: usize, slice_size: usize, slice_offsets: &'a mut DeviceMemory<SliceOffsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>
Initializes a sparse matrix descriptor for the Sliced Ellpack (SELL) format.
The descriptor borrows the slice-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.
Sourcepub fn format(&self) -> Result<Format>
pub fn format(&self) -> Result<Format>
Returns the format of this sparse matrix descriptor.
§Errors
Returns an error if cuSPARSE cannot report the sparse matrix format.
Sourcepub fn index_base(&self) -> Result<IndexBase>
pub fn index_base(&self) -> Result<IndexBase>
Returns the index base of this sparse matrix descriptor.
§Errors
Returns an error if cuSPARSE cannot report the sparse matrix index base.
Sourcepub fn values(&self) -> Result<DevicePtr>
pub fn values(&self) -> Result<DevicePtr>
Returns the values pointer of this sparse matrix descriptor.
§Errors
Returns an error if cuSPARSE cannot report the values pointer.
Sourcepub fn set_values<T: DataTypeLike>(
&mut self,
values: &'a mut DeviceMemory<T>,
) -> Result<()>
pub fn set_values<T: DataTypeLike>( &mut self, values: &'a mut DeviceMemory<T>, ) -> Result<()>
Sets the values pointer of this sparse matrix descriptor.
The pointed-to device buffer must remain valid while the descriptor uses it.
§Errors
Returns an error if cuSPARSE rejects the values pointer.
Sourcepub fn shape(&self) -> Result<SparseMatrixShape>
pub fn shape(&self) -> Result<SparseMatrixShape>
Returns the shape of this sparse matrix descriptor.
§Errors
Returns an error if cuSPARSE cannot report the sparse matrix shape or if
the reported values cannot be represented as usize.
Sourcepub fn strided_batch_count(&self) -> Result<i32>
pub fn strided_batch_count(&self) -> Result<i32>
Returns the batch count of this sparse matrix descriptor.
§Errors
Returns an error if cuSPARSE cannot report the strided batch settings.
Sourcepub fn set_coo_strided_batch(
&mut self,
batch_count: usize,
batch_stride: usize,
) -> Result<()>
pub fn set_coo_strided_batch( &mut self, batch_count: usize, batch_stride: usize, ) -> Result<()>
Sets the batch count and batch stride fields of this COO sparse matrix descriptor.
§Errors
Returns an error if either argument cannot be represented by cuSPARSE or if cuSPARSE rejects the strided batch settings.
Sourcepub fn set_csr_strided_batch(
&mut self,
batch_count: usize,
offsets_batch_stride: usize,
columns_values_batch_stride: usize,
) -> Result<()>
pub fn set_csr_strided_batch( &mut self, batch_count: usize, offsets_batch_stride: usize, columns_values_batch_stride: usize, ) -> Result<()>
Sets the batch count and batch stride fields of this CSR sparse matrix descriptor.
Sourcepub fn set_bsr_strided_batch(
&mut self,
batch_count: usize,
offsets_batch_stride: usize,
columns_batch_stride: usize,
values_batch_stride: usize,
) -> Result<()>
pub fn set_bsr_strided_batch( &mut self, batch_count: usize, offsets_batch_stride: usize, columns_batch_stride: usize, values_batch_stride: usize, ) -> Result<()>
Sets the batch count and batch stride fields of this BSR sparse matrix descriptor.
pub fn fill_mode(&self) -> Result<FillMode>
pub fn set_fill_mode(&mut self, fill_mode: FillMode) -> Result<()>
pub fn diagonal_type(&self) -> Result<DiagonalType>
pub fn set_diagonal_type(&mut self, diagonal_type: DiagonalType) -> Result<()>
Sourcepub fn set_csr_pointers(
&mut self,
row_offsets: &'a mut DeviceMemory<impl IndexTypeLike>,
column_indices: &'a mut DeviceMemory<impl IndexTypeLike>,
values: &'a mut DeviceMemory<impl DataTypeLike>,
) -> Result<()>
pub fn set_csr_pointers( &mut self, row_offsets: &'a mut DeviceMemory<impl IndexTypeLike>, column_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>
Sets the pointers of this CSR sparse matrix descriptor.
The pointed-to device buffers must remain valid while the descriptor uses them.
Sourcepub fn set_csc_pointers(
&mut self,
column_offsets: &'a mut DeviceMemory<impl IndexTypeLike>,
row_indices: &'a mut DeviceMemory<impl IndexTypeLike>,
values: &'a mut DeviceMemory<impl DataTypeLike>,
) -> Result<()>
pub fn set_csc_pointers( &mut self, column_offsets: &'a mut DeviceMemory<impl IndexTypeLike>, row_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>
Sets the pointers of this CSC sparse matrix descriptor.
The pointed-to device buffers must remain valid while the descriptor uses them.
Sourcepub fn set_coo_pointers(
&mut self,
row_indices: &'a mut DeviceMemory<impl IndexTypeLike>,
column_indices: &'a mut DeviceMemory<impl IndexTypeLike>,
values: &'a mut DeviceMemory<impl DataTypeLike>,
) -> Result<()>
pub fn set_coo_pointers( &mut self, row_indices: &'a mut DeviceMemory<impl IndexTypeLike>, column_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>
Sets the pointers of this COO sparse matrix descriptor.
The pointed-to device buffers must remain valid while the descriptor uses them.
pub fn as_raw(&self) -> cusparseSpMatDescr_t
pub fn as_raw_const(&self) -> cusparseConstSpMatDescr_t
pub fn cuda_context(&self) -> &Arc<CudaContext>
Sourcepub unsafe fn from_raw(
handle: cusparseSpMatDescr_t,
ctx: &Context,
) -> Result<Self>
pub unsafe fn from_raw( handle: cusparseSpMatDescr_t, ctx: &Context, ) -> Result<Self>
Wraps an existing cuSPARSE sparse-matrix descriptor and takes ownership of it.
§Safety
handle must be a valid cusparseSpMatDescr_t. Any device buffers
referenced by the descriptor must remain valid for lifetime 'a.
Ownership of handle is transferred to the returned descriptor, and the
handle must not be destroyed elsewhere after calling this function.
Sourcepub fn into_raw(self) -> cusparseSpMatDescr_t
pub fn into_raw(self) -> cusparseSpMatDescr_t
Consumes the descriptor and returns the raw cuSPARSE handle without destroying it.
The caller becomes responsible for eventually destroying the returned
handle with cusparseDestroySpMat.