[GSoC] Feature: LU-SGS preconditioner to GPU - #2872
Conversation
…preconditioner level approach. Validated against corresponding CPU method finding matching prod vectors down to machine precision
|
Oh and add yourself to AUTHORS.md please |
…SGS into two methods to keep unique MPI pattern, introduced Q_LUSGS on GPU
…' into feature_gpu_lusgs_preconditioner
|
The pointed issues have been addressed for the GPU LU-SGS. Also, I've added the Quantized mode through a bool runtime control passed to the kernels. I've performed some tests on my CPU with the RAE2822 test-case:
I am wondering if this divergence between CPU and GPU when running with multiple MPI tasks is expected? To be sure, I run the same test with the ILU preconditioner and the version of the HEAD of the develop branch: matched residuals in serial and 4 OPENMP threads, non matching residuals when running with 4 MPI threads. Moreover, the GPU residuals drop and become positive. For this reason, I though that the issue might not be in the modifications introduced in this PR and pushed. |
| /*! | ||
| * \brief Apply the forward pass of the LU-SGS preconditioner | ||
| */ | ||
| void ComputeLU_SGSPreconditionerForward(const CSysVector<ScalarType>& vec, CSysVector<ScalarType>& prod) const; | ||
|
|
||
| /*! | ||
| * \brief Apply the backward pass of the LU-SGS preconditioner | ||
| */ | ||
| void ComputeLU_SGSPreconditionerBackward(CSysVector<ScalarType>& prod) const; | ||
|
|
There was a problem hiding this comment.
Move to the private part of the class members
| /*--- First part of the symmetric iteration: (D+L).x* = b ---*/ | ||
| if (precond_fwd_graph_exec == nullptr || precond_fwd_graph_vec != d_vec || precond_fwd_graph_prod != d_prod) { | ||
| if (precond_fwd_graph_exec != nullptr) { | ||
| gpuErrChk(cudaGraphExecDestroy(precond_fwd_graph_exec)); | ||
| precond_fwd_graph_exec = nullptr; | ||
| } |
There was a problem hiding this comment.
Is it worth using the graph when the vectors are always changing? Does that only happen with FGMRES?
|
Looks good, yes MPI is expected not to work, the communications are only using the CPU values, we would have to download and reupload vectors, which would be inefficient, so the best bet for now is OpenMP |
This PR ports the LU-SGS preconditioner to GPU
Proposed Changes
This PR introduces a build phase for the LU-SGS preconditioner where the inverse of the diagonal D is calculated to facilitate the compute phase. Then, forward and backward sweeps are implemented through custom CUDA kernels matching the logic of the CPU section (except for the inverse of D, which is directly multiplied in the GPU logic). These kernels are managed by the compute method on GPU which maintains the MPI communications.
Related Work
This PR follows the discussion of #2843 . Kernel level dependencies are managed as for the ILU preconditioner proposed in #2858 .
Validation
CPU and GPU implementations of the LU-SGS preconditioner are compared for validation of this PR on the rae2822 test-case. After one iteration, the first, preconditioned Krylov vector is compared finding matching results down to machine precision. Residuals are compared after 100 iterations finding matching results.
TO-DO
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.