Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor MGR coarse level matrix computation #1102

Merged
merged 21 commits into from
Jul 12, 2024
Merged

Conversation

victorapm
Copy link
Contributor

Main changes are:

  • Simplify hypre_MGRSetup implementation
  • Add HYPRE_MGRSetNonGalerkinMaxElmts to control truncation in MGR's non-galerkin option
  • Fix MGR's non-galerkin truncation for max_elmts == 0 (no truncation)
  • Add dedicated file par_mgr_rap.c for coarse level matrix computation routines
  • Add restriction operator info to MGR statistics

Additional changes that follow up:

  • Add hypre_CSRMatrixTruncateDiag to truncate a matrix to its diagonal
  • Add utilities/stl_ops.c for STL-like operations valid for host and device.

{
AP = hypre_ParCSRMatMat(A, P);
RAP = hypre_ParCSRMatMat(R, AP);
hypre_CSRMatrixReorder(hypre_ParCSRMatrixDiag(RAP));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me why we are reordering here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from some time ago and I'm not 100% sure, but I believe it's because hypre_ParCSRMatMat doesn't guarantee that the diagonal entry goes first. So the reorder is to guarantee that. @liruipeng is this correct?

#include <math.h>

/*--------------------------------------------------------------------
* hypre_IntSequence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a description of what this function is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f6cfb03


/* Destroy temporary variables */
hypre_ParCSRMatrixDestroy(A_FC), A_FC = NULL;
hypre_ParCSRMatrixDestroy(A_CF), A_CF = NULL;
hypre_ParCSRMatrixDestroy(A_CC), A_CF = NULL;
hypre_ParCSRMatrixDestroy(A_CC), A_CC = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@@ -617,7 +612,7 @@ hypre_MGRSetup( void *mgr_vdata,
/* Allocate memory for level structure */
if (A_array == NULL)
{
A_array = hypre_CTAlloc(hypre_ParCSRMatrix*, max_num_coarse_levels, HYPRE_MEMORY_HOST);
A_array = hypre_CTAlloc(hypre_ParCSRMatrix*, max_num_coarse_levels + 1, HYPRE_MEMORY_HOST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still wrapping my head around this one vs using the RAP_ptr, but it is not a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This saves me some lines of code for computing MGR statistics in par_mgr_stats.c

Copy link
Contributor

@oseikuffuor1 oseikuffuor1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@victorapm, this looks good to me, thanks!

@victorapm victorapm requested review from rfalgout and removed request for rfalgout July 3, 2024 22:49
Copy link
Contributor

@rfalgout rfalgout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@victorapm victorapm merged commit 5de2c5c into master Jul 12, 2024
@victorapm victorapm deleted the mgr-coarse-grid branch July 12, 2024 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants