Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6986 Discussions

Calling Iterative Sparse Solver from C++, Preconditioning Problems, Multiple Right Hand Side,

recage
Beginner
479 Views
Problem: when solving a MRHS problem with the iterative sparse solver (called from C++), it does not seem to put the current residual in the right place, so that it can be utilized by the preconditioner (i.e. when RCI_Request==3).

For a single RHS problems the function 'dcg' puts the current residual into the array tmp(:,3), which can be used by the preconditioner. That's fine.
However, for multiple RHS problems the function 'dcgmrhs' is supposed to put the residual into tmp(:,3+ipar(3)), but this doesn't seem to be true. Hence, the preconditioner can not proceed with its job. How can I instruct 'dcgmrhs' to store the residuals in tmp(:,3+ipar(3))?
Or is there a misunderstanding on my side?

I have observed this behavior when calling the functions from C++.

Best regards, Recage
0 Kudos
1 Solution
Alexander_K_Intel2
479 Views
Quoting - recage
Dear Alexander, thanks for replying again.

Here ist the code segment for the preconditioning. The full source of the function is in the attachments.

[cpp]/*---------------------------------------------------------------------------*/
	/* If rci_request=3, then compute apply the preconditioner matrix C_inverse  */
	/* on vector tmp(:,3+ipar(3)) and put the result in vector tmp(:,3)          */
	/* (Fortran notation)                                                        */
	/*---------------------------------------------------------------------------*/
	if (rci_request==3)
	{
		mkl_dcsrsv(&matdes[2], &n, &one, matdes, a, ja, ia, &ia[1], &tmp[(3+ipar[2]-1)*n], &tmp[2*n]);
		goto rci;
	}[/cpp]
Best regards,
Recage
Recage,
First of all, what is not good in such precondition... CG and CGMHRS work with symmetric positive define system, thats mean that precondition must be symmetric positive define! If it's not nobody can guarantee the right solution of your system by CGMHRS. If you interested how construct precondition based on inversion L and U parts of initial matrix, you can look incg_ssor_precon_c.c in MKL examples. In that example precondition named SSOR construct.
With best regards,
Alexander Kalinkin

View solution in original post

0 Kudos
5 Replies
Alexander_K_Intel2
479 Views
Quoting - recage
Problem: when solving a MRHS problem with the iterative sparse solver (called from C++), it does not seem to put the current residual in the right place, so that it can be utilized by the preconditioner (i.e. when RCI_Request==3).

For a single RHS problems the function 'dcg' puts the current residual into the array tmp(:,3), which can be used by the preconditioner. That's fine.
However, for multiple RHS problems the function 'dcgmrhs' is supposed to put the residual into tmp(:,3+ipar(3)), but this doesn't seem to be true. Hence, the preconditioner can not proceed with its job. How can I instruct 'dcgmrhs' to store the residuals in tmp(:,3+ipar(3))?
Or is there a misunderstanding on my side?

I have observed this behavior when calling the functions from C++.

Best regards, Recage
Hi Recage,
To more deep understanding situation could you send example of your code? The cause of my misunderstanding is that you wrote about C++ program but use Fortran definition.
With best regards,
Alexander Kalinkin
0 Kudos
recage
Beginner
479 Views
Dear Alexander, thanks for replying again.

Here ist the code segment for the preconditioning. The full source of the function is in the attachments.

[cpp]/*---------------------------------------------------------------------------*/
	/* If rci_request=3, then compute apply the preconditioner matrix C_inverse  */
	/* on vector tmp(:,3+ipar(3)) and put the result in vector tmp(:,3)          */
	/* (Fortran notation)                                                        */
	/*---------------------------------------------------------------------------*/
	if (rci_request==3)
	{
		mkl_dcsrsv(&matdes[2], &n, &one, matdes, a, ja, ia, &ia[1], &tmp[(3+ipar[2]-1)*n], &tmp[2*n]);
		goto rci;
	}[/cpp]
Best regards,
Recage
0 Kudos
Alexander_K_Intel2
480 Views
Quoting - recage
Dear Alexander, thanks for replying again.

Here ist the code segment for the preconditioning. The full source of the function is in the attachments.

[cpp]/*---------------------------------------------------------------------------*/
	/* If rci_request=3, then compute apply the preconditioner matrix C_inverse  */
	/* on vector tmp(:,3+ipar(3)) and put the result in vector tmp(:,3)          */
	/* (Fortran notation)                                                        */
	/*---------------------------------------------------------------------------*/
	if (rci_request==3)
	{
		mkl_dcsrsv(&matdes[2], &n, &one, matdes, a, ja, ia, &ia[1], &tmp[(3+ipar[2]-1)*n], &tmp[2*n]);
		goto rci;
	}[/cpp]
Best regards,
Recage
Recage,
First of all, what is not good in such precondition... CG and CGMHRS work with symmetric positive define system, thats mean that precondition must be symmetric positive define! If it's not nobody can guarantee the right solution of your system by CGMHRS. If you interested how construct precondition based on inversion L and U parts of initial matrix, you can look incg_ssor_precon_c.c in MKL examples. In that example precondition named SSOR construct.
With best regards,
Alexander Kalinkin
0 Kudos
recage
Beginner
479 Views
Recage,
First of all, what is not good in such precondition... CG and CGMHRS work with symmetric positive define system, thats mean that precondition must be symmetric positive define! If it's not nobody can guarantee the right solution of your system by CGMHRS. If you interested how construct precondition based on inversion L and U parts of initial matrix, you can look incg_ssor_precon_c.c in MKL examples. In that example precondition named SSOR construct.
With best regards,
Alexander Kalinkin

Thanks Alexander. Based on your hints I have successfully implemented a preconditioner for CGMRHS.

Best regards, Recage
0 Kudos
Alexander_K_Intel2
479 Views
Quoting - recage

Thanks Alexander. Based on your hints I have successfully implemented a preconditioner for CGMRHS.

Best regards, Recage

Recage,
You are welcome, fill free to ask more :)
With best regards,
Alexander Kalinkin
0 Kudos
Reply