IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

Erreur de segmentation MPI programme


Sujet :

C

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2014
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Erreur de segmentation MPI programme
    J'ai programmé mon propre programme scalapack (bibliothèque d'algèbre linéaire), j'utilise aussi le parrallel computing.
    Le code compile mais à l'exécution il y a une erreur de segmentation. Je ne vois pas laquelle et comment je peux la trouver.
    Merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <cblas.h>
    #include <mpi.h>
     
    #define AA(i,j) AA[(i)*M+(j)]
    #define XX(i,j) XX[(i)*M+(j)]
     
    typedef struct{
    double* tab;
    int nrow;
    int ncol;
    }Matrix;
     
     
    typedef struct{
     int ictxt;
    int nprow;
    int npcol;
    int myrow;
    int mycol;
    int nb;
    int info;
    int itemp;
    int myrank_mpi;
    int nprocs_mpi;
    }InfoParrall;
     
    /*! External procedures prototypes from CBLACS: */
    extern void Cblacs_pinfo(int *mypnum, int *nprocs);
    extern void Cblacs_get(int ConTxt, int what, int *val);
    extern void Cblacs_gridinit(int *ConTxt, char *order, int nprow, int npcol);
    extern void Cblacs_gridinfo(int ConTxt, int *nprow, int *npcol,
                                int *myrow, int *mycol);
    extern void Cblacs_gridexit(int ConTxt);
    extern void Cblacs_exit(int NotDone);
    double* multMM(Matrix A, Matrix B, InfoParrall inf);
    double* multVV(Matrix A, Matrix B, InfoParrall inf);
    double* multV(double* AA, double* X,int M, int nb,int mycol, int myrow, int ZERO,int ONE, int nprow, int npcol,int myrank_mpi,int info,int ictxt,int my,int Acol,int Arow,int Xrow,int Xcol);
    double* multM(double* AA, double* X,int M, int nb,int mycol, int myrow, int ZERO,int ONE, int nprow, int npcol,int myrank_mpi,int info,int ictxt,int my,int Acol,int Arow,int Xrow,int Xcol);
     
     
     
    double* multMM(Matrix A, Matrix B, InfoParrall inf){
    return multM(A.tab,B.tab,5,inf.nb,inf.mycol,inf.myrow,0,1,inf.nprow,inf.npcol,inf.myrank_mpi,inf.info,inf.ictxt,A.nrow,A.ncol,A.nrow,B.nrow,B.ncol);
    }
     
    double* multM(double* AA, double* X,int M, int nb,int mycol, int myrow, int ZERO,int ONE, int nprow, int npcol,int myrank_mpi,int info,int ictxt,int my,int Acol,int Arow,int Xrow,int Xcol){
    int descA[9],descx[9],descy[9];
    descinit_(descA, &M, &M, &nb, &nb, &ZERO, &ZERO, &ictxt, &Acol, 0);
    descinit_(descx, &M, &ONE, &nb, &ONE, &ZERO, &ZERO, &ictxt, &Xrow, 0);
    descinit_(descy, &M, &ONE, &nb, &ONE, &ZERO, &ZERO, &ictxt, &my, 0);
     
       double *y = (double*) malloc(M*M*sizeof(double));
       double alpha = 1.0; double beta = 0.0;
      pdgemm_("N","N",&M,&M,&Acol,&alpha,AA,Arow,Acol,descA,X,Xrow,Xcol,descx,&beta,y,Arow,Acol,descy);
     return y;
    }
     
     
    int main(int argc, char **argv) {
    /************ MPI ***************************/
       int myrank_mpi, nprocs_mpi;
       MPI_Init( &argc, &argv);
       MPI_Comm_rank(MPI_COMM_WORLD, &myrank_mpi);
       MPI_Comm_size(MPI_COMM_WORLD, &nprocs_mpi);
    /************ BLACS ***************************/
      InfoParrall inf;
       int ZERO=0,ONE=1;
       inf.nprow = 2; inf.npcol = 2; inf.nb =2;
       Cblacs_pinfo( &(inf.myrank_mpi), &(inf.nprocs_mpi) ) ;
       Cblacs_get( -1, 0, &(inf.ictxt) );
       Cblacs_gridinit( &(inf.ictxt), "Row", inf.nprow, inf.npcol );
       Cblacs_gridinfo( inf.ictxt, &(inf.nprow), &(inf.npcol), &(inf.myrow), &(inf.mycol) );
     
    // Initialisation de matrix
    int M=5;
    int i,j;
    Matrix AA;
    AA.tab = (double*) malloc(M*M*sizeof(double));
    for(i=0;i<M;i++){
    	for(j=0;j<M;j++){
    		AA.tab[i*M+j]=i;
    	}
    }
    //matrix X
    Matrix X;
    X.tab = (double*) malloc(M*M*sizeof(double));
    for(i=0;i<M;i++){
    	for(j=0;j<M;j++){
    		X.tab[i*M+j]=1;
    	}
    }
     
    AA.nrow = numroc_( &M, &(inf.nb), &(inf.myrow), &ZERO, &(inf.nprow) );
    AA.ncol = numroc_( &M, &(inf.nb), &(inf.mycol), &ZERO, &(inf.npcol) );
    X.nrow = numroc_( &M, &(inf.nb), &(inf.myrow), &ZERO, &(inf.nprow) );
    X.ncol=numroc_( &M, &(inf.nb), &(inf.mycol), &ZERO, &(inf.npcol) );
    int my = numroc_( &M, &(inf.nb), &(inf.myrow), &ZERO, &(inf.nprow) );
    //double *y= multM(AA.tab, X.tab,M,  (inf.nb), (inf.mycol), (inf.myrow),  ZERO, ONE, (inf.nprow), (inf.npcol), (inf.myrank_mpi),(inf.info),(inf.ictxt),my,AA.nrow,AA.ncol,X.nrow,X.ncol);
    double* y=multMM(AA,X,inf);
     
       Cblacs_barrier((inf.ictxt),"A");
     
     
       for(i=0;i<my;i++){
       printf("rank=%d %.2f \n", (inf.myrank_mpi),y[i]);
    }
       free(AA.tab);
        free(X.tab);
       Cblacs_gridexit( 0 );
       MPI_Finalize();
       return 0;
    }

  2. #2
    Inactif  


    Homme Profil pro
    Doctorant sécurité informatique — Diplômé master Droit/Économie/Gestion
    Inscrit en
    Décembre 2011
    Messages
    9 012
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Doctorant sécurité informatique — Diplômé master Droit/Économie/Gestion
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 9 012
    Points : 23 145
    Points
    23 145
    Par défaut
    Bonjour,

    Utilise un débogueur pour obtenir plus d’informations sur ton erreur.
    Tu peux aussi utiliser valgrind pour voir si tu n'aurais pas des fuites mémoires et autres.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2014
    Messages : 2
    Points : 1
    Points
    1
    Par défaut MPI initialisation erreur
    Je suis à la recherche d'erreur dans mon programme, j'utilise valgrind afin de le déboguer :

    Il me signale cette erreur :
    Conditional jump or move depends on uninitialised value(s)
     at 0x5BA34C9: ??? (in /usr/lib/openmpi/lib/libmpi.so.0.0.2)
     by 0x5BC43A3: PMPI_Init (in /usr/lib/openmpi/lib/libmpi.so.0.0.2)
     by 0x40179A: main (v4.c:121)
     Uninitialised value was created by a stack allocation
     at 0x5BA31A7: ??? (in /usr/lib/openmpi/lib/libmpi.so.0.0.2)
    Je vais donc voir à la ligne 121 de mon code :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    int main(int argc, char **argv) {
    /************ MPI ***************************/
       int myrank_mpi, nprocs_mpi;
      MPI_Init(&argc, &argv);   <- ligne 121

    Je ne comprends pas comment je peux initialiser ces valeurs !

    Ma ligne de commande pour compiler est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    mpicc v4.c -lgslcblas -lscalapack-openmpi -lblacs-openmpi -lblacsCinit-openmpi -g
    Je n'arrive pas à voir d'où provient l'erreur

    Merci

Discussions similaires

  1. Réponses: 15
    Dernier message: 11/12/2010, 17h43
  2. Réponses: 8
    Dernier message: 21/05/2010, 16h17
  3. Réponses: 1
    Dernier message: 14/05/2010, 08h00
  4. Réponses: 1
    Dernier message: 21/10/2009, 10h36
  5. Réponses: 16
    Dernier message: 14/05/2007, 14h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo