Ceci est une ancienne révision du document !


Trilinos

'' Définition (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

ObjectivesPackage
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

La liste de tous les packages Lien

**La des packages installés au mésocentre **

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 version ont été installées :

  1. Version séquentielle compilé avec le compilateur gcc et utilisant les versions standards du blas et lapack
  2. Version séquentielle compilé avec le compilateur Intel (icc, icpc) et utilisant MKL pour blas et lapack
  3. Version parallèle compilé avec Open MPI et utilisant les versions standards du blas et lapack

Il existe donc trois modules sur le cluster :

 [kmazouzi@mesocomte0 ~]$ module avail trilinos
 
 trilinos/serial/gcc/10.4.0 
 
 trilinos/serial/icc/10.4.0 
 
 trilinos/parallel/ompi/10.4.0

Pour utiliser une version, il suffit de charger le module correspondant.

Par exemple pour utiliser la version Intel/MLKL :

module  load trilinos/serial/icc/10.4.0 
La version séquentielle compilée avec GCC ne fournit pas d'interface Fortran. Un bug gcc

Exemples

EpetraSimpleVector.cpp
#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;
}
GaleriLinearSystem.cpp
#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<Epetra_Map> Map = rcp (CreateMap ("Cartesian2D", Comm, GaleriList));
  RCP<Epetra_CrsMatrix> 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

Trilinos fournit des fichiers Makefile prédifinis dans le répertoire d'instalation $(TRILINOS_DIR)/include.

après avoir charger le module nécessaire) une variable d'environnement pointant vers le répertoire d'installation : $TRILINOS_DIR est créée.

Cela permet de compiler/linker les applications en utilisant le même compilateur et les mêmes options de compilation dont les packages ont été compilées.

Pour compiler vos applications, il faut donc créer un nouveau makefile et d' importer le makefile correspondant aux packages utilisés.

Voici un lien sur l'utilisation de Makefile Makefile

Voici en exemple d'un makefile pour compiler le programme Vect.cpp ci-dessus :

Makefile
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 faut charger le module trilinos correspondant
$make
$ ./MyApp.exe 
Epetra in Trilinos 10.6.4
 
2 norm of x = 35.8368
2 norm of b = 17.9184
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 utilise mpirun, par exemple :

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 Site officiel
  • Quelques examples en C++ Lien externe
  • Tutorial DIDASKO (Exemple de plusieurs packages) Site
  • trilinos.1313788864.txt.gz
  • Dernière modification : 2015/02/25 08:45
  • (modification externe)