|
ScaLAPACK
2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
|
#include "redist.h"#include <stdio.h>#include <stdlib.h>#include <assert.h>Go to the source code of this file.
Data Types | |
| struct | MDESC |
| struct | IDESC |
Defines | |
| #define | static2 static |
| #define | fortran_mr2d pigemr2do |
| #define | fortran_mr2dnew pigemr2d |
| #define | icopy_ icopy |
| #define | ilacpy_ ilacpy |
| #define | Clacpy Cigelacpy |
| #define | BLOCK_CYCLIC_2D 1 |
| #define | SHIFT(row, sprow, nbrow) ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow))) |
| #define | max(A, B) ((A)>(B)?(A):(B)) |
| #define | min(A, B) ((A)>(B)?(B):(A)) |
| #define | DIVUP(a, b) ( ((a)-1) /(b)+1) |
| #define | ROUNDUP(a, b) (DIVUP(a,b)*(b)) |
| #define | scanD0 igescanD0 |
| #define | dispmat igedispmat |
| #define | setmemory igesetmemory |
| #define | freememory igefreememory |
| #define | scan_intervals igescan_intervals |
| #define | SENDBUFF 0 |
| #define | RECVBUFF 1 |
| #define | SIZEBUFF 2 |
| #define | NDEBUG |
Functions/Subroutines | |
| void | Clacpy () |
| void | Cblacs_pcoord () |
| int | Cblacs_pnum () |
| void | Csetpvmtids () |
| void | Cblacs_get () |
| void | Cblacs_pinfo () |
| void | Cblacs_gridinfo () |
| void | Cblacs_gridinit () |
| void | Cblacs_exit () |
| void | Cblacs_gridexit () |
| void | Cblacs_setup () |
| void | Cigebs2d () |
| void | Cigebr2d () |
| void | Cigesd2d () |
| void | Cigerv2d () |
| void | Cigsum2d () |
| void | Cigamn2d () |
| void | Cigamx2d () |
| void | ilacpy_ () |
| int | localindice () |
| void * | mr2d_malloc () |
| int | ppcm () |
| int | localsize () |
| int | memoryblocksize () |
| int | changeorigin () |
| void | paramcheck () |
| void | scanD0 () |
| void | dispmat () |
| void | setmemory () |
| void | freememory () |
| int | scan_intervals () |
| void | Cpigemr2do () |
| void | Cpigemr2d () |
| void * | mr2d_malloc (int n) |
| int | pgcd (int a, int b) |
| int | ppcm (int a, int b) |
| int | localsize (int myprow, int p, int nbrow, int m) |
| int | memoryblocksize (MDESC *a) |
| void | checkequal (int ctxt, int a) |
| void | paramcheck (MDESC *a, int i, int j, int m, int n, int p, int q, gcontext) |
| int | changeorigin (int myp, int sp, int p, int bs, int i, int *decal, int *newsp) |
| int | localindice (int ig, int jg, int templateheight, int templatewidth, MDESC *a) |
| #define BLOCK_CYCLIC_2D 1 |
Definition at line 36 of file pgemraux.c.
| #define Clacpy Cigelacpy |
Definition at line 23 of file pgemraux.c.
| #define dispmat igedispmat |
Definition at line 83 of file pgemraux.c.
| #define DIVUP | ( | a, | |
| b | |||
| ) | ( ((a)-1) /(b)+1) |
Definition at line 44 of file pgemraux.c.
| #define fortran_mr2d pigemr2do |
Definition at line 18 of file pgemraux.c.
| #define fortran_mr2dnew pigemr2d |
Definition at line 19 of file pgemraux.c.
| #define freememory igefreememory |
Definition at line 85 of file pgemraux.c.
| #define icopy_ icopy |
Definition at line 20 of file pgemraux.c.
| #define ilacpy_ ilacpy |
Definition at line 21 of file pgemraux.c.
| #define max | ( | A, | |
| B | |||
| ) | ((A)>(B)?(A):(B)) |
Definition at line 42 of file pgemraux.c.
| #define min | ( | A, | |
| B | |||
| ) | ((A)>(B)?(B):(A)) |
Definition at line 43 of file pgemraux.c.
| #define NDEBUG |
Definition at line 102 of file pgemraux.c.
| #define RECVBUFF 1 |
Definition at line 96 of file pgemraux.c.
| #define ROUNDUP | ( | a, | |
| b | |||
| ) | (DIVUP(a,b)*(b)) |
Definition at line 45 of file pgemraux.c.
| #define scan_intervals igescan_intervals |
Definition at line 86 of file pgemraux.c.
| #define scanD0 igescanD0 |
Definition at line 82 of file pgemraux.c.
| #define SENDBUFF 0 |
Definition at line 95 of file pgemraux.c.
| #define setmemory igesetmemory |
Definition at line 84 of file pgemraux.c.
| #define SHIFT | ( | row, | |
| sprow, | |||
| nbrow | |||
| ) | ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow))) |
Definition at line 41 of file pgemraux.c.
| #define SIZEBUFF 2 |
Definition at line 97 of file pgemraux.c.
| #define static2 static |
Definition at line 8 of file pgemraux.c.
| void Cblacs_exit | ( | ) |
| void Cblacs_get | ( | ) |
| void Cblacs_gridexit | ( | ) |
| void Cblacs_gridinfo | ( | ) |
| void Cblacs_gridinit | ( | ) |
| void Cblacs_pcoord | ( | ) |
| void Cblacs_pinfo | ( | ) |
| int Cblacs_pnum | ( | ) |
| void Cblacs_setup | ( | ) |
| int changeorigin | ( | ) |
| int changeorigin | ( | int | myp, |
| int | sp, | ||
| int | p, | ||
| int | bs, | ||
| int | i, | ||
| int * | decal, | ||
| int * | newsp | ||
| ) |
Definition at line 258 of file pgemraux.c.
{
int tempheight, firstblock, firsttemp;
/* we begin by changing the parameters so that ia < templatewidth,... */
tempheight = bs * p;
firsttemp = i / tempheight;
firstblock = (i / bs) % p;
*newsp = (sp + firstblock) % p;
if (myp >= 0)
*decal = firsttemp * bs + (SHIFT(myp, sp, p) < firstblock ? bs : 0);
else
*decal = 0;
return i % bs;
}
| void checkequal | ( | int | ctxt, |
| int | a | ||
| ) |
Definition at line 191 of file pgemraux.c.
{
int np, dummy, nbrow, myp, b;
Cblacs_gridinfo(ctxt, &nbrow, &np, &dummy, &myp);
assert(nbrow == 1);
if (np == 1)
return;
if (myp == 0) {
Cigesd2d(ctxt, 1, 1, &a, 1, 0, 1);
Cigerv2d(ctxt, 1, 1, &b, 1, 0, np - 1);
assert(a == b);
} else {
Cigerv2d(ctxt, 1, 1, &b, 1, 0, myp - 1);
assert(a == b);
Cigesd2d(ctxt, 1, 1, &a, 1, 0, (myp + 1) % np);
}
}
| void Cigamn2d | ( | ) |
| void Cigamx2d | ( | ) |
| void Cigebr2d | ( | ) |
| void Cigebs2d | ( | ) |
| void Cigerv2d | ( | ) |
| void Cigesd2d | ( | ) |
| void Cigsum2d | ( | ) |
| void Clacpy | ( | ) |
| void Cpigemr2d | ( | ) |
| void Cpigemr2do | ( | ) |
| void Csetpvmtids | ( | ) |
| void dispmat | ( | ) |
| void freememory | ( | ) |
| void ilacpy_ | ( | ) |
| int localindice | ( | ) |
| int localindice | ( | int | ig, |
| int | jg, | ||
| int | templateheight, | ||
| int | templatewidth, | ||
| MDESC * | a | ||
| ) |
Definition at line 277 of file pgemraux.c.
{
int vtemp, htemp, vsubtemp, hsubtemp, il, jl;
assert(ig >= 0 && ig < a->m && jg >= 0 && jg < a->n);
/* coordinates in global matrix with the tests in intersect, ig MUST BE in
* [0..m] and jg in [0..n] */
/* coordinates of the template that "owns" the element */
vtemp = ig / templateheight;
htemp = jg / templatewidth;
/* coordinates of the element in the subblock of the (vtemp, htemp)
* template */
vsubtemp = ig % a->nbrow;
hsubtemp = jg % a->nbcol;
/* coordinates of the element in the local block of the processor */
il = a->nbrow * vtemp + vsubtemp;
jl = a->nbcol * htemp + hsubtemp;
assert(il < a->lda);
#ifndef NDEBUG
{
int pr, pc, p, q, lp, lq;
Cblacs_gridinfo(a->ctxt, &p, &q, &pr, &pc);
p = templateheight / a->nbrow;
q = templatewidth / a->nbcol;
lp = ig % templateheight / a->nbrow;
lq = jg % templatewidth / a->nbcol;
assert(lp == SHIFT(pr, a->sprow, p));
assert(lq == SHIFT(pc, a->spcol, q));
}
#endif
return (jl * a->lda + il);
}
| int localsize | ( | ) |
| int localsize | ( | int | myprow, |
| int | p, | ||
| int | nbrow, | ||
| int | m | ||
| ) |
Definition at line 148 of file pgemraux.c.
{
int templateheight, blockheight;
templateheight = p * nbrow;
if (m % templateheight != 0) { /* not an exact boundary */
if ((m % templateheight) > (nbrow * myprow)) { /* processor
* (myprow,mypcol) has
* some elements in that
* incomplete template */
if ((m % templateheight) >= (nbrow * (myprow + 1))) { /* processor
* (myprow,mypcol)'s
* part is complete */
blockheight = (m / templateheight) * nbrow + nbrow;
} else { /* processor (myprow,mypcol)'s part is not complete */
blockheight = (m / templateheight) * nbrow + (m % nbrow);
}; /* if ((m%templateheight) > (nbrow*(myprow+1))) */
} else { /* processor (myprow,mypcol) has no element in that
* incomplete template */
blockheight = (m / templateheight) * nbrow;
}; /* if ((m%templateheight) > (nbrow*myprow)) */
} else { /* exact boundary */
blockheight = m / p; /* (m/templateheight) * nbrow */
}; /* if (m%templateheight !=0) */
return blockheight;
}
| int memoryblocksize | ( | ) |
| int memoryblocksize | ( | MDESC * | a | ) |
Definition at line 177 of file pgemraux.c.
{
int myprow, mypcol, p, q;
/* Compute the (myprow,mypcol) indices of processor mypnum in P0xQ0 We
* assume the row-major ordering of the BLACS */
Cblacs_gridinfo(a->ctxt, &p, &q, &myprow, &mypcol);
myprow = SHIFT(myprow, a->sprow, p);
mypcol = SHIFT(mypcol, a->spcol, q);
assert(myprow >= 0 && mypcol >= 0);
return localsize(myprow, p, a->nbrow, a->m) *
localsize(mypcol, q, a->nbcol, a->n);
}
| void* mr2d_malloc | ( | ) |
| void* mr2d_malloc | ( | int | n | ) |
Definition at line 108 of file pgemraux.c.
{
void *ptr;
assert(n > 0);
ptr = (void *) malloc(n);
if (ptr == NULL) {
fprintf(stderr, "xxmr2d:out of memory\n");
exit(2);
}
return ptr;
}
| void paramcheck | ( | ) |
| void paramcheck | ( | MDESC * | a, |
| int | i, | ||
| int | j, | ||
| int | m, | ||
| int | n, | ||
| int | p, | ||
| int | q, | ||
| gcontext | |||
| ) |
Definition at line 210 of file pgemraux.c.
{
int p2, q2, myprow, mypcol;
#ifndef NDEBUG
checkequal(gcontext, p);
checkequal(gcontext, q);
checkequal(gcontext, a->sprow);
checkequal(gcontext, a->spcol);
checkequal(gcontext, a->m);
checkequal(gcontext, a->n);
checkequal(gcontext, i);
checkequal(gcontext, j);
checkequal(gcontext, a->nbrow);
checkequal(gcontext, a->nbcol);
#endif
Cblacs_gridinfo(a->ctxt, &p2, &q2, &myprow, &mypcol);
/* compatibility T3D, must check myprow and mypcol are within bounds */
if (myprow >= p2 || mypcol >= q2)
myprow = mypcol = -1;
if ((myprow >= 0 || mypcol >= 0) && (p2 != p && q2 != q)) {
fprintf(stderr, "??MR2D:incoherent p,q parameters\n");
exit(1);
}
assert(myprow < p && mypcol < q);
if (a->sprow < 0 || a->sprow >= p || a->spcol < 0 || a->spcol >= q) {
fprintf(stderr, "??MR2D:Bad first processor coordinates\n");
exit(1);
}
if (i < 0 || j < 0 || i + m > a->m || j + n > a->n) {
fprintf(stderr, "??MR2D:Bad submatrix:i=%d,j=%d,\
m=%d,n=%d,M=%d,N=%d\n",
i, j, m, n, a->m, a->n);
exit(1);
}
if ((myprow >= 0 || mypcol >= 0) &&
localsize(SHIFT(myprow, a->sprow, p), p, a->nbrow, a->m) > a->lda) {
fprintf(stderr, "??MR2D:bad lda arg:row=%d,m=%d,p=%d,\
nbrow=%d,lda=%d,sprow=%d\n",
myprow, a->m, p, a->nbrow, a->lda, a->sprow);
exit(1);
}
}
| int pgcd | ( | int | a, |
| int | b | ||
| ) |
Definition at line 121 of file pgemraux.c.
{
int aux;
if (a < b)
return pgcd(b, a);
else {
aux = a % b;
if (aux == 0)
return b;
else
return pgcd(b, aux);
}
}
| int ppcm | ( | ) |
| int ppcm | ( | int | a, |
| int | b | ||
| ) |
Definition at line 136 of file pgemraux.c.
{
int pg;
pg = pgcd(a, b);
return a * (b / pg);
}
| int scan_intervals | ( | ) |
| void scanD0 | ( | ) |
| void setmemory | ( | ) |