2012-04-24 20 views
1

Blacのpdgemmを使用して行列乗算をプリフォームしようとしています。 http://www.netlib.org/scalapack/html/pblas_qref.html#PvGEMMCでmpiとlapackを使用した場合のセグメンテーションフォルトの取得

私のコードでは、「スレッドローカルデータ用にメモリを割り当てることができません:ABORT」というpdgemm呼び出しが返されます。私のコードでは、それ自身で行列を掛けているので正方行列なので、結果として得られる行列は同じ次元です。ここで私はScaLapacsで多くの経験を持っていけない

#include <stdlib.h> 
#include <stdio.h> 
#include "mpi.h" 
#include <math.h> 

#define gridSize 10 

int main(int argc, char* argv[]) { 
    int i,j,k, np, myid; 
    int bufsize; 
    double *buf;   /* Buffer for reading */ 

    MPI_Offset filesize; 
    MPI_File myfile; /* Shared file */ 
    MPI_Status status; /* Status returned from read */ 

    /* Initialize MPI */ 
    MPI_Init(&argc, &argv); 
    MPI_Comm_rank(MPI_COMM_WORLD, &myid); 
    MPI_Comm_size(MPI_COMM_WORLD, &np); 

    double *A = (double*) malloc(gridSize*gridSize*sizeof(double)); 

    /*MPI-IO Code removed for clarity including buf and bufsize assignments 
    . 
    . 
    . 
    . 
    */ 
    //I use mpi-IO to read in a matrix from a file, each processor reads in a row and that row is store in the array called buf 
    for (j = 0; j <bufsize;j++){ 
    A[myid*bufsize+j] = buf[j]; 
    } 

    //BLACS portion 
    int ictxt, nprow, npcol, myrow, mycol, nb; 
    int info,itemp; 
    int ZERO = 0, ONE = 1; 
    nprow = 2; npcol = 2; nb = 2; 

    Cblacs_pinfo(&myid,&np); 
    Cblacs_get(-1,0,&ictxt); 
    Cblacs_gridinit(&ictxt,"Row",nprow,npcol); 
    Cblacs_gridinfo(ictxt,&nprow,&npcol,&myrow,&mycol); 

    int M = gridSize; 

    int descA[9], descx[9], descy[9]; 
    int mA = numroc_(&M, &nb, &myrow, &ZERO, &nprow); 
    int nA = numroc_(&M, &nb, &mycol, &ZERO, &npcol); 
    int nx = numroc_(&M, &nb, &myrow, &ZERO, &nprow); 
    int my = numroc_(&M ,&nb, &myrow, &ZERO, &nprow); 

    descinit_(descA,&M,&M,&nb,&nb,&ZERO,&ZERO,&ictxt,&mA,&info); 
    descinit_(descx,&M,&M,&nb,&nb,&ZERO,&ZERO,&ictxt,&nx,&info); 

    descinit_(descy,&M,&M,&nb,&nb,&ZERO,&ZERO,&ictxt,&my,&info); 


    double* matrixA = (double*)malloc(mA*nA*sizeof(double)); 
    double* matrixB = (double*)malloc(mA*nA*sizeof(double)); 
    double* matrixC = (double*)calloc(mA*nA,sizeof(double)); 
    int sat,sut; 


    for(i=0;i<mA;i++){ 
    for(j=0;j<nA;j++){ 
     sat = (myrow*nb)+i+(i/nb)*nb; 
     sut = (mycol*nb)+j+(j/nb)*nb; 
     matrixA[j*mA+i] = A[sat*M+sut]; 
     matrixB[j*mA+i] = A[sat*M+sut]; 
    } 
    } 

    double alpha = 1.0; double beta = 0.0; 

    //call where seg fault happens 
    pdgemm_("N","N",&M,&M,&M,&alpha,matrixA,&ONE,&ONE,descA,matrixB,&ONE,&ONE,descx, 
     &beta,matrixC,&ONE,&ONE,descy); 

    Cblacs_barrier(ictxt,"A"); 

    Cblacs_gridexit(0); 

    /* Close the file */ 
    MPI_File_close(&myfile); 

    if (myid==0) { 
    printf("Done\n"); 

    } 
    MPI_Finalize(); 

    exit(0); 

} 

問題

のコードですが、私は、セグメンテーションフォールトを取得していますなぜ私は以上見てきた例から、私はわからない、任意の助けいただければ幸いです。

+1

Fortranルーチンでは、ILP64インタフェースとも呼ばれる64バイ整数を使用できます。あなたはどちらを持っていますか? – Anycorn

+0

@Anycornはどの変数ですか?私は宣言でプレーンな古いintを使用しています –

+0

私はFortranのルーチンを言っています。例えば、pdgemmは32ビットではなく64ビットの整数を期待するかもしれません。 – Anycorn

答えて

2

私は右に「INT」を変更することでそれを得た静的ライブラリをリンクすることで動作します、私が試した「長いダブル」

別の方法に「長い」と「ダブル」。

mpiccの-w -oa交流-L $ MKLPATH -I $ IMKLPATH -Wl、 - 起動グループ$ MKLPATH/libmkl_scalapack.a $ MKLPATH/libmkl_blacs_openmpi_lp64.a $ MKLPATH/libmkl_intel_lp64.a $ MKLPATH/libmkl_intel_thread.a $ MKLPATH/libmkl_core.a -static_mpi -Wl、-end-group -lpthread -lm -openmp

関連する問題