[petsc-users] Ask for help in tracking down bugs - setting #threads for pardiso block LU solver

Barry Smith bsmith at petsc.dev
Fri Sep 27 10:20:34 CDT 2024


   Boris,

     There is nothing obviously wrong with what you outline, so let's dive down into the code with the debugger and see what is happening.

PetscSetMKL_PARDISOThreads() set from options is called when the command line option is provided, and this calls 

PETSC_EXTERN void PetscSetMKL_PARDISOThreads(int threads)
{
  mkl_domain_set_num_threads(threads, MKL_DOMAIN_PARDISO);
}

so in the debugger can you check that mkl_domain_set_num_threads() gets called with your requested number of threads?

BTW: Since you are hardwiring the use of Pardiso in the code with function calls you couldsimply call PetscSetMKL_PARDISOThreads() directly
after your line of code

PCFactorSetMatSolverType(subPc, MATSOLVERMKL_PARDISO);       set solver for LU

instead of feeding it in through the options database.

Let us know how this turns out

  Barry





> On Sep 27, 2024, at 7:24 AM, Voinov, Boris <boris.voinov at intel.com> wrote:
> 
> Hello,
>  
> Could you please help me to figure out what’s wrong with the way I’m trying to make mkl pardiso use the number of threads more than one while setting it as a sub PC solver for ASM preconditioner.
> Here is how I do this
> Loop over block PCs {
>   PCSetType(subPc, PCLU);             set subPC type
>   PCFactorSetMatSolverType(subPc, MATSOLVERMKL_PARDISO);       set solver for LU
>   SetPardisoParams("pardiso");      set mkl related options including -mat_mkl_pardiso_65 equal to the desired #threads; return code after PetscOptionsSetValue is ok, so I presume the option is set correctly. 
>   PCSetFromOptions(subPc);
> }
>  
> Then what I see under the debugger
> PCSetUp after a series of calls gets to MatLUFactorSymbolic_AIJMKL_PARDISO which in turn calls MatSetFromOptions_MKL_PARDISO(F, A) and there
> in these lines it seems to ignore what I’ve set for -mat_mkl_pardiso_65 and sets #threads to the default 1
> PetscCall(PetscOptionsInt("-mat_mkl_pardiso_65", "Suggested number of threads to use within PARDISO", "None", threads, &threads, &flg));
> if (flg) PetscSetMKL_PARDISOThreads((int)threads);
>  
> This is about petsc-3.20.
> PS when I do this in a standalone code which reads a matrix and solves the linear system and set -mat_mkl_pardiso_65 in the command line it’s all right but I need the number of threads to be set in other way in my code.
>  
> Thank you and best regards,
> Boris
>  
> -------------------------------------------------------------
> Intel Ireland Limited (Branch)
> Collinstown Industrial Park, Leixlip, County Kildare, Ireland
> Registered Number: E902934
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240927/d9a4682d/attachment.html>


More information about the petsc-users mailing list