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
Refactor the PETSc matrix/vector classes #5454
Comments
The whole point of the new system is that we need to import/export to/from a petsc vector and a serial ReadWriteVector. I don't think it is necessary to inherit from ReadWriteVector. What @Rombur did for Trilinos is creating new vectors in a different namespace. I think that is what is appropriate here too. edit: The problem is that PETSc vectors require locking/unlocking for each element access, so we can not treat it as a block of memory and a linear algebra vectors, at least not in a multithreaded contest. @Rombur 's design fixes that issue but only if you separate the two concepts. |
Yes, the idea is that there is only one or two (deal.II) classes that implement the |
The discussion in August is slowly coming back to mind. You're both right of course. We already ban using multiple threads with PETSc so this won't be an issue. I'll update my list. |
We can do three things at once, then: if we put the new vector class in |
Well, if we go forward with the plan, we no longer need to limit PETSc computations to one thread because multithreaded read/write access will only happen to ReadWriteVectors and not to PETSc vectors. |
I think that PETSc still keeps track of things at a global level, so one cannot create PETSc objects simultaneously across multiple threads without getting a race condition. I'll look into this. |
That might be true (likely). I think we never spell out what kind of thread-safety expectations we have for particular classes. All our multithreaded code only parallelizes work done over cells (or internal vector operations that are safe like |
I agree. Creating multiple subscriptions is probably not thread-safe. PETSc also supports compilation in a 'thread-safe' mode which I think prevents these race conditions. |
I think we've made enough progress on improving our PETSc wrappers in several new ways that we can close this as completed / out-of-date. |
#5453 reminded me that I have been meaning to clean things up in this part of the library. We currently have several open issues for the PETSc bindings:
Mat
objects)I propose that I do the following to address these:
PETScWrappers::SparseMatrix
(for the same reasons we deprecated the serial vector class)PETScWrappers::VectorView
based on the wrapper mode currently inVectorBase
. Thismightshould inherit fromReadWriteVector
andLinearAlgebraVector
and should conform to the new interface specified by Future interfaces to vectors from other libraries #745. I imagine this class as a bridge betweenVec
and our own new vector classes, while not necessarily owning theVec
.MatrixBase
toMatrixView
and inherit from it for the three remainingPETScWrappers
matrix classes (which are now owning views)VectorBase
class (since only one class now inherits from it)PETScWrappers
; i.e.,PETScWrappers::MPI
should be removed since everything is intended to work with MPI-compatible data structures (with, of course, exceptions likePreconditionLU
that are due to missing algorithms in PETSc)This is a lot of work but I think its good to have a road map for the future direction of this part of the library.
The text was updated successfully, but these errors were encountered: