61 #define static2 static
62 #if defined(Add_) || defined(f77IsF2C)
63 #define fortran_mr2d pcgemr2do_
64 #define fortran_mr2dnew pcgemr2d_
66 #define fortran_mr2dnew PCGEMR2D
67 #define fortran_mr2d PCGEMR2DO
69 #define clacpy_ CLACPY
71 #define fortran_mr2d pcgemr2do
72 #define fortran_mr2dnew pcgemr2d
74 #define clacpy_ clacpy
76 #define Clacpy Ccgelacpy
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 cgescanD0
139 #define dispmat cgedispmat
140 #define setmemory cgesetmemory
141 #define freememory cgefreememory
142 #define scan_intervals cgescan_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:xcgemr 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;
274 complex *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
276 MPI_Init(&argc, &argv);
278 setvbuf(stdout, NULL, _IOLBF, 0);
279 setvbuf(stderr, NULL, _IOLBF, 0);
281 free(malloc(14000000));
291 if ((fp = fopen(
"GEMR2D.dat",
"r")) == NULL) {
292 fprintf(stderr,
"Can't open GEMR2D.dat\n");
295 printf(
"\n// CGEMR2D TESTER for COMPLEX //\n");
296 getparam(fp, &nbre, NULL);
297 printf(
"////////// %d tests \n\n", nbre);
298 parameters[0] = nbre;
299 Cigebs2d(gcontext,
"All",
"H", 1, 1, parameters, 1);
301 Cigebr2d(gcontext,
"All",
"H", 1, 1, parameters, 1, 0, 0);
302 nbre = parameters[0];
305 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
306 m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
312 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
314 while (nbre-- != 0) {
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",
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;
369 ma.
nbrow = parameters[2];
370 ma.
nbcol = parameters[3];
373 mb.
nbrow = parameters[6];
374 mb.
nbcol = parameters[7];
375 ma.
m = parameters[8];
376 ma.
n = parameters[9];
377 ma.
sprow = parameters[10];
378 ma.
spcol = parameters[11];
379 mb.
sprow = parameters[12];
380 mb.
spcol = parameters[13];
387 mb.
m = parameters[20];
388 mb.
n = parameters[21];
397 if (myprow0 >= p0 || mypcol0 >= q0)
398 myprow0 = mypcol0 = -1;
400 if (myprow1 >= p1 || mypcol1 >= q1)
401 myprow1 = mypcol1 = -1;
402 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
403 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
411 if (myprow0 >= 0 && mypcol0 >= 0) {
417 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
420 for (i = 0; i < blocksize0; i++)
421 ptrmyblockvide[i].r = -1;
423 if (myprow1 >= 0 && mypcol1 >= 0) {
430 ptrmyblock, ia, ja, &ma,
431 ptrsavemyblock, ib, jb, &mb, gcontext);
435 ptrsavemyblock, ib, jb, &mb,
436 ptrmyblockvide, ia, ja, &ma, gcontext);
439 if (myprow0 >= 0 && mypcol0 >= 0) {
441 for (i = 0; i < blocksize0; i++) {
451 assert(gi < ma.
m && gj < ma.
n);
454 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
457 ptrmyblockcopy[i].
r = -1;
459 if (ptrmyblockvide[i].r != ptrmyblockcopy[i].r) {
461 printf(
"Proc %d : Error element number %d, value = %f , initvalue =%f \n"
463 ptrmyblockvide[i].r, ptrmyblockcopy[i].r);
467 printf(
"Processor %d, has tested %d COMPLEX elements,\
468 Number of redistribution errors = %d \n",
469 mypnum, blocksize0, nberrors);
473 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
476 printf(
" => Total number of redistribution errors = %d \n",
479 printf(
"TEST PASSED OK\n");
481 if (myprow0 >= 0 && mypcol0 >= 0) {
487 if (myprow1 >= 0 && mypcol1 >= 0) {