61 #define static2 static
62 #if defined(Add_) || defined(f77IsF2C)
63 #define fortran_mr2d pdtrmr2do_
64 #define fortran_mr2dnew pdtrmr2d_
66 #define fortran_mr2dnew PDTRMR2D
67 #define fortran_mr2d PDTRMR2DO
69 #define dlacpy_ DLACPY
71 #define fortran_mr2d pdtrmr2do
72 #define fortran_mr2dnew pdtrmr2d
74 #define dlacpy_ dlacpy
76 #define Clacpy Cdtrlacpy
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 dtrscanD0
136 #define dispmat dtrdispmat
137 #define setmemory dtrsetmemory
138 #define freememory dtrfreememory
139 #define scan_intervals dtrscan_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:xdtrmr 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;
272 double *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
274 MPI_Init(&argc, &argv);
276 setvbuf(stdout, NULL, _IOLBF, 0);
277 setvbuf(stderr, NULL, _IOLBF, 0);
279 free(malloc(14000000));
289 if ((fp = fopen(
"TRMR2D.dat",
"r")) == NULL) {
290 fprintf(stderr,
"Can't open TRMR2D.dat\n");
293 printf(
"\n// DTRMR2D TESTER for DOUBLE PRECISION //\n");
294 getparam(fp, &nbre, NULL);
295 printf(
"////////// %d tests \n\n", nbre);
296 parameters[0] = nbre;
297 Cigebs2d(gcontext,
"All",
"H", 1, 1, parameters, 1);
299 Cigebr2d(gcontext,
"All",
"H", 1, 1, parameters, 1, 0, 0);
300 nbre = parameters[0];
303 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
304 m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
310 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
312 while (nbre-- != 0) {
326 uplo = u ?
"UPPER" :
"LOWER";
327 diag = d ?
"UNIT" :
"NONUNIT";
328 printf(
"\t\t************* TEST # %d **********\n",
330 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
331 %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
337 printf(
" %s %s", toupper(*uplo) ==
'U' ?
"up" :
"low",
338 toupper(*diag) ==
'U' ?
"unit" :
"nonunit");
340 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
341 fprintf(stderr,
"not enough nodes:%d processors required\n",
342 max(p0 * q0, p1 * q1));
347 parameters[2] = ma.
nbrow;
348 parameters[3] = ma.
nbcol;
351 parameters[6] = mb.
nbrow;
352 parameters[7] = mb.
nbcol;
353 parameters[8] = ma.
m;
354 parameters[9] = ma.
n;
355 parameters[10] = ma.
sprow;
356 parameters[11] = ma.
spcol;
357 parameters[12] = mb.
sprow;
358 parameters[13] = mb.
spcol;
365 parameters[20] = mb.
m;
366 parameters[21] = mb.
n;
367 parameters[22] = *uplo ==
'U';
368 parameters[23] = *diag ==
'U';
374 ma.
nbrow = parameters[2];
375 ma.
nbcol = parameters[3];
378 mb.
nbrow = parameters[6];
379 mb.
nbcol = parameters[7];
380 ma.
m = parameters[8];
381 ma.
n = parameters[9];
382 ma.
sprow = parameters[10];
383 ma.
spcol = parameters[11];
384 mb.
sprow = parameters[12];
385 mb.
spcol = parameters[13];
392 mb.
m = parameters[20];
393 mb.
n = parameters[21];
396 uplo = parameters[22] ?
"UPPER" :
"LOWER";
397 diag = parameters[23] ?
"UNIT" :
"NONUNIT";
404 if (myprow0 >= p0 || mypcol0 >= q0)
405 myprow0 = mypcol0 = -1;
407 if (myprow1 >= p1 || mypcol1 >= q1)
408 myprow1 = mypcol1 = -1;
409 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
410 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
418 if (myprow0 >= 0 && mypcol0 >= 0) {
424 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
425 blocksize0 *
sizeof(
double));
427 for (i = 0; i < blocksize0; i++)
428 ptrmyblockvide[i] = -1;
430 if (myprow1 >= 0 && mypcol1 >= 0) {
437 ptrmyblock, ia, ja, &ma,
438 ptrsavemyblock, ib, jb, &mb, gcontext);
442 ptrsavemyblock, ib, jb, &mb,
443 ptrmyblockvide, ia, ja, &ma, gcontext);
446 if (myprow0 >= 0 && mypcol0 >= 0) {
448 for (i = 0; i < blocksize0; i++) {
458 assert(gi < ma.
m && gj < ma.
n);
461 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
463 else if (toupper(*uplo) ==
'U')
464 in = (gi <= gj +
max(0, m - n) - (toupper(*diag) ==
'U'));
466 in = (gi >= gj -
max(0, n - m) + (toupper(*diag) ==
'U'));
468 ptrmyblockcopy[i] = -1;
470 if (ptrmyblockvide[i] != ptrmyblockcopy[i]) {
472 printf(
"Proc %d : Error element number %d, value = %f , initvalue =%f \n"
474 ptrmyblockvide[i], ptrmyblockcopy[i]);
478 printf(
"Processor %d, has tested %d DOUBLE PRECISION elements,\
479 Number of redistribution errors = %d \n",
480 mypnum, blocksize0, nberrors);
484 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
487 printf(
" => Total number of redistribution errors = %d \n",
490 printf(
"TEST PASSED OK\n");
492 if (myprow0 >= 0 && mypcol0 >= 0) {
498 if (myprow1 >= 0 && mypcol1 >= 0) {