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

Inefficient conversion from PETSC to array #389

Open
e-moral-sanchez opened this issue Mar 13, 2024 · 2 comments
Open

Inefficient conversion from PETSC to array #389

e-moral-sanchez opened this issue Mar 13, 2024 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists performance Make the code run faster PETSc

Comments

@e-moral-sanchez
Copy link
Contributor

e-moral-sanchez commented Mar 13, 2024

At the moment when we convert a distributed StencilVector or StencilMatrix or BlockLinearOperator to PETSc.Vec or PETSc.Mat format with the topetsc() method, the corresponding (dense) arrays cannot be compared directly. This is because PETSc distributes the vectors or matrices differently than Psydac.

In a distributed Psydac StencilVector or StencilMatrix a process may own non-contiguous rows (for instance, if the domain is 2D and it is distributed by 4 processes). At the moment, a process with the PETSC distributed Vec or Mat object will always own contiguous rows. This is possible because when calling the assembly of the PETSc Vec or Mat object, there is an exchange of global communication.

The reason why PETSc does this is because it does not have any information about how the domain is decomposed. Consequently, it simply decomposes the vector or matrix by rows uniformly.

The major consequence of this issue is that the function petsc_to_array becomes unnecessarily expensive, since we need to gather the array from all the processes and redistribute it according to Psydac's domain partition.

A potential solution might be to create a PETSc.DM object that contains the domain decomposition information from Psydac.

Note: In order to get the global indices of the owned rows and columns of the PETSc.Mat object, one can use the method getOwnershipIS()

@yguclu
Copy link
Member

yguclu commented Mar 22, 2024

Duplicate of #247?

@yguclu yguclu added the duplicate This issue or pull request already exists label Mar 22, 2024
@e-moral-sanchez
Copy link
Contributor Author

I agree.

@e-moral-sanchez e-moral-sanchez self-assigned this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists performance Make the code run faster PETSc
Projects
None yet
Development

No branches or pull requests

2 participants