fix reordering option for diagonal of square matrix transpose (#370)

* Remove hard option to reorder transpose operation to place diagonal in first entry for square matrices. Implement this locally as needed.

*Add runtime option to switch to GPU support

Co-authored-by: Ruipeng Li <li50@llnl.gov>
This commit is contained in:
Daniel Osei-Kuffuor 2021-05-19 12:35:27 -07:00 committed by GitHub
parent ae362727b9
commit 995969c9af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 18 deletions

View File

@ -3205,6 +3205,8 @@ hypre_MGRBuildRestrict(hypre_ParCSRMatrix *A,
}
else if (restrict_type == 3)
{
/* move diagonal to first entry */
hypre_CSRMatrixReorder(hypre_ParCSRMatrixDiag(AT));
hypre_MGRBuildInterpApproximateInverse(AT, CF_marker, num_cpts_global, debug_flag, &R_ptr);
hypre_BoomerAMGInterpTruncation(R_ptr, trunc_factor, max_elmts);
}

View File

@ -1235,12 +1235,6 @@ hypre_CSRMatrixTransposeHost(hypre_CSRMatrix *A,
hypre_CSRMatrixI(*AT)[num_cols_A] = num_nnzs_A;
hypre_TFree(bucket, HYPRE_MEMORY_HOST);
/* Move diagonal to first entry (for square matrices only)*/
if(num_rows_A == num_cols_A)
{
hypre_CSRMatrixReorder(*AT);
}
// Set rownnz and num_rownnz
if (hypre_CSRMatrixNumRownnz(A) < num_rows_A)
{
@ -1515,7 +1509,7 @@ HYPRE_Int hypre_CSRMatrixSplit(hypre_CSRMatrix *Bs_ext,
*--------------------------------------------------------------------------*/
HYPRE_Int
hypre_CSRMatrixReorder(hypre_CSRMatrix *A)
hypre_CSRMatrixReorderHost(hypre_CSRMatrix *A)
{
HYPRE_Complex *A_data = hypre_CSRMatrixData(A);
HYPRE_Int *A_i = hypre_CSRMatrixI(A);
@ -1556,6 +1550,27 @@ hypre_CSRMatrixReorder(hypre_CSRMatrix *A)
return hypre_error_flag;
}
HYPRE_Int
hypre_CSRMatrixReorder(hypre_CSRMatrix *A)
{
HYPRE_Int ierr = 0;
#if defined(HYPRE_USING_CUDA) || defined(HYPRE_USING_HIP)
HYPRE_ExecutionPolicy exec = hypre_GetExecPolicy1( hypre_CSRMatrixMemoryLocation(A) );
if (exec == HYPRE_EXEC_DEVICE)
{
ierr = hypre_CSRMatrixMoveDiagFirstDevice(A);
}
else
#endif
{
ierr = hypre_CSRMatrixReorderHost(A);
}
return ierr;
}
/*--------------------------------------------------------------------------
* hypre_CSRMatrixAddPartial:
* adds matrix rows in the CSR matrix B to the CSR Matrix A, where row_nums[i]

View File

@ -1206,15 +1206,7 @@ hypre_CSRMatrixTransposeDevice(hypre_CSRMatrix *A,
*AT_ptr = C;
hypre_SyncCudaComputeStream(hypre_handle());
/* Put diagonal at first entry (for square matrices only)*/
if(nrows_A == ncols_A)
{
#if defined(HYPRE_USING_CUDA) || defined(HYPRE_USING_HIP)
hypre_CSRMatrixMoveDiagFirstDevice( *AT_ptr );
#endif
}
hypre_SyncCudaComputeStream(hypre_handle());
return hypre_error_flag;
}

View File

@ -24,7 +24,7 @@ Final Relative Residual Norm = 7.212489e-09
# Output file: elast.out.6
Iterations = 14
Final Relative Residual Norm = 1.005959e-09
Final Relative Residual Norm = 1.005958e-09
# Output file: elast.out.7
Iterations = 16

View File

@ -339,7 +339,7 @@ Final Relative Residual Norm = 7.556742e-09
# Output file: solvers.out.307
hypre_ILU Iterations = 38
Final Relative Residual Norm = 7.037600e-09
Final Relative Residual Norm = 7.037599e-09
# Output file: solvers.out.308
hypre_ILU Iterations = 26