-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Description
This issue is for organizing and documenting progress of the migration from the old Epetra stack to the modern Tpetra stack. Specific tasks to be done are organized in issues with the respective label marking them. An overview of the progress can be found in Migration from Epetra to Tpetra.
Goals:
- Migrate the entire linear algebra stack to
Tpetra - Switch 4C's Trilinos dependencies to the
Tpetrastack
Background
4C relies on Trilinos for the implementation of sparse linear algebra capabilities.
We currently use the Epetra stack, which will be phased-out from Trilinos by the end of 09/2025 (at the latest) -- and even right now, the Epetra stack is not actively developed anymore, so we cannot easily benefit from new features. Finally, Epetra is limited to MPI-only mode, so we cannot use on-node parallelism or accelerator devices (as they appear in more and more of todays computing clusters).
The modern Tpetra stack is the successor of Epetra. It is actively developed, it forms the basis for a modern solver stack in Trilinos, and comes with a hand-in-hand Kokkos integration for MPI+X parallelism.
The switch to Tpetra is mandatory, such that we can benefit from developments in Trilinos in the future.
The current strategy is to divide the transition into tree phases to ensure an orderly transition. The first phase includes preliminary steps in which the dependency on Epetra is reduced. If possible, the functionalities which still remains from Epetra are encapsulated by using wrappers.
In the second phase, the conversion of the sparse matrices will take place.
In the third and final phase, all remaining dependencies on Epetra that were not removed in the previous phases will be removed.
A presentation about packages, which will be archived can be found HERE (as presented at TUG 2023). Those include the following relevant packages for 4C:
Epetra/EpetraExtIsorropiaIntrepidAmesosAztecOOIfpackMLNOX
In addition, Epetra code from all other packages will be removed.
Functionality is still ported from old to new solver stack till October 2024. If we use features from the old stack, which are not yet in the new one, there's still time to get them moved. After October 2024, the old solver stack out phasing will start till October 2025, to give stakeholders and users some final months for moving to the new stack. Afterwards all Epetra related code will be archived and thus won't be part of the repository anymore.
First Phase I
Before the actual migration to Tpetra can take place, some packages that support only Epetra have to be replaced by newer versions supporting both solver stacks. In addition this will be connected to heavy cleanup actions reducing complexity and thus simplifying the code paths taken in 4C.
Linear solver
-
Amesos2: Direct solver package. The direct solver package is quite regularly used for prototyping and problems using difficult physics. As a lot of tests depend on this, it's quite time consuming to replace everything related toAmesos. (see [Trilinos] Move direct solver from Amesos to Amesos2 #661) -
Belos: Iterative solver package. The iterative linear solvers come into play for big problem sizes and are critical for performance running large parallel simulations.All the code already runs the new package, despite some parts in the partitioned(see Remove instantiation offsistill depending onAztecOO, but mainly due toNOX.::NOX::Epetra::LinearSystemAztecOO#1353) -
Muelu: Multigrid preconditioner package. We use multigrid for all kinds of problem types as preconditioner either for single-fields or multi-fields, which means this is an integral part of the linear solvers in 4C. Thus we need to switch and remove the old multigrid packageML. The plan is to use template xml-files tailored to certain problem types, which other developers can just use for their own simulations.
In the current state optional, but maybe beneficial:
-
Ifpack: Incomplete factorization and additive Schwarz preconditioning package. We use it for all kinds of preconditioning, but have a quite rigid and hard coded entry point to it in our code. Moving the related parameters to an external file and reading this one in would allow us to be more flexible and make the switch to the successorIfpack2a bit more trivial (see [Ifpack] Move parameters and options to xml-file #365 Ifpack move parameters and options to xml file #400 [Ifpack] Move backend toStratimikos#766). -
Teko: Block preconditioning package. Used to remove self implemented block preconditioners and thus simplify the overall code structure and also relevant for the switch toMueLuandBelosfor the self implemented block-iterative preconditioner infsi. It also allows us to delete our own internalamgnxnimplementation (see Move remaining scatra to teko #972 [Teko] Removeamgnxnframework #754). -
Stratimikos: Trilinos interface package to linear solvers (Belos,Amesos2) and preconditioners (Ifpack,MueLu,Teko). Would likely reduce the amount of interface/adapter files currently used for different linear solvers (iterative, direct) and preconditioners (incomplete factorization, multigrid, block). This would also force us to think about our implementation of the linear solver class (see [Ifpack] Move backend toStratimikos#766 [MueLu] Move backend toStratimikos#1401 [solver] Move internals toThyraobjects #1400).
Nonlinear solver
- Remove
Epetradependency fromNOX(see [NOX] Replace NOX::Epetra::Group with Tpetra counterpart #198 [Structure] Use NOX for non-linear solution procedure in new solid time integration #300 Reducing number of NOX-based solvers #359 [NOX] Clean up ofNOX::Solver::SingleStep#379 [NOX] Remove "Modified" parameter list #406)
Discretization
-
Zoltan/Zoltan2: Packages for graph coloring, graph and spatial domain partitioning and matrix reordering. We currently make use ofIsorropiaas old interface toZoltan, the actual partitioning package.Zoltan2is a mix of being an interface toZoltan, but also implementing algorithms by itself. (see [Trilinos] Move from Isorropia to Zoltan2 #596 [Trilinos] Switch from Isorropia/Zoltan to Zoltan2/Zoltan #594) -
Intrepid2: Quadrature and basis function package. The code currently usesIntrepidto obtain quadrature rules for a certain cell type, to do the element local integration. We don't use anything else the package provides (which is strange, because getting local Jacobians, it's transposes or inverses is very easy at this point, but that's how it is). Besides that, we also provide a set of own quadrature rules not depending onIntrepid(this is again a classic, why have one thing doing quadrature when you can have several). We need to refactor the implementation based onIntrepid. (see [Trilinos] Refactor Gauss points and move to Intrepid2 #191 [Trilinos] Switch from Intrepid to Intrepid2 #192 [Intrepid2] Switch from Intrepid to Intrepid2 #222)
Linear Algebra Objects
Avoid the usage of Epetra in the physics modules by providing appropriate wrapper classes
- Matrix:
- Remove occurrences of
Epetra_CrsMatrixand replace byCore::LinAlg::SparseMatrix(see [Epetra] Work onEpetra_CrsMatrixreplacement #761 [Epetra] Remove calls toepetra_matrix()#764 [Solver] Use SparseOperator instead of Epetra_Operator in linear solver #723)
- Remove occurrences of
- Vector:
- Remove occurrences of
Epetra_Vectorand replace byCore::LinAlg::Vector - Remove occurrences of
Epetra_IntVectorand replace byCore::LinAlg::Vector - Remove occurrences of
Epetra_FEVectorand replace byCore::LinAlg::Vector(see [Epetra] IntegrateEpetra_FEVectorclasses into our vector wrapper #84) - Remove occurrences of
Epetra_MultiVectorand replace byCore::LinAlg::Vector
- Remove occurrences of
- Graph:
- Remove occurrences of
Epetra_CrsGraphand replace byCore::LinAlg::Graph(see Create Wrapper for Epetra_CrsGraph #397 [epetra] Wrapper for Epetra_CrsGraph #403 [epetra] Apply clang-tidy in graph wrapper #498) - Remove occurrences of
Epetra_FECrsGraphand replace byCore::LinAlg::Graph([linalg] Make LinAlg::Graph use Epetra_FECrsGraph #404 [LinAlg] Add FE_Graph capability toCore::LinAlg::Graph#759)
- Remove occurrences of
- Map:
- Remove occurrences of
Epetra_Mapand replace byCore::LinAlg::Map(see [LinAlg] Reduce Epetra_Map and Epetra_BlockMap occurances #552 Provide Wrapper for the Epetra map #554) - Remove occurrences of
Epetra_BlockMapand replace byCore::LinAlg::Map(see [LinAlg] Reduce Epetra_Map and Epetra_BlockMap occurances #552 Replace Epetra_BlockMap with Map #799)
- Remove occurrences of
- Misc:
- Remove occurrences of
Epetra_Import\Epetra_Exportand replace byCore::LinAlg::Transfer::Export\Core::LinAlg::Transfer::Import(see [LinAlg] Create wrapper classes forEpetra_ImportandEpetra_Export#755 Implement wrapper for Epetra import #827 Implement wrapper for Epetra Export #877) - Create a view for for
LinAlgobjects by usingCore::LinAlg::View(see Create LinAlg::View for our wrappers #557 Enable LinAlg::View for Map #787)
- Remove occurrences of
Centralize calls to EpetraExt:
- Refactor matrix-matrix multiplication
- Refactor/evaluate matrix-matrix addition (see [EpetraExt] Evaluate the sparse matrix addition methods #136 [LinAlg] Refactor matrix add and multiply methods #1152)
- Refactor matrix transpose
- Remove matrix reindexing (see [EpetraExt] Remove reindexing of linear problem out of direct solver #675)
Framework
Start reducing Epetra dependent utilities with respective calls from Teuchos or remove Epetra dependency:
- Direct Blas/Lapack calls
- Time measurements
- MPI communicator (see Remove LinAlg::Map constructors taking Epetra_Comm #788)
First Phase II
There will be some preparation necessary related to further cleanup to make things go through smoothly (see #764 #763). Everything Epetra related needs to be reduced as much as possible, such that we end up with a minimal set of occurrences that are actually relevant for the switch.
Further preparation steps necessary:
- Assert every
Epetrabased call if a warning or error occurs (see [LinAlg] Move FOUR_C_THROW into respective wrapper classes #1190) - Use static matrix profiles without dynamic allocations (see [LinAlg] Static sparsity layout for sparse matrices #1544)
- Remove all inheritance from
Epetrabased objects (see [LinAlg] Remove inheritance toEpetraobjects #1557) - Preparations to adjust our interface for the second phase (see [LinAlg] Clean-up of sparse algebra wrappers #875 [LinAlg] Refactor sparse operator, matrix and block-matrix wrapper #863)
This is also a good point to get some side quests done, that are not directly related to the switch, but to usability and Trilinos in general:
- Refactor linear solver and preconditioner input in
4Cand update the respective documentation (see Update documentation of our solvers in readthedocs #68 [solver] Configuration and input procedure #1577 [solver] Reduce linear solver related input file parameters #1576 [solver] Unify preconditioner configuration file input variable #1575)
Second Phase
After everything is ready to be able to work with Tpetra we can think about migrating the functionality from Epetra sparse linear algebra to Tpetra sparse linear algebra.
- Discuss how to do the switch and integrate
Tpetra: We decided to wrap the sparse linear algebra objects, remove utils functions as much as possible and try to move as many packages to the new ones by still depending onEpetrafor now.
Linear solver
Call the respective linear solver with the relevant Tpetra objects.
Some packages only support either only Epetra or only Tpetra, we can only adapt them with the actual switch to Tpetra:
-
Ifpack2: Additive-Schwarz preconditioner package.
Discretization
We need to feed Zoltan2 with the relevant Tpetra objects, thus we need to call the respective adapters with Tpetra
using GraphAdapter = Zoltan2::XpetraCrsGraphAdapter<Tpetra::CrsMatrix, Tpetra::MultiVector>;
using VectorAdapter = Zoltan2::XpetraMultiVectorAdapter<Tpetra::MultiVector>;Linear Algebra Objects
Replace the Epetra members from sparse algebra wrappers by Tpetra. An overview issue is given in #875.
- Matrix:
- Replace
Epetra_CrsMatrix->Tpetra::CrsMatrix
- Replace
- Vector:
- Replace
Epetra_Vector->Tpetra::Vector - Replace
Epetra_MultiVector->Tpetra::MultiVector
- Replace
- Graph:
- Replace
Epetra_CrsGraph->Tpetra::CrsGraph
- Replace
- Map:
- Replace
Epetra_Map->Tpetra::Map
- Replace
- Misc:
- Replace
Epetra_Importer->Tpetra::ImporterandEpetra_Exporter->Tpetra::Exporter
- Replace
Replace the calls from EpetraExt by Tpetra:
- Replace
EpetraExt::MatrixMatrix::Multiply->Tpetra::MatrixMatrix::Multiply - Replace
EpetraExt::MatrixMatrix::Add->Tpetra::MatrixMatrix::Add - Replace
EpetraExt::RowMatrix_Transpose->Tpetra::RowMatrixTransposer
Framework
We need to replace as_epetra_comm() with a call to as_teuchos_comm() as Tpetra works with the communicator objects from Teuchos.
Third Phase
TBD
Quick links
How to participate?
If you want to participate in this effort (even temporarily), please assign yourself to this meta-issue, so that we have an overview of possible contributors. Every helping hand is very welcome!