[GSoC] Feature: Jacobi preconditioner on GPU and CUDA Unified preconditiong matrix#2843
[GSoC] Feature: Jacobi preconditioner on GPU and CUDA Unified preconditiong matrix#2843ddg93 wants to merge 5 commits into
Conversation
… allocation of the preconditioning matrix.
|
That's great! |
pcarruscag
left a comment
There was a problem hiding this comment.
I think Areen looked into unified memory a bit.
Do you have some performance measurements? I imagine we save on the data transfer but suffer a little on the kernel performance?
Does unified memory introduce a significant restriction in terms of the required compute capability?
…ted on 1 test-case.
…ogic from device pointers. Validated on test-case turb_SA_RAE2822 comparing residuals over 100 iterations.
d12fd4b to
e070ec7
Compare
Thanks for the heads-up. Updated that commit and the following ones. |
For the moment, I've only one performance measurement on my local GPU Quadro P620:
Preliminary profiling shows indeed that the transfer of the preconditioning matrix is asynchronously launched but then the preconditioning kernel takes longer due to page fault. I intend to better profile what is going on with the CSysVector Unified memory implementation. Unified memory is available for the compute capability 6.0 or higher. Some of its advanced features seem to depend on the system. Is there some report by Areen? It could be interesting for me to read it. |
|
Thanks I was wondering about unified vs explicit transfers not CPU vs GPU. |
Proposed Changes
This draft PR introduces CUDA Unified memory allocation and management for the CSysVector class and the preconditioning matrix inside the Jacobi preconditioner. Also, this draft PR extends the section of GPU execution inside the FGMRES solver. Custom CUDA kernels are implemented for the preconditioning matrix, the multi dot product and the linear combination (the first operations of the Modified Gram-Schmidt orthogonalization).
The solver logic is not modified, and the GPU path is hidden inside the specific methods. A custom data() method recovers the CSysVector Unified pointer inside the CUDA logic, cleaning the logic from the double host/device pointers. All memory explicit memory copies are also removed from the CUDA logic, but explicit device synchronizations are introduced around MPI calls and at the end of the CUDA section.
Performance evaluation (on-going)
for the considered test-case (rae2822), the CPU execution expresses an Avg. s/iter: 0.198681 while the GPU execution expresses an Avg. s/iter: 0.256129 on my local Quadro P620 GPU.
I intend to perform more tests on more advanced hardware, considering different test-cases and evaluating against the CPU version and a GPU version with separated device and host pointers and memory copies.
Asynchronous pre-fetching:
The Jacobi preconditioner calculations are performed on GPU through a new custom CUDA kernel through the preconditioner abstraction.
The preconditioning matrix is selected to test CUDA Unified Memory asynchronous prefetching to the GPU.
For simplicity, the double CPU/GPU pointer is still maintained in the current logic, although the device pointer reduces to an alias for the Unified Memory pointer when this kind of allocation is adopted.
This strategy introduces a simple context to test the CUDA Unified Memory usage and study the possibility of overlapping memory transfers and calculations without the need to introduce CUDA streams.
Concretely, this PR:
This work is part of my ongoing contribution during the Google Summer of Code 2026 program.
Validation
Validated locally with:
Nsys profiling was performed to confirm the asynchronous prefetching of the CUDA Unified Memory preconditioning matrix on my local GPU. Partial prefetching is observed, although page faults were reported during the preconditioner CUDA kernel, indicating that the calculations were slowed down by the prefetching matrix still being transferred to the GPU. This overlap is expected to largely improve on more modern hardware; tests are ongoing in the cloud.
Related Work
The Jacobi preconditioner kernels come from the PR #2825.
Observed Issues
Some issues were observed during this first period of GSoC:
Next steps
I propose to continue working on the following steps:
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.