Kod: |
#include <mpi.h> #include <mkl.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #define gridSize 5 #define NPROC 4 #define NB 2 extern pdlaread_(const char *t, double *a, const int *desc, const int *row, const int *col, const double *work); void ispisi_matricu(int m, int n, double a[]) { int i,j; for (i = 0; i < m; i++) { for(j=0; j < n;j++) { printf("%f ", a[i*n+j] ); } printf("\n"); } } int main(int argc, char* argv[]) { double *A; int i, j, root = NPROC-1; int desc[9], np, myid; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &np); if ( np != NPROC ) { if ( myid == root) fprintf( stderr, "Broj procesa je %d, a treba biti %d!\n", np, NPROC ); goto die; } //BLACS portion int ictxt, nprow, npcol, myrow, mycol, nb = 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); printf("proc %d - moje coords: (%d,%d)\n", myid, myrow, mycol); int M = gridSize; int mA = numroc_(&M, &nb, &myrow, &ZERO, &nprow); int nA = numroc_(&M, &nb, &mycol, &ZERO, &npcol); double dmA = M; //char ime[7] = {'d', 'a', 't', '.', 't', 'x', 't'}; descinit_(desc, &M, &M, &nb, &nb, &ZERO, &ZERO, &ictxt, &mA, &info); A = (double*) malloc (M*M*sizeof(double)); pdlaread_("dat.txt", A, desc, &ZERO, &ZERO, &dmA ); if (myid == 0) ispisi_matricu(M,M,A); free(A); die: MPI_Finalize(); return 0; } |
Kod: |
proc 0 - moje coords: (0,0) proc 1 - moje coords: (0,1) proc 2 - moje coords: (1,0) proc 3 - moje coords: (1,1) { 0, 0}: On entry to PLAWRITE parameter number 1 had an illegal value -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan |
Kod: |
SUBROUTINE PDLAREAD( FILNAM, A, DESCA, IRREAD, ICREAD, WORK ) * * -- ScaLAPACK tools routine (version 1.8) -- * University of Tennessee, Knoxville, Oak Ridge National Laboratory, * and University of California, Berkeley. * * written by Antoine Petitet, August 1995 (petitet@cs.utk.edu) * adapted by Julie Langou, April 2007 (julie@cs.utk.edu) * * .. Scalar Arguments .. INTEGER ICREAD, IRREAD * .. * .. Array Arguments .. CHARACTER*(*) FILNAM INTEGER DESCA( * ) DOUBLE PRECISION A( * ), WORK( * ) * .. * * Purpose * ======= * * PDLAREAD reads from a file named FILNAM a matrix and distribute * it to the process grid. * * Only the process of coordinates {IRREAD, ICREAD} read the file. * * WORK must be of size >= MB_ = DESCA( MB_ ). * * ===================================================================== |
Kod: |
extern void pdlaread_(const char *const filnam, double *const a, const int *const desca, const int *const irread, const int *const icread, double *const work, const int filnam_len); |
output generated using printer-friendly topic mod. Vremenska zona: GMT + 01:00.