MatSeqSELLSetPreallocation#
For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz
(or the array nnz
).
Synopsis#
#include "petscmat.h"
PetscErrorCode MatSeqSELLSetPreallocation(Mat B, PetscInt rlenmax, const PetscInt rlen[])
Collective
Input Parameters#
B - The
MATSEQSELL
matrixrlenmax - number of nonzeros per row (same for all rows), ignored if
rlen
is providedrlen - array containing the number of nonzeros in the various rows (possibly different for each row) or
NULL
Notes#
Specify the preallocated storage with either rlenmax
or rlen
(not both).
Set rlenmax
= PETSC_DEFAULT
and rlen
= NULL
for PETSc to control dynamic memory
allocation.
You can call MatGetInfo()
to get information on how effective the preallocation was;
for example the fields mallocs,nz_allocated,nz_used,nz_unneeded;
You can also run with the option -info
and look for messages with the string
malloc in them to see if additional memory allocation was needed.
Developer Note#
Use rlenmax
of MAT_SKIP_ALLOCATION
to not allocate any space for the matrix
entries or columns indices.
The maximum number of nonzeos in any row should be as accurate as possible.
If it is underestimated, you will get bad performance due to reallocation
(MatSeqXSELLReallocateSELL()
).
See Also#
Mat
, MATSEQSELL
, MATSELL
, MatCreate()
, MatCreateSELL()
, MatSetValues()
, MatGetInfo()
Level#
intermediate
Location#
Examples#
Implementations#
MatSeqSELLSetPreallocation_SeqSELL in src/mat/impls/sell/seq/sell.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages