257#define nbparameter 24
263 Int ia, ja, ib, jb, m, n;
264 Int gcontext, context0, context1;
265 Int myprow1, myprow0, mypcol0, mypcol1;
269 complex *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
271 MPI_Init(&argc, &argv);
273 setvbuf(stdout, NULL, _IOLBF, 0);
274 setvbuf(stderr, NULL, _IOLBF, 0);
276 free(malloc(14000000));
286 if ((fp = fopen(
"TRMR2D.dat",
"r")) == NULL) {
287 fprintf(stderr,
"Can't open TRMR2D.dat\n");
290 printf(
"\n// CTRMR2D TESTER for COMPLEX //\n");
291 getparam(fp, &nbre, NULL);
292 printf(
"////////// %d tests \n\n", nbre);
293 parameters[0] = nbre;
297 nbre = parameters[0];
300 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
301m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
307 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
309 while (nbre-- != 0) {
323 uplo = u ?
"UPPER" :
"LOWER";
324 diag = d ?
"UNIT" :
"NONUNIT";
325 printf(
"\t\t************* TEST # %d **********\n",
327 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
328%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
334 printf(
" %s %s", toupper(*uplo) ==
'U' ?
"up" :
"low",
335 toupper(*diag) ==
'U' ?
"unit" :
"nonunit");
337 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
338 fprintf(stderr,
"not enough nodes:%d processors required\n",
339 max(p0 * q0, p1 * q1));
344 parameters[2] = ma.
nbrow;
345 parameters[3] = ma.
nbcol;
348 parameters[6] = mb.
nbrow;
349 parameters[7] = mb.
nbcol;
350 parameters[8] = ma.
m;
351 parameters[9] = ma.
n;
352 parameters[10] = ma.
sprow;
353 parameters[11] = ma.
spcol;
354 parameters[12] = mb.
sprow;
355 parameters[13] = mb.
spcol;
362 parameters[20] = mb.
m;
363 parameters[21] = mb.
n;
364 parameters[22] = *uplo ==
'U';
365 parameters[23] = *diag ==
'U';
371 ma.
nbrow = parameters[2];
372 ma.
nbcol = parameters[3];
375 mb.
nbrow = parameters[6];
376 mb.
nbcol = parameters[7];
377 ma.
m = parameters[8];
378 ma.
n = parameters[9];
379 ma.
sprow = parameters[10];
380 ma.
spcol = parameters[11];
381 mb.
sprow = parameters[12];
382 mb.
spcol = parameters[13];
389 mb.
m = parameters[20];
390 mb.
n = parameters[21];
393 uplo = parameters[22] ?
"UPPER" :
"LOWER";
394 diag = parameters[23] ?
"UNIT" :
"NONUNIT";
401 if (myprow0 >= p0 || mypcol0 >= q0)
402 myprow0 = mypcol0 = -1;
404 if (myprow1 >= p1 || mypcol1 >= q1)
405 myprow1 = mypcol1 = -1;
406 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
407 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
415 if (myprow0 >= 0 && mypcol0 >= 0) {
421 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
424 for (i = 0; i < blocksize0; i++)
425 ptrmyblockvide[i].r = -1;
427 if (myprow1 >= 0 && mypcol1 >= 0) {
434 ptrmyblock, ia, ja, &ma,
435 ptrsavemyblock, ib, jb, &mb, gcontext);
439 ptrsavemyblock, ib, jb, &mb,
440 ptrmyblockvide, ia, ja, &ma, gcontext);
443 if (myprow0 >= 0 && mypcol0 >= 0) {
445 for (i = 0; i < blocksize0; i++) {
455 assert(gi < ma.
m && gj < ma.
n);
458 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
460 else if (toupper(*uplo) ==
'U')
461 in = (gi <= gj +
max(0, m - n) - (toupper(*diag) ==
'U'));
463 in = (gi >= gj -
max(0, n - m) + (toupper(*diag) ==
'U'));
465 ptrmyblockcopy[i].
r = -1;
467 if (ptrmyblockvide[i].r != ptrmyblockcopy[i].r) {
469 printf(
"Proc %d : Error element number %d, value = %f , initvalue =%f \n"
471 ptrmyblockvide[i].r, ptrmyblockcopy[i].r);
475 printf(
"Processor %d, has tested %d COMPLEX elements,\
476Number of redistribution errors = %d \n",
477 mypnum, blocksize0, nberrors);
484 printf(
" => Total number of redistribution errors = %d \n",
487 printf(
"TEST PASSED OK\n");
489 if (myprow0 >= 0 && mypcol0 >= 0) {
495 if (myprow1 >= 0 && mypcol1 >= 0) {