Example #1
0
void 
dgather(int ictxt, int n, int numc, int nb, double *A, double *A_d, int *descAd){

int RootNodeic, ione=1, izero=0, isRootNode=0, nru, info;
int nprow, npcol, myrow, mycol, descA[9], itemp;
int i,k;

   sl_init_(&RootNodeic, &ione, &ione);

   Cblacs_gridinfo(ictxt, &nprow,&npcol, &myrow, &mycol);

   if (myrow==0 && mycol ==0){ isRootNode = 1;}

   if(isRootNode){
      nru = numroc_(&n, &n, &myrow, &izero, &nprow);
      itemp = max(1,nru);
      descinit_(descA, &n, &numc, &n, &n, &izero, &izero, &RootNodeic, &itemp, &info );
   }
   else{
      k=0;
      for(i=0;i<9;i++){
          descA[k]=0;
          k++;
      }
      descA[1]=-1;
    }

   pdgemr2d_(&n,&numc,A_d,&ione, &ione, descAd, A, &ione, &ione, descA, &ictxt );

   if (isRootNode){
       Cblacs_gridexit(RootNodeic);
   }
  
}
Example #2
0
void redistScidbToScaLAPACK(double *A, const slpp::desc_t& DESCA, double *B, const slpp::desc_t& DESCB)
{
    // see note above about how DESC_SCIDB is a view of Scidb data that ScaLAPACK
    // can access with a 1D block-cyclic
    slpp::desc_t DESCA_SCIDB = scidbDistrib(DESCA) ;

    std::cerr << "redistScidbToScaLAPACK: DESCA ************" << std::endl ;
    std::cerr << DESCA  << std::endl;
    std::cerr << "redistScidbToScaLAPACK: DESCA_SCIDB ************" << std::endl ;
    std::cerr << DESCA_SCIDB  << std::endl;
    std::cerr << "redistScidbToScaLAPACK: DESCB ************" << std::endl ;
    std::cerr << DESCB  << std::endl;

    size_t heightInChunks = (DESCA.M+DESCA.MB-1)/DESCA.MB ; // divide, rounding up
    size_t widthInChunks =  (DESCA.N+DESCA.NB-1)/DESCA.NB ; // divide, rounding up
    for(size_t rowChunk=0 ; rowChunk < heightInChunks ; rowChunk++) {
        // or row=0 ; row < M, row += MB

        // copy a row from A, using DESCA_SCIDB as a trick
        slpp::int_t blockRows = std::min(DESCA.MB, DESCA.M-slpp::int_t(rowChunk)*DESCA.MB) ;
        size_t Arow = rowChunk*heightInChunks;
        size_t A1Dcolumn = rowChunk*widthInChunks;

        std::cerr <<"redistScidbToScaLAPACK: rowChunk: " << rowChunk << std::endl;
        std::cerr <<"redistScidbToScaLAPACK: blockRows: " << blockRows << std::endl;
        std::cerr <<"redistScidbToScaLAPACK: blockCols: " << DESCA.N << std::endl;
        std::cerr <<"redistScidbToScaLAPACK: JA: " << A1Dcolumn << std::endl;
        std::cerr <<"redistScidbToScaLAPACK: Arow: " << Arow << std::endl;
        pdgemr2d_(blockRows, DESCA.N, A, /*IA*/0, /*JA*/A1Dcolumn, DESCA_SCIDB, B, Arow, 0, DESCB, DESCB.CTXT);
        // TODO: where's INFO in that call? how do I check for failure?
    }
}
Example #3
0
void 
ddistr(int ictxt, int n, int numc, int nb, double *A , double *A_d, int *descAd ){

int RootNodeic, ione=1, izero=0, isRootNode=0, nru, info;
int nprow, npcol, myrow, mycol,descA[9], itemp;
int i,k;

/*
#ifdef NOUNDERLAPACK
 sl_init__(&RootNodeic,&ione, &ione);
#else
  sl_init__(&RootNodeic,&ione, &ione);
#endif
*/



   
  sl_init_(&RootNodeic,&ione, &ione);
  
  Cblacs_gridinfo(ictxt, &nprow, &npcol, &myrow, &mycol);  


	//printf("nprow=%d, npcol=%d, myrow=%d, mycol=%d\n",nprow,npcol,myrow,mycol);
	//printf("nb=%d\n",nb);


  if (myrow==0 && mycol==0) { isRootNode=1;}

  if (isRootNode){
     //printf("root entro aca...\n");
	nru = numroc_(&n, &n, &myrow,&izero, &nprow );
     //printf("root paso numroc\n");
	itemp = max(1, nru);
     descinit_(descA, &n, &numc, &n, &n, &izero, &izero, &RootNodeic, &itemp, &info);
  	//printf("root paso descinit\n");
  } 
  else{
     //printf("yo entre aca\n");
     k=0;
     for(i=0;i<9;i++){ 
       descA[k]=0;
       k++;
     }
     descA[1]=-1;
  }

  //printf("inicio de cosas para todos\n");
  nru = numroc_(&n, &nb, &myrow, &izero, &nprow);
  //printf("todos pasan numroc\n");
  itemp = max(1,nru);
  descinit_(descAd, &n, &numc, &nb, &nb, &izero, &izero, &ictxt,&itemp, &info);  
  //printf("todos pasan descinit\n");

  pdgemr2d_( &n, &numc, A, &ione, &ione, descA, A_d, &ione, &ione, descAd, &ictxt);
  //printf("todos pasan pdgemr2d\n");
  
 if (isRootNode){ 
     	//printf("RootNodeic=%d\n",RootNodeic);
	Cblacs_gridexit(RootNodeic);
	//printf("root paso gridexit\n");
  }
}