60 #define static2 static
61 #if defined(Add_) || defined(f77IsF2C)
62 #define fortran_mr2d psgemr2do_
63 #define fortran_mr2dnew psgemr2d_
65 #define fortran_mr2dnew PSGEMR2D
66 #define fortran_mr2d PSGEMR2DO
68 #define slacpy_ SLACPY
70 #define fortran_mr2d psgemr2do
71 #define fortran_mr2dnew psgemr2d
73 #define slacpy_ slacpy
75 #define Clacpy Csgelacpy
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 sgescanD0
135 #define dispmat sgedispmat
136 #define setmemory sgesetmemory
137 #define freememory sgefreememory
138 #define scan_intervals sgescan_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:xsgemr 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;
270 float *ptrmyblock, *ptrsavemyblock, *ptrmyblockcopy, *ptrmyblockvide;
272 MPI_Init(&argc, &argv);
274 setvbuf(stdout, NULL, _IOLBF, 0);
275 setvbuf(stderr, NULL, _IOLBF, 0);
277 free(malloc(14000000));
287 if ((fp = fopen(
"GEMR2D.dat",
"r")) == NULL) {
288 fprintf(stderr,
"Can't open GEMR2D.dat\n");
291 printf(
"\n// SGEMR2D TESTER for REAL //\n");
292 getparam(fp, &nbre, NULL);
293 printf(
"////////// %d tests \n\n", nbre);
294 parameters[0] = nbre;
295 Cigebs2d(gcontext,
"All",
"H", 1, 1, parameters, 1);
297 Cigebr2d(gcontext,
"All",
"H", 1, 1, parameters, 1, 0, 0);
298 nbre = parameters[0];
301 printf(
"\n m n m0 n0 sr0 sc0 i0 j0 p0 q0 nbr0 nbc0 \
302 m1 n1 sr1 sc1 i1 j1 p1 q1 nbr1 nbc1\n\n");
308 fprintf(stderr,
"bonjour,je suis le noeud %d\n", mypnum);
310 while (nbre-- != 0) {
323 printf(
"\t\t************* TEST # %d **********\n",
325 printf(
" %3d %3d %3d %3d %3d %3d %3d %3d \
326 %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
333 if (p0 * q0 > nprocs || p1 * q1 > nprocs) {
334 fprintf(stderr,
"not enough nodes:%d processors required\n",
335 max(p0 * q0, p1 * q1));
340 parameters[2] = ma.
nbrow;
341 parameters[3] = ma.
nbcol;
344 parameters[6] = mb.
nbrow;
345 parameters[7] = mb.
nbcol;
346 parameters[8] = ma.
m;
347 parameters[9] = ma.
n;
348 parameters[10] = ma.
sprow;
349 parameters[11] = ma.
spcol;
350 parameters[12] = mb.
sprow;
351 parameters[13] = mb.
spcol;
358 parameters[20] = mb.
m;
359 parameters[21] = mb.
n;
365 ma.
nbrow = parameters[2];
366 ma.
nbcol = parameters[3];
369 mb.
nbrow = parameters[6];
370 mb.
nbcol = parameters[7];
371 ma.
m = parameters[8];
372 ma.
n = parameters[9];
373 ma.
sprow = parameters[10];
374 ma.
spcol = parameters[11];
375 mb.
sprow = parameters[12];
376 mb.
spcol = parameters[13];
383 mb.
m = parameters[20];
384 mb.
n = parameters[21];
393 if (myprow0 >= p0 || mypcol0 >= q0)
394 myprow0 = mypcol0 = -1;
396 if (myprow1 >= p1 || mypcol1 >= q1)
397 myprow1 = mypcol1 = -1;
398 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
399 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
407 if (myprow0 >= 0 && mypcol0 >= 0) {
413 memcpy((
char *) ptrmyblockcopy, (
char *) ptrmyblock,
414 blocksize0 *
sizeof(
float));
416 for (i = 0; i < blocksize0; i++)
417 ptrmyblockvide[i] = -1;
419 if (myprow1 >= 0 && mypcol1 >= 0) {
426 ptrmyblock, ia, ja, &ma,
427 ptrsavemyblock, ib, jb, &mb, gcontext);
431 ptrsavemyblock, ib, jb, &mb,
432 ptrmyblockvide, ia, ja, &ma, gcontext);
435 if (myprow0 >= 0 && mypcol0 >= 0) {
437 for (i = 0; i < blocksize0; i++) {
447 assert(gi < ma.
m && gj < ma.
n);
450 if (gi < 0 || gj < 0 || gi >= m || gj >= n)
453 ptrmyblockcopy[i] = -1;
455 if (ptrmyblockvide[i] != ptrmyblockcopy[i]) {
460 printf(
"Processor %d, has tested %d REAL elements,\
461 Number of redistribution errors = %d \n",
462 mypnum, blocksize0, nberrors);
466 Cigsum2d(gcontext,
"All",
"H", 1, 1, &nberrors, 1, 0, 0);
469 printf(
" => Total number of redistribution errors = %d \n",
472 printf(
"TEST PASSED OK\n");
474 if (myprow0 >= 0 && mypcol0 >= 0) {
480 if (myprow1 >= 0 && mypcol1 >= 0) {