60 #define static2 static
61 #if defined(Add_) || defined(f77IsF2C)
62 #define fortran_mr2d pstrmr2do_
63 #define fortran_mr2dnew pstrmr2d_
65 #define fortran_mr2dnew PSTRMR2D
66 #define fortran_mr2d PSTRMR2DO
68 #define slacpy_ SLACPY
70 #define fortran_mr2d pstrmr2do
71 #define fortran_mr2dnew pstrmr2d
73 #define slacpy_ slacpy
75 #define Clacpy Cstrlacpy
88 #define BLOCK_CYCLIC_2D 1
93 #define SHIFT(row,sprow,nbrow) ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow)))
94 #define max(A,B) ((A)>(B)?(A):(B))
95 #define min(A,B) ((A)>(B)?(B):(A))
96 #define DIVUP(a,b) ( ((a)-1) /(b)+1)
97 #define ROUNDUP(a,b) (DIVUP(a,b)*(b))
99 #define malloc mymalloc
101 #define realloc myrealloc
134 #define scanD0 strscanD0
135 #define dispmat strdispmat
136 #define setmemory strsetmemory
137 #define freememory strfreememory
138 #define scan_intervals strscan_intervals
171 for (i = 0; i < m * n; i++, pdata++) {
180 getparam(FILE * f,...)
195 static char buffer[200];
200 f = va_arg(ap, FILE *);
203 next = fgets(buffer, 200, f);
205 fprintf(stderr,
"bad configuration driver file:after line %d\n", nbline);
209 }
while (buffer[0] ==
'#');
211 var = va_arg(ap,
int *);
212 while (var != NULL) {
213 *var = strtol(ptr, &next, 10);
215 fprintf(stderr,
"bad configuration driver file:error line %d\n", nbline);
219 var = va_arg(ap,
int *);
233 fprintf(stderr,
"usage with PVM:xstrmr nbproc\n\
234 \t where nbproc is the number of nodes to initialize\n");
237 nproc = atoi(argv[1]);
259 #define nbparameter 24
265 int ia, ja, ib, jb, m, n;
266 int gcontext, context0, context1;
267 int myprow1, myprow0, mypcol0, mypcol1;
271 float *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(
"TRMR2D.dat",
"r")) == NULL) {
289 fprintf(stderr,
"Can't open TRMR2D.dat\n");
292 printf(
"\n// STRMR2D TESTER for REAL //\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) {
325 uplo = u ?
"UPPER" :
"LOWER";
326 diag = d ?
"UNIT" :
"NONUNIT";
327 printf(
"\t\t************* TEST # %d **********\n",
329 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
330 %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
336 printf(
" %s %s", toupper(*uplo) ==
'U' ?
"up" :
"low",
337 toupper(*diag) ==
'U' ?
"unit" :
"nonunit");
339 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
340 fprintf(stderr,
"not enough nodes:%d processors required\n",
341 max(p0 * q0, p1 * q1));
346 parameters[2] = ma.
nbrow;
347 parameters[3] = ma.
nbcol;
350 parameters[6] = mb.
nbrow;
351 parameters[7] = mb.
nbcol;
352 parameters[8] = ma.
m;
353 parameters[9] = ma.
n;
354 parameters[10] = ma.
sprow;
355 parameters[11] = ma.
spcol;
356 parameters[12] = mb.
sprow;
357 parameters[13] = mb.
spcol;
364 parameters[20] = mb.
m;
365 parameters[21] = mb.
n;
366 parameters[22] = *uplo ==
'U';
367 parameters[23] = *diag ==
'U';
373 ma.
nbrow = parameters[2];
374 ma.
nbcol = parameters[3];
377 mb.
nbrow = parameters[6];
378 mb.
nbcol = parameters[7];
379 ma.
m = parameters[8];
380 ma.
n = parameters[9];
381 ma.
sprow = parameters[10];
382 ma.
spcol = parameters[11];
383 mb.
sprow = parameters[12];
384 mb.
spcol = parameters[13];
391 mb.
m = parameters[20];
392 mb.
n = parameters[21];
395 uplo = parameters[22] ?
"UPPER" :
"LOWER";
396 diag = parameters[23] ?
"UNIT" :
"NONUNIT";
403 if (myprow0 >= p0 || mypcol0 >= q0)
404 myprow0 = mypcol0 = -1;
406 if (myprow1 >= p1 || mypcol1 >= q1)
407 myprow1 = mypcol1 = -1;
408 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
409 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
417 if (myprow0 >= 0 && mypcol0 >= 0) {
423 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
424 blocksize0 *
sizeof(
float));
426 for (i = 0; i < blocksize0; i++)
427 ptrmyblockvide[i] = -1;
429 if (myprow1 >= 0 && mypcol1 >= 0) {
436 ptrmyblock, ia, ja, &ma,
437 ptrsavemyblock, ib, jb, &mb, gcontext);
441 ptrsavemyblock, ib, jb, &mb,
442 ptrmyblockvide, ia, ja, &ma, gcontext);
445 if (myprow0 >= 0 && mypcol0 >= 0) {
447 for (i = 0; i < blocksize0; i++) {
457 assert(gi < ma.
m && gj < ma.
n);
460 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
462 else if (toupper(*uplo) ==
'U')
463 in = (gi <= gj +
max(0, m - n) - (toupper(*diag) ==
'U'));
465 in = (gi >= gj -
max(0, n - m) + (toupper(*diag) ==
'U'));
467 ptrmyblockcopy[i] = -1;
469 if (ptrmyblockvide[i] != ptrmyblockcopy[i]) {
474 printf(
"Processor %d, has tested %d REAL elements,\
475 Number of redistribution errors = %d \n",
476 mypnum, blocksize0, nberrors);
480 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
483 printf(
" => Total number of redistribution errors = %d \n",
486 printf(
"TEST PASSED OK\n");
488 if (myprow0 >= 0 && mypcol0 >= 0) {
494 if (myprow1 >= 0 && mypcol1 >= 0) {