Repository navigation
Vectorize vec_topetsc and petsc_to_psydac - #592
max-models wants to merge 14 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 99 |
| Duplication | 18 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
I thought those functions were accelerated with Pyccel.. |
|
Hi, thanks for the PR. The conversion of matrices was pyccelized (within each block, see psydac/psydac/linalg/topetsc.py Lines 510 to 518 in 746d0c9 |
|
Hi @max-models, Thanks for this PR! What is its current status? Do you want us to review it, or should we wait for the "Ready for review" green light? BTW, I have just merged |
Hi, the status is that I unfortunately didn't have time to take a second look at it yet. Once I have done that, I will mark it as ready for review :) |
vec_topetsc and petsc_to_psydac
|
Hi @max-models, is this PR ready for review? |
Yes! |
yguclu
left a comment
There was a problem hiding this comment.
@max-models Thanks a lot for this PR!
@e-moral-sanchez I cannot find a single call to the function psydac_to_petsc_global in the library, including the unit tests. Where is it used, then?
@yguclu , this function is used internally in psydac/psydac/linalg/topetsc.py Line 410 in 4868f6c |
After this PR, |
|
@max-models While reviewing, I also found that the new I have taken the liberty to update the PR description accordingly; please have a look at the TODO list there. In addition:
|
I think that these functions are still useful to understand the index conversion, so in my opinion we should keep them. |
@e-moral-sanchez I understand what you mean, but these functions:
So they are effectively dead code, and they may become obsolete (i.e. they may stop working properly). If we want to keep them, we need to have some unit tests for them at the very least |
You are right, I agree that we can delete these functions since they won't be used anymore. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -21 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Thanks @yguclu @e-moral-sanchez, I made the following changes:
|
Converting vectors between PSYDAC and PETSc used to loop over every entry in Python, and each entry needed a search for the process that owns it. This PR replaces both directions with NumPy array operations:
vec_topetsc: each process already knows the PETSc offset of its own data, so it gathers its non-zero entries with np.nonzero and inserts them all with a single setValues call.petsc_to_psydac: the local PETSc array is written straight into the interior of the stencil data, instead of being read back with one getValue call per entry.This also fixes a bug in
petsc_to_psydacwith the argumentout: before, only the non-zero entries of the PETSc vector were copied, sooutkept its previous values wherever the PETSc vector was zero (fixes #640). Now all the local entries are copied.The output is the same as before, except for the fix of #640. The existing serial and parallel
topetsctests pass (stencil vectors in 1D, 2D and 3D, plus block vectors).Speedup of
vec_topetscon a 2D vector:TODO
psydac/linalg/tests/test_stencil_vector.pywith twoStencilVectorobjects:xwith some zero entries, andoutpre-filled with non-zero values; check thatoutequalsxafter the roundtrip withvec_topetscandpetsc_to_psydac. The test should fail on devel, as the reproducer ofpetsc_to_psydackeeps stale values inoutwhere the PETSc vector is zero #640 does.psydac/linalg/tests/test_block.py: the same as above, but for aBlockVectorof twoStencilVectorblocks of different sizes (for example 6 and 4).- #592 : Copy all entries in `petsc_to_psydac` when `out` is given, instead of keeping stale values where the PETSc vector is zero, see #640psydac/linalg/topetsc_old.pyandpsydac/linalg/tests/bench_topetsc.py. I just kept them to benchmark before/after