[petsc-users] calling lapack for LU decomposition

Michael Povolotskyi mpovolot at purdue.edu
Mon Nov 4 21:37:02 CST 2013


On 11/4/2013 3:37 PM, Jed Brown wrote:
> Michael Povolotskyi <mpovolot at purdue.edu> writes:
>
>> Dear Petsc developers,
>> in my work I need to measure the multi threading performance of LAPACK
>> function dgetrf
>>
>> Since all matrices are of PETSc type I'd like to call Petsc functions
>> for the LU decomposition.
>> My code reads like this
>>
>> Mat A; //serial dense matrix
>>
>> PetscErrorCode ierr;
>> KSP            ksp;
>> Mat            F;
>> PC             pc;
>>
>> ierr = KSPCreate(comm, &ksp);
>> ierr = KSPSetOperators(ksp, A, A, SAME_PRECONDITIONER);
>> ierr = KSPSetType(ksp, KSPPREONLY);
>> ierr = KSPGetPC(ksp, &pc);
>> ierr = PCSetType(pc, PCLU);
>> ierr = PCFactorSetMatSolverPackage(pc, "petsc");
> This is the default.
>
>> ierr = KSPSetUp(ksp);
>> ierr = PCFactorGetMatrix(pc, &F);
> This function is not needed.
>
>> Is this a correct way to call dgetrf ?
> Yeah, run with -log_summary and look for the time spent in the
> MatLUFactorNumeric event.
>
> (You _can_ call the low-level MatLUFactor() directly, but I recommend
> what you have written because it is more general-purpose so you can
> easily switch to other methods.)
Thank you,
Michael.


More information about the petsc-users mailing list