61 #define static2 static
62 #if defined(Add_) || defined(f77IsF2C)
63 #define fortran_mr2d pdgemr2do_
64 #define fortran_mr2dnew pdgemr2d_
66 #define fortran_mr2dnew PDGEMR2D
67 #define fortran_mr2d PDGEMR2DO
69 #define dlacpy_ DLACPY
71 #define fortran_mr2d pdgemr2do
72 #define fortran_mr2dnew pdgemr2d
74 #define dlacpy_ dlacpy
76 #define Clacpy Cdgelacpy
89 #define BLOCK_CYCLIC_2D 1
94 #define SHIFT(row,sprow,nbrow) ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow)))
95 #define max(A,B) ((A)>(B)?(A):(B))
96 #define min(A,B) ((A)>(B)?(B):(A))
97 #define DIVUP(a,b) ( ((a)-1) /(b)+1)
98 #define ROUNDUP(a,b) (DIVUP(a,b)*(b))
100 #define malloc mymalloc
102 #define realloc myrealloc
135 #define scanD0 dgescanD0
136 #define dispmat dgedispmat
137 #define setmemory dgesetmemory
138 #define freememory dgefreememory
139 #define scan_intervals dgescan_intervals
172 for (i = 0; i < m * n; i++, pdata++) {
181 getparam(FILE * f,...)
196 static char buffer[200];
201 f = va_arg(ap, FILE *);
204 next = fgets(buffer, 200, f);
206 fprintf(stderr,
"bad configuration driver file:after line %d\n", nbline);
210 }
while (buffer[0] ==
'#');
212 var = va_arg(ap,
int *);
213 while (var != NULL) {
214 *var = strtol(ptr, &next, 10);
216 fprintf(stderr,
"bad configuration driver file:error line %d\n", nbline);
220 var = va_arg(ap,
int *);
234 fprintf(stderr,
"usage with PVM:xdgemr nbproc\n\
235 \t where nbproc is the number of nodes to initialize\n");
238 nproc = atoi(argv[1]);
260 #define nbparameter 24
266 int ia, ja, ib, jb, m, n;
267 int gcontext, context0, context1;
268 int myprow1, myprow0, mypcol0, mypcol1;
271 double *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
273 MPI_Init(&argc, &argv);
275 setvbuf(stdout, NULL, _IOLBF, 0);
276 setvbuf(stderr, NULL, _IOLBF, 0);
278 free(malloc(14000000));
288 if ((fp = fopen(
"GEMR2D.dat",
"r")) == NULL) {
289 fprintf(stderr,
"Can't open GEMR2D.dat\n");
292 printf(
"\n// DGEMR2D TESTER for DOUBLE PRECISION //\n");
293 getparam(fp, &nbre, NULL);
294 printf(
"////////// %d tests \n\n", nbre);
295 parameters[0] = nbre;
296 Cigebs2d(gcontext,
"All",
"H", 1, 1, parameters, 1);
298 Cigebr2d(gcontext,
"All",
"H", 1, 1, parameters, 1, 0, 0);
299 nbre = parameters[0];
302 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
303 m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
309 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
311 while (nbre-- != 0) {
324 printf(
"\t\t************* TEST # %d **********\n",
326 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
327 %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
334 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
335 fprintf(stderr,
"not enough nodes:%d processors required\n",
336 max(p0 * q0, p1 * q1));
341 parameters[2] = ma.
nbrow;
342 parameters[3] = ma.
nbcol;
345 parameters[6] = mb.
nbrow;
346 parameters[7] = mb.
nbcol;
347 parameters[8] = ma.
m;
348 parameters[9] = ma.
n;
349 parameters[10] = ma.
sprow;
350 parameters[11] = ma.
spcol;
351 parameters[12] = mb.
sprow;
352 parameters[13] = mb.
spcol;
359 parameters[20] = mb.
m;
360 parameters[21] = mb.
n;
366 ma.
nbrow = parameters[2];
367 ma.
nbcol = parameters[3];
370 mb.
nbrow = parameters[6];
371 mb.
nbcol = parameters[7];
372 ma.
m = parameters[8];
373 ma.
n = parameters[9];
374 ma.
sprow = parameters[10];
375 ma.
spcol = parameters[11];
376 mb.
sprow = parameters[12];
377 mb.
spcol = parameters[13];
384 mb.
m = parameters[20];
385 mb.
n = parameters[21];
394 if (myprow0 >= p0 || mypcol0 >= q0)
395 myprow0 = mypcol0 = -1;
397 if (myprow1 >= p1 || mypcol1 >= q1)
398 myprow1 = mypcol1 = -1;
399 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
400 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
408 if (myprow0 >= 0 && mypcol0 >= 0) {
414 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
415 blocksize0 *
sizeof(
double));
417 for (i = 0; i < blocksize0; i++)
418 ptrmyblockvide[i] = -1;
420 if (myprow1 >= 0 && mypcol1 >= 0) {
427 ptrmyblock, ia, ja, &ma,
428 ptrsavemyblock, ib, jb, &mb, gcontext);
432 ptrsavemyblock, ib, jb, &mb,
433 ptrmyblockvide, ia, ja, &ma, gcontext);
436 if (myprow0 >= 0 && mypcol0 >= 0) {
438 for (i = 0; i < blocksize0; i++) {
448 assert(gi < ma.
m && gj < ma.
n);
451 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
454 ptrmyblockcopy[i] = -1;
456 if (ptrmyblockvide[i] != ptrmyblockcopy[i]) {
458 printf(
"Proc %d : Error element number %d, value = %f , initvalue =%f \n"
460 ptrmyblockvide[i], ptrmyblockcopy[i]);
464 printf(
"Processor %d, has tested %d DOUBLE PRECISION elements,\
465 Number of redistribution errors = %d \n",
466 mypnum, blocksize0, nberrors);
470 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
473 printf(
" => Total number of redistribution errors = %d \n",
476 printf(
"TEST PASSED OK\n");
478 if (myprow0 >= 0 && mypcol0 >= 0) {
484 if (myprow1 >= 0 && mypcol1 >= 0) {