Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| bibliotheques_scientifiques [2010/08/09 00:35] – admin | bibliotheques_scientifiques [2016/12/15 14:34] (Version actuelle) – [BLAS] admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Introduction ====== | ====== Introduction ====== | ||
| - | Les bibliothèques sont des ensembles d’algorithmes testés, validés, optimisés. Elles sont indépendantes de l’architecture machine, et supportent différents types de données : réel, complexe, simple ou double précision. Les constructeurs ont optimisé certaines de ces bibliothèques pour leurs machines (ex : Intel MKL), elles sont plus performantes mais dépendantes de l’architecture. | + | Les bibliothèques |
| Il est donc recommandé de les utiliser quand c'est possible, cela permet de se consacrer uniquement aux nouveaux développements. | Il est donc recommandé de les utiliser quand c'est possible, cela permet de se consacrer uniquement aux nouveaux développements. | ||
| Ligne 16: | Ligne 16: | ||
| **BLAS 1** : opérations de type vecteur-vecteur | **BLAS 1** : opérations de type vecteur-vecteur | ||
| - | | + | |
| **BLAS 2** : opérations de type vecteur-matrice | **BLAS 2** : opérations de type vecteur-matrice | ||
| - | | + | |
| **BLAS 3** : opérations de type matrice-matrice | **BLAS 3** : opérations de type matrice-matrice | ||
| - | C C | + | C + alpha.A.B + beta.C |
| Ligne 46: | Ligne 46: | ||
| </ | </ | ||
| + | |||
| + | **Compilation :** | ||
| + | < | ||
| + | |||
| + | $ gfortran stod.f -o stod -lblas | ||
| + | </ | ||
| + | |||
| + | ===== Appel de DGEMM depuis C/C++===== | ||
| + | |||
| + | <file c demm.c> | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #include < | ||
| + | |||
| + | extern void dgemm_(const char*, const char*, int*, int*,int*, double*, double*, int*, double*, int*, double*, double*, int*); | ||
| + | |||
| + | |||
| + | int main(int argc, char **argv){ | ||
| + | |||
| + | int i,j; | ||
| + | double one = 1.0; | ||
| + | double zero = 0.0; | ||
| + | |||
| + | int n = 1024; | ||
| + | |||
| + | if(argc==2) | ||
| + | { | ||
| + | n=atoi(argv[1]); | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | double *A = (double*)malloc(n*n*sizeof(double)); | ||
| + | |||
| + | double *B = (double*)malloc(n*n*sizeof(double)); | ||
| + | |||
| + | double *C = (double*)malloc(n*n*sizeof(double)); | ||
| + | |||
| + | if(C==NULL || B==NULL || A==NULL){ | ||
| + | |||
| + | fprintf(stderr, | ||
| + | |||
| + | if(A!=NULL) free(A); | ||
| + | if(B!=NULL) free(B); | ||
| + | if(B!=NULL) free(C); | ||
| + | |||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | for(i = 0; i < n*n; i++) { | ||
| + | A[i] = i; | ||
| + | B[i] = i; | ||
| + | } | ||
| + | |||
| + | //make BLAS 3 matrix matrix operation | ||
| + | //C = C + alpha.A.B + beta.C | ||
| + | dgemm_(" | ||
| + | |||
| + | // #elif defined(CBLAS) || defined(MKL) || defined(VECLIB) | ||
| + | | ||
| + | |||
| + | |||
| + | for(i=n-2; i< | ||
| + | | ||
| + | | ||
| + | |||
| + | printf(" | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | |||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | return(0); | ||
| + | } | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| ====== LAPACK ====== | ====== LAPACK ====== | ||
| Ligne 56: | Ligne 139: | ||
| **Exemple : ** appel de la routine '' | **Exemple : ** appel de la routine '' | ||
| - | <code fortran> | + | <file fortran |
| - | !Appel a LAPACK pour retrouver la solution V tq A*V=U | + | |
| - | INFO = 0 | + | |
| - | NRHS = 1 | + | |
| - | LDA = N | + | |
| - | LDB = N | + | |
| - | CALL DGESV (N, NRHS, A, LDA, IPIV, U, LDB, INFO) | + | |
| - | </ | + | program randomsys |
| + | implicit none | ||
| + | real(kind=8), | ||
| + | real(kind=8), | ||
| + | real(kind=8) :: err | ||
| + | integer :: i, info, lda, ldb, nrhs, n | ||
| + | integer, dimension(: | ||
| + | ! initialize random number generator seed | ||
| + | ! if you remove this, the same numbers will be generated each | ||
| + | ! time you run this code. | ||
| + | call init_random_seed() | ||
| + | |||
| + | print *, "Input n ... " | ||
| + | read *, n | ||
| + | |||
| + | allocate(a(n, | ||
| + | allocate(b(n)) | ||
| + | allocate(x(n)) | ||
| + | allocate(ipiv(n)) | ||
| + | |||
| + | call random_number(a) | ||
| + | call random_number(x) | ||
| + | b = matmul(a,x) ! compute RHS | ||
| + | | ||
| + | nrhs = 1 ! number of right hand sides in b | ||
| + | lda = n ! leading dimension of a | ||
| + | ldb = n ! leading dimension of b | ||
| + | |||
| + | call dgesv(n, nrhs, a, lda, ipiv, b, ldb, info) | ||
| + | |||
| + | ! Note: the solution is returned in b | ||
| + | ! and a has been changed. | ||
| + | |||
| + | ! compare computed solution to original x: | ||
| + | print *, " | ||
| + | do i=1,n | ||
| + | err = abs(x(i)-b(i))/ | ||
| + | print ' | ||
| + | enddo | ||
| + | |||
| + | deallocate(a, | ||
| + | |||
| + | end program randomsys | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Compilation :** | ||
| + | < | ||
| + | $ gfortran randomsys.f90 -o appli -lblas -llapack | ||
| + | </ | ||
| ====== Scalapack ====== | ====== Scalapack ====== | ||
| Ligne 82: | Ligne 208: | ||
| ^Acronyme ^Utilitaire ^Directe ^Itératif^ Non Linéaire^ Valeurs propres^ Parallèle^ Matrice^ | ^Acronyme ^Utilitaire ^Directe ^Itératif^ Non Linéaire^ Valeurs propres^ Parallèle^ Matrice^ | ||
| - | |BLAS | **X** | | + | |BLAS | **X** | |
| - | |PBLAS| | + | |PBLAS| |
| - | |BLACS | **X** | | + | |BLACS | **X** | |
| - | |LAPACK | | + | |LAPACK | |
| - | |ScaLAPACK | | **X** | | + | |ScaLAPACK | | **X** | |
| - | |SuperLU | | **X** | | + | |SuperLU | | **X** | |
| - | |SuperLU_DIST | | **X** | | | | + | |SuperLU_DIST | | **X** | | | |
| - | |PETSc| | + | |PETSc| |
| + | |||
| + | |||
| + | ====== Documentation ====== | ||
| + | |||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||