====== Trilinos ======
FIXME
//Source originale : Wikipedia//
**Trilinos** is a collection of open source software libraries, called packages, intended to be used as building blocks for the development of scientific applications. This library was developed at Sandia National Laboratories from a core group of existing algorithms, and utilizes the functionality of well-known packages such as BLAS and LAPACK.
Trilinos contains packages for:
* Constructing and using sparse and dense matrices, graphs and vectors.
* Iterative and direct solution of linear systems.
* Parallel multilevel and algebraic preconditioning.
* Solution of non-linear, eigenvalue and time-dependent problems.
* PDE-constrained optimization problem.
* Partitioning and load balancing of distributed data structures.
* Automatic differentiation.
* PDE-discretizations.
Most Trilinos packages are written in **C++** with **Fortran kernels** used for performance-sensitive computations. **Python** bindings are provided using SWIG.
====== Les package Trilinos ======
^Objectives^Package^
|Linear algebra objects | Epetra, Jpetra, Tpetra|
|Krylov solvers| AztecOO, Belos, Komplex|
|LU-type preconditioners |AztecOO, IFPACK|
|Multilevel preconditioners| ML, CLAPS|
|Eigenvalue problems| Anasazi|
|Block preconditioners| Meros|
|Direct sparse linear solvers| Amesos|
|Direct dense solvers| Epetra, Teuchos, Pliris|
|Abstract interfaces |Thyra|
|Nonlinear system solvers| NOX, LOCA|
|Time Integrators/DAEs| Rythmos|
|C++ utilities, (some) I/O Teuchos| EpetraExt, Kokkos|
|Trilinos Tutorial| Didasko|
|“Skins”| PyTrilinos, WebTrilinos, Star-P, Stratimikos, ForTrilinos|
|Optimization| MOOCHO, Aristos|
|Archetype package |NewPackage|
|Other | Galeri, Isorropia, Moertel, RTOp, Aristos, RBGen|
[[http://trilinos.sandia.gov/packages/|Liste de tous les packages disponibles]]
__**Liste des packages installés au mésocentre **__
|Amesos, Common, Epetraext, Globipack, Isorropia, Ml, Optika, Piro, Rythmos, Stokhos, Teuchos, TriKota, Zoltan
Anasazi, CTrilinos, Fei, Ifpack, Kokkos, Moertel, Optipack, Pliris, Sacado, Stratimikos, ThreadPool, Trilinoscouplings
Aztecoo, Didasko, ForTrilinos, Ifpack2, Komplex, Moocho, Pamgen, PyTrilinos, Shards, Sundance, Thyra,
Belos, Epetra, Galeri, Intrepid, Mesquite, Nox, Phalanx, Rtop, Stk, Teko, Tpetra, Triutils
====== Versions installées ======
Trois versions de cette bibliothèque sont disponibles :
- Version séquentielle compilée avec le compilateur **gcc** et utilisant les versions standards de **blas** et de **lapack**
- Version séquentielle compilée avec le compilateur Intel (**icc, icpc**) utilisant MKL pour **blas** et **lapack**
- Version parallèle compilée avec Open MPI et utilisant les versions standards de **blas** et de **lapack**
Chacune de ces variantes est associée à son propre module sur le cluster,
qu'il est possible de charger pour utiliser automatiquement cette version :
[kmazouzi@mesocomte0 ~]$ module avail trilinos
trilinos/serial/gcc/10.4.0
trilinos/serial/icc/10.4.0
trilinos/parallel/ompi/10.4.0
Par exemple pour utiliser la version Intel/MLK :
module load trilinos/serial/icc/10.4.0
**Du fait d'un bug dans le compilateur GCC, la version séquentielle compilée avec GCC ne bénéficie pas du support Fortran**
====== Exemples ======
===== Exemple1 : Manipulation de vecteurs en utilsant le package Epetra =====
#include "Epetra_SerialComm.h"
#include "Epetra_Map.h"
#include "Epetra_Vector.h"
#include "Epetra_Version.h"
int main(int argc, char *argv[])
{
cout << Epetra_Version() << endl << endl;
Epetra_SerialComm Comm;
int NumElements = 1000;
// Construct a Map with NumElements and index base of 0
Epetra_Map Map(NumElements, 0, Comm);
// Create x and b vectors
Epetra_Vector x(Map);
Epetra_Vector b(Map);
b.Random();
x.Update(2.0, b, 0.0); // x = 2*b
double bnorm, xnorm;
x.Norm2(&xnorm);
b.Norm2(&bnorm);
cout << "2 norm of x = " << xnorm << endl
<< "2 norm of b = " << bnorm << endl;
return 0;
}
===== Exemple2 : Génération de la matrice Laplacienne sur une grille 2D =====
#include "Galeri_Maps.h"
#include "Galeri_CrsMatrices.h"
#include "Galeri_Utils.h"
#ifdef HAVE_MPI
#include "Epetra_MpiComm.h"
#include "mpi.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Map.h"
#include "Epetra_CrsMatrix.h"
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_RCP.hpp"
using namespace Galeri;
// =========== //
// main driver //
// =========== //
int main(int argv, char* argc[])
{
using Teuchos::RCP;
using Teuchos::rcp;
#ifdef HAVE_MPI
MPI_Init (&argv, &argc);
Epetra_MpiComm Comm (MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
// Create a parameter list
Teuchos::ParameterList GaleriList;
// Set the number of discretization points in the x and y direction.
GaleriList.set ("nx", 10 * Comm.NumProc ());
GaleriList.set ("ny", 10);
// Create the map and matrix using the parameter list for a 2D Laplacian.
RCP Map = rcp (CreateMap ("Cartesian2D", Comm, GaleriList));
RCP Matrix = rcp (CreateCrsMatrix ("Laplace2D", &*Map, GaleriList));
// Print out the map and matrices
Map->Print (std::cout);
Matrix->Print (std::cout);
#ifdef HAVE_MPI
MPI_Finalize ();
#endif
return 0;
}
====== Compilation ======
===== Code séquentiel =====
Trilinos fournit des fichiers **Makefile** prédifinis dans le répertoire d'instalation **$(TRILINOS_DIR)/include**,
permettant de compiler/linker les applications en utilisant le même compilateur et les mêmes options de compilation
que celles utilisés pour l'installation des packages.
La variable d'environnement ''$TRILINOS_DIR'' est automatiquement définie lors du chargement du module :
Il est possible de l'utiliser dans des scripts pour éviter d'utiliser les chemin complet.
Pour compiler vos applications, il suffit donc créer un nouveau **makefile** et d'importer le makefile correspondant aux packages utilisés.
Documentation sur l'utilisation de Makefile [[MakeFile]]
Voici en exemple d'un makefile permettant de compiler le programme **Vect.cpp**
décrit ci-dessus :
include $(TRILINOS_DIR)/include/Makefile.export.Trilinos
# Make sure to use same compilers and flags as Trilinos
CXX=$(Trilinos_CXX_COMPILER)
CC=$(Trilinos_C_COMPILER)
FORT=$(Trilinos_Fortran_COMPILER)
CXX_FLAGS=$(Trilinos_CXX_COMPILER_FLAGS) $(USER_CXX_FLAGS)
C_FLAGS=$(Trilinos_C_COMPILER_FLAGS) $(USERC_FLAGS)
FORT_FLAGS=$(Trilinos_Fortran_COMPILER_FLAGS) $(USER_FORT_FLAGS)
INCLUDE_DIRS=$(Trilinos_INCLUDE_DIRS) $(Trilinos_TPL_INCLUDE_DIRS)
LIBRARY_DIRS=$(Trilinos_LIBRARY_DIRS) $(Trilinos_TPL_LIBRARY_DIRS)
LIBRARIES=$(Trilinos_LIBRARIES)
LINK_FLAGS=$(Trilinos_EXTRA_LD_FLAGS)
#just assuming that epetra is turned on.
DEFINES=-DMYAPP_EPETRA
# build the
MyApp.exe: Vect.o
$(CXX) $(CXX_FLAGS) Vect.cpp -o MyApp.exe $(LINK_FLAGS) $(INCLUDE_DIRS) $(DEFINES) $(LIBRARY_DIRS) $(LIBRARIES)
Vect.o:
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_DIRS) $(DEFINES) Vect.cpp
.PHONY: clean
clean:
rm -f *.o *.a *.exe
Avant de lancer **make**, il est nécessaire de charger le module trilinos correspondant
pour que les fichiers utilisés soient accessibles.
$make
$ ./MyApp.exe
Epetra in Trilinos 10.6.4
2 norm of x = 35.8368
2 norm of b = 17.9184
===== Code Parallèle =====
L'objectif de Trilinos est de fournir une interface unique pour accéder aux fonctions des packages. La seule différence entre un code séquentielle et un code parallèle et l'utilisation des pré-processeurs MPI
**On utilise donc le même Makefile que celui ci-dessus. Mais en chargeant bien la version parallèle de Trilinos.**
Il suffit de changer Vect par le nom de votre programme dans le Makefile ci-dessus
Pour exécuter notre application, on utilisera typiquement **mpirun** :
mpirun -np 4 MyAppli.exe
Number of Global Elements = 400
Number of Global Points = 400
Maximum of all GIDs = 399
Minimum of all GIDs = 0
Index Base = 0
Constant Element Size = 1
Number of Local Elements = 100
Number of Local Points = 100
Maximum of my GIDs = 179
Minimum of my GIDs = 0
MyPID Local Index Global Index
0 0 0
0 1 40
0 2 80
0 3 120
0 4 160
====== Support pour Fortran ======
Il semble que le support de Fortran n'est pas totalement finalisé. L'objectif du projet **ForTrilinos** est de fournir des interfaces standards à tous les packages Trilinos.
The ForTrilinos project emphasizes portability, robustness, and scalable development. Portability results from standards conformance. In particular, ForTrilinos exploits the C interoperability features of the Fortran 2003 standard to interact with other Trilinos packages through the CTrilinos package. This approach provides platform-independent type safety and procedure name resolution using language constructs supported by the recent releases of all ten Fortran compilers surveyed. Robustness results in part from a Fortran implementation of runtime assertions and in part by embedding an automated memory management architecture into each ForTrilinos object. Scalable development results from automating the most labor-intensive portions of the interface development effort.
ForTrilinos currently wraps portions of Epetra, Pliris, and AztecOO. **The development of ForTrilinos is primarily user-driven, so new interfaces are developed at the request of Trilinos users.**
**ForTrilinos:** Fortran 2003 wrappers for selected Trilinos code
The ForTrilinos package is being developed to provide an advanced object-oriented Fortran 2003 interface to selected Trilinos C++ code.
**NOTE:** The Fortran 2003 wrappers call the C wrappers in the CTrilinos package.
**NOTE:** Fortran users that want a lower-level non-object-oriented interface to Trilinos can just directly use the C-wrappers in the CTrilinos package.
FIXME
====== Documentation ======
* Une série de documents complets sur l'utilisation de trilinos [[http://trilinos.sandia.gov/documentation.html|Site officiel]]
* Quelques examples en C++ [[http://code.google.com/p/trilinos/wiki/TrilinosHandsOnTutorial|Lien externe]]
* Tutorial DIDASKO (Exemple de plusieurs packages) [[http://trilinos.sandia.gov/packages/docs/r10.6/packages/didasko/doc/html/index.html| Site]]