2014-05-18 1 views
4

http://acts.nersc.gov/scalapack/hands-on/etc/pddttrdrv/pddttrdrv.c.html에서 간단한 Hello World (MKL) ScaLapack 예제를 실행하려고하는데 문제가 발생했습니다 (MPICH2를 사용하고 있고 OS가 Windows 임).MKL ScaLapack 문제

나는 MPI 플래그

로 코드를 실행하면 -localonly 2

내가 얻을 :

{ -1, -1}: On entry to 
{ -1, -1}: On entry to 
parameter number 1 had an illegal value 
parameter number 1 had an illegal value 

PDDTTRF, D&C alg.: only 1 block per proc

,

필자는 매개 변수를 두 번 점검하고 온라인 참조와 비교하여 값이 정확한지 확인하고 문제점을 찾지 못했는지 확인합니다.

코드는 다음과 같습니다

#include <mpi.h> 
#define numroc_ NUMROC 
#define descinit_ DESCINIT 
#include <iostream> 
#include <math.h> 
#include <mkl_pblas.h> 
#include <mkl_scalapack.h> 
#include <mkl_blacs.h> 
using namespace std; 

extern "C" { 
    /* Cblacs declarations */ 
    void Cblacs_pinfo(int*, int*); 
    void Cblacs_get(int, int, int*); 
    void Cblacs_gridinit(int*, const char*, int, int); 
    void Cblacs_pcoord(int, int, int*, int*); 
    void Cblacs_gridexit(int); 
    void Cblacs_barrier(int, const char*); 
    void Cdgerv2d(int, int, int, double*, int, int, int); 
    void Cdgesd2d(int, int, int, double*, int, int, int); 
    void Cblacs_gridmap(int*, int*, int, int, int); 
    void Cblacs_exit(int);  
    int numroc_(int*, int*, int*, int*, int*); 
} 


int main(int argc, char **argv) 
{ 


    int  context, desca[9], descb[9], ib, info, ja, laf, lda, ldb, 
     lwork, mb, mype, n, nb, npcol, npe, nprow, nrhs; 
    double b[4], d[4], dl[4], du[4]; 
    double *af, *work; 
    char trans = 'N'; 

    /* Set array dimensions and blocking */ 

    n = 8;   /* dimension of the problem */ 
    lda = 4;   /* leading dimension of A */ 
    ldb = 4;   /* leading dimension of B */ 
    nrhs = 1;   /* number of right-hand sides */ 
    npcol = 2;  /* number of processor columns */ 
    ja = 1;   /* offset for A */ 
    ib = ja;   /* offset for B */ 
    mb = 4;   /* blocking */ 
    nb = 4;   /* blocking */ 

    laf = 12 * npcol + 3 * nb; 
    af = (double *)malloc(laf*sizeof(double)); 
    lwork = 10 * npcol + 4 * nrhs; 
    work = (double *)malloc(lwork*sizeof(double)); 

    /* Start BLACS */ 


    Cblacs_pinfo(&mype, &npe); 
    Cblacs_get(0, 0, &context); 
    Cblacs_gridinit(&context, "R", 1, npe); 

    if (mype == 0){ 
     /* PE = 0 gets D(1:4), DL(1:4), DU(1:4) and B(1:4) */ 
     d[0] = 1.8180; d[1] = 1.6602; d[2] = 1.3420; d[3] = 1.2897; 
     dl[0] = 0.0000; dl[1] = 0.8385; dl[2] = 0.5681; dl[3] = 0.3704; 
     du[0] = 0.6946; du[1] = 0.4449; du[2] = 0.5466; du[3] = 0.7027; 
     b[0] = 1.0; b[1] = 2.0; b[2] = 3.0; b[3] = 4.0; 
    } 
    else if (mype == 1){ 
     /* PE = 1 gets D(5:8), DL(5:8), DU(5:8) and B(5:8) */ 
     d[0] = 1.3412; d[1] = 1.5341; d[2] = 1.7271; d[3] = 1.3093; 
     dl[0] = 0.7027; dl[1] = 0.5466; dl[2] = 0.4449; dl[3] = 0.6946; 
     du[0] = 0.3704; du[1] = 0.5681; du[2] = 0.8385; du[3] = 0.0000; 
     b[0] = 5.0; b[1] = 6.0; b[2] = 7.0; b[3] = 8.0; 
    } 

    /* Array descriptor for A (D, DL and DU) */ 

    desca[0] = 501; desca[1] = context; desca[2] = n; desca[3] = nb; 
    desca[4] = 0; desca[5] = lda; desca[6] = 0; 

    /* Array descriptor for B */ 

    descb[0] = 502; descb[1] = context; descb[2] = n; descb[3] = nb; 
    descb[4] = 0; descb[5] = ldb; descb[6] = 0; 

    /* Factorization */ 

    pddttrf(&n, dl, d, du, &ja, desca, af, &laf, work, &lwork, &info); 

    /* Solution */ 

    //pddttrs(&trans, &n, &nrhs, dl, d, du, &ja, desca, b, &ib, descb, 
    // af, &laf, work, &lwork, &info); 

    printf("MYPE=%i: x[:] = %7.4f %7.4f %7.4f %7.4f\n", 
     mype, b[0], b[1], b[2], b[3]); 

    Cblacs_gridexit(context); 
    Cblacs_exit(0); 

} 

답변

0

인텔의 forum에서 (주석 섹션에 맞게 너무 커서) 단지 코멘트, 그것은 미래에 누군가가 도움이되기를 바랍니다.

[[email protected] scalapack]$run -np 2 ./a.out 
MYPE=0: x[:] = 1.0000 2.0000 3.0000 4.0000 
MYPE=1: x[:] = 5.0000 6.0000 7.0000 8.0000 

2 단계로 실행됩니다. 코드 설계대로.

1 순위로 실행하면 예상대로 오류가 반환됩니다.

[[email protected] scalapack]$ mpirun -np 1 ./a.out 
{ 0, 0}: On entry to 
PDDTTRF, D&C alg.: only 1 block per proc parameter number 1 had an illegal value 
pddttrf problem! Info -1 
MYPE=0: x[:] = 1.0000 2.0000 3.0000 4.0000 

그의 { -1, -1} 때문에 코드가 먼저 Cblacs_get(0, 0, &context);에서 잘못 될 것 같다.

관련 문제