61 #define static2 static
62 #if defined(Add_) || defined(f77IsF2C)
63 #define fortran_mr2d pztrmr2do_
64 #define fortran_mr2dnew pztrmr2d_
66 #define fortran_mr2dnew PZTRMR2D
67 #define fortran_mr2d PZTRMR2DO
69 #define zlacpy_ ZLACPY
71 #define fortran_mr2d pztrmr2do
72 #define fortran_mr2dnew pztrmr2d
74 #define zlacpy_ zlacpy
76 #define Clacpy Cztrlacpy
92 #define BLOCK_CYCLIC_2D 1
97 #define SHIFT(row,sprow,nbrow) ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow)))
98 #define max(A,B) ((A)>(B)?(A):(B))
99 #define min(A,B) ((A)>(B)?(B):(A))
100 #define DIVUP(a,b) ( ((a)-1) /(b)+1)
101 #define ROUNDUP(a,b) (DIVUP(a,b)*(b))
103 #define malloc mymalloc
105 #define realloc myrealloc
138 #define scanD0 ztrscanD0
139 #define dispmat ztrdispmat
140 #define setmemory ztrsetmemory
141 #define freememory ztrfreememory
142 #define scan_intervals ztrscan_intervals
175 for (i = 0; i < m * n; i++, pdata++) {
184 getparam(FILE * f,...)
199 static char buffer[200];
204 f = va_arg(ap, FILE *);
207 next = fgets(buffer, 200, f);
209 fprintf(stderr,
"bad configuration driver file:after line %d\n", nbline);
213 }
while (buffer[0] ==
'#');
215 var = va_arg(ap,
int *);
216 while (var != NULL) {
217 *var = strtol(ptr, &next, 10);
219 fprintf(stderr,
"bad configuration driver file:error line %d\n", nbline);
223 var = va_arg(ap,
int *);
237 fprintf(stderr,
"usage with PVM:xztrmr nbproc\n\
238 \t where nbproc is the number of nodes to initialize\n");
241 nproc = atoi(argv[1]);
263 #define nbparameter 24
269 int ia, ja, ib, jb, m, n;
270 int gcontext, context0, context1;
271 int myprow1, myprow0, mypcol0, mypcol1;
275 dcomplex *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
277 MPI_Init(&argc, &argv);
279 setvbuf(stdout, NULL, _IOLBF, 0);
280 setvbuf(stderr, NULL, _IOLBF, 0);
282 free(malloc(14000000));
292 if ((fp = fopen(
"TRMR2D.dat",
"r")) == NULL) {
293 fprintf(stderr,
"Can't open TRMR2D.dat\n");
296 printf(
"\n// ZTRMR2D TESTER for COMPLEX*16 //\n");
297 getparam(fp, &nbre, NULL);
298 printf(
"////////// %d tests \n\n", nbre);
299 parameters[0] = nbre;
300 Cigebs2d(gcontext,
"All",
"H", 1, 1, parameters, 1);
302 Cigebr2d(gcontext,
"All",
"H", 1, 1, parameters, 1, 0, 0);
303 nbre = parameters[0];
306 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
307 m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
313 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
315 while (nbre-- != 0) {
329 uplo = u ?
"UPPER" :
"LOWER";
330 diag = d ?
"UNIT" :
"NONUNIT";
331 printf(
"\t\t************* TEST # %d **********\n",
333 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
334 %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
340 printf(
" %s %s", toupper(*uplo) ==
'U' ?
"up" :
"low",
341 toupper(*diag) ==
'U' ?
"unit" :
"nonunit");
343 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
344 fprintf(stderr,
"not enough nodes:%d processors required\n",
345 max(p0 * q0, p1 * q1));
350 parameters[2] = ma.
nbrow;
351 parameters[3] = ma.
nbcol;
354 parameters[6] = mb.
nbrow;
355 parameters[7] = mb.
nbcol;
356 parameters[8] = ma.
m;
357 parameters[9] = ma.
n;
358 parameters[10] = ma.
sprow;
359 parameters[11] = ma.
spcol;
360 parameters[12] = mb.
sprow;
361 parameters[13] = mb.
spcol;
368 parameters[20] = mb.
m;
369 parameters[21] = mb.
n;
370 parameters[22] = *uplo ==
'U';
371 parameters[23] = *diag ==
'U';
377 ma.
nbrow = parameters[2];
378 ma.
nbcol = parameters[3];
381 mb.
nbrow = parameters[6];
382 mb.
nbcol = parameters[7];
383 ma.
m = parameters[8];
384 ma.
n = parameters[9];
385 ma.
sprow = parameters[10];
386 ma.
spcol = parameters[11];
387 mb.
sprow = parameters[12];
388 mb.
spcol = parameters[13];
395 mb.
m = parameters[20];
396 mb.
n = parameters[21];
399 uplo = parameters[22] ?
"UPPER" :
"LOWER";
400 diag = parameters[23] ?
"UNIT" :
"NONUNIT";
407 if (myprow0 >= p0 || mypcol0 >= q0)
408 myprow0 = mypcol0 = -1;
410 if (myprow1 >= p1 || mypcol1 >= q1)
411 myprow1 = mypcol1 = -1;
412 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
413 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
421 if (myprow0 >= 0 && mypcol0 >= 0) {
427 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
430 for (i = 0; i < blocksize0; i++)
431 ptrmyblockvide[i].r = -1;
433 if (myprow1 >= 0 && mypcol1 >= 0) {
440 ptrmyblock, ia, ja, &ma,
441 ptrsavemyblock, ib, jb, &mb, gcontext);
445 ptrsavemyblock, ib, jb, &mb,
446 ptrmyblockvide, ia, ja, &ma, gcontext);
449 if (myprow0 >= 0 && mypcol0 >= 0) {
451 for (i = 0; i < blocksize0; i++) {
461 assert(gi < ma.
m && gj < ma.
n);
464 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
466 else if (toupper(*uplo) ==
'U')
467 in = (gi <= gj +
max(0, m - n) - (toupper(*diag) ==
'U'));
469 in = (gi >= gj -
max(0, n - m) + (toupper(*diag) ==
'U'));
471 ptrmyblockcopy[i].
r = -1;
473 if (ptrmyblockvide[i].r != ptrmyblockcopy[i].r) {
475 printf(
"Proc %d : Error element number %d, value = %f , initvalue =%f \n"
477 ptrmyblockvide[i].r, ptrmyblockcopy[i].r);
481 printf(
"Processor %d, has tested %d COMPLEX*16 elements,\
482 Number of redistribution errors = %d \n",
483 mypnum, blocksize0, nberrors);
487 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
490 printf(
" => Total number of redistribution errors = %d \n",
493 printf(
"TEST PASSED OK\n");
495 if (myprow0 >= 0 && mypcol0 >= 0) {
501 if (myprow1 >= 0 && mypcol1 >= 0) {