|
ScaLAPACK
2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
|
#include "redist.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <ctype.h>Go to the source code of this file.
Data Types | |
| struct | MDESC |
| struct | IDESC |
Defines | |
| #define | static2 static |
| #define | fortran_mr2d pdtrmr2do |
| #define | fortran_mr2dnew pdtrmr2d |
| #define | dcopy_ dcopy |
| #define | dlacpy_ dlacpy |
| #define | Clacpy Cdtrlacpy |
| #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 dtrscanD0 |
| #define | dispmat dtrdispmat |
| #define | setmemory dtrsetmemory |
| #define | freememory dtrfreememory |
| #define | scan_intervals dtrscan_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 | Cdgesd2d () |
| void | Cdgerv2d () |
| void | dlacpy_ () |
| 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 | Cpdtrmr2do () |
| void | Cpdtrmr2d () |
| void | setmemory (double **adpointer, int blocksize) |
| void | freememory (double *ptrtobefreed) |
| static2 int | insidemat (char *uplo, char *diag, int i, int j, int m, int n, int *offset) |
| static2 void | intersect (char *uplo, char *diag, int j, int start, int end, int action, int *ptrsizebuff, double **pptrbuff, double *ptrblock, int m, int n, MDESC *ma, int ia, int ja, int templateheight0, int templatewidth0, MDESC *mb, int ib, int jb, int templateheight1, int templatewidth1) |
| int | scan_intervals (char type, int ja, int jb, int n, MDESC *ma, MDESC *mb, int q0, int q1, int col0, int col1, IDESC *result) |
| void | scanD0 (char *uplo, char *diag, int action, ptrbuff, int *ptrsizebuff, int m, int n, MDESC *ma, int ia, int ja, int p0, int q0, MDESC *mb, int ib, int jb, int p1, int q1, IDESC *v_inter, int vinter_nb, IDESC *h_inter, int hinter_nb, double *ptrbuff *ptrblock) |
| #define SHIFT | ( | row, | |
| sprow, | |||
| nbrow | |||
| ) | ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow))) |
| 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 | ( | ) |
| void Cdgerv2d | ( | ) |
| void Cdgesd2d | ( | ) |
| int changeorigin | ( | ) |
| void Cigamn2d | ( | ) |
| void Cigamx2d | ( | ) |
| void Cigebr2d | ( | ) |
| void Cigebs2d | ( | ) |
| void Cigerv2d | ( | ) |
| void Cigesd2d | ( | ) |
| void Cigsum2d | ( | ) |
| void Clacpy | ( | ) |
| void Cpdtrmr2d | ( | ) |
| void Cpdtrmr2do | ( | ) |
| void Csetpvmtids | ( | ) |
| void dispmat | ( | ) |
| void dlacpy_ | ( | ) |
| void freememory | ( | ) |
| void freememory | ( | double * | ptrtobefreed | ) |
| static2 int insidemat | ( | char * | uplo, |
| char * | diag, | ||
| int | i, | ||
| int | j, | ||
| int | m, | ||
| int | n, | ||
| int * | offset | ||
| ) |
Definition at line 141 of file pdtrmr2.c.
{
/* tests outside mxn */
assert(j >= 0 && j < n);
assert(i >= 0);
if (toupper(*uplo) == 'U') {
int nbline; /* number of lines in the j_th column */
int virtualnbline; /* number of line if we were not limited by m */
*offset = 0;
virtualnbline = max(m - n, 0) + j + (toupper(*diag) == 'N');
nbline = min(virtualnbline, m);
return nbline - i;
} else {
int firstline; /* first line in the j_th column */
int diagcol; /* column where the diag begin */
int virtualline; /* virtual first line if the matrix was extended with
* negative indices */
int off;
diagcol = max(n - m, 0);;
virtualline = j - diagcol + (toupper(*diag) == 'U');
firstline = max(0, virtualline);
off = max(firstline - i, 0);
*offset = off;
i += off;
return m - i;
}
}/* insidemat() */
| static2 void intersect | ( | char * | uplo, |
| char * | diag, | ||
| int | j, | ||
| int | start, | ||
| int | end, | ||
| int | action, | ||
| int * | ptrsizebuff, | ||
| double ** | pptrbuff, | ||
| double * | ptrblock, | ||
| int | m, | ||
| int | n, | ||
| MDESC * | ma, | ||
| int | ia, | ||
| int | ja, | ||
| int | templateheight0, | ||
| int | templatewidth0, | ||
| MDESC * | mb, | ||
| int | ib, | ||
| int | jb, | ||
| int | templateheight1, | ||
| int | templatewidth1 | ||
| ) |
Definition at line 176 of file pdtrmr2.c.
{
/* int un = 1; only when we use dcopy instead of memcpy */
double *ptrstart;
int offset, nbline;
int intervalsize;
assert(start < end);
assert(j >= 0 && j < n);
nbline =
insidemat(uplo, diag, start, j, m, n, &offset);
if (nbline <= 0)
return;
start += offset;
if (start >= end)
return;
intervalsize = min(end - start, nbline);
(*ptrsizebuff) += intervalsize;
switch (action) {
case SENDBUFF: /* fill buff with local elements to be sent */
ptrstart = ptrblock + localindice(start + ia, j + ja,
templateheight0, templatewidth0, ma);
memcpy((char *) (*pptrbuff), (char *) ptrstart,
intervalsize * sizeof(double));
/* dcopy_(&intervalsize, (char *) (ptrstart), &un, (char *) (*pptrbuff),
* &un); */
(*pptrbuff) += intervalsize;
break;
case RECVBUFF: /* fill local memory with the values received */
ptrstart = ptrblock + localindice(start + ib, j + jb,
templateheight1, templatewidth1, mb);
memcpy((char *) ptrstart, (char *) (*pptrbuff),
intervalsize * sizeof(double));
/* dcopy_(&intervalsize, (char *) (*pptrbuff), &un, (char *) (ptrstart),
* &un); */
(*pptrbuff) += intervalsize;
break;
case SIZEBUFF: /* computation of sizebuff */
break;
default:
printf("action is %d outside the scope of the case [0..2] !! \n ", action);
exit(0);
break;
}; /* switch (action) */
}/* intersect() */
| int localindice | ( | ) |
| int localsize | ( | ) |
| int memoryblocksize | ( | ) |
| void* mr2d_malloc | ( | ) |
| void paramcheck | ( | ) |
| int ppcm | ( | ) |
| int scan_intervals | ( | ) |
| int scan_intervals | ( | char | type, |
| int | ja, | ||
| int | jb, | ||
| int | n, | ||
| MDESC * | ma, | ||
| MDESC * | mb, | ||
| int | q0, | ||
| int | q1, | ||
| int | col0, | ||
| int | col1, | ||
| IDESC * | result | ||
| ) |
Definition at line 243 of file pdtrmr2.c.
{
int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
int l; /* local indice on the beginning of the interval */
assert(type == 'c' || type == 'r');
nbcol0 = (type == 'c' ? ma->nbcol : ma->nbrow);
nbcol1 = (type == 'c' ? mb->nbcol : mb->nbrow);
templatewidth0 = q0 * nbcol0;
templatewidth1 = q1 * nbcol1;
{
int sp0 = (type == 'c' ? ma->spcol : ma->sprow);
int sp1 = (type == 'c' ? mb->spcol : mb->sprow);
j0 = SHIFT(col0, sp0, q0) * nbcol0 - ja;
j1 = SHIFT(col1, sp1, q1) * nbcol1 - jb;
}
offset = 0;
l = 0;
/* a small check to verify that the submatrix begin inside the first block
* of the original matrix, this done by a sort of coordinate change at the
* beginning of the Cpdtrmr2d */
assert(j0 + nbcol0 > 0);
assert(j1 + nbcol1 > 0);
while ((j0 < n) && (j1 < n)) {
int end0, end1;
int start, end;
end0 = j0 + nbcol0;
end1 = j1 + nbcol1;
if (end0 <= j1) {
j0 += templatewidth0;
l += nbcol0;
continue;
}
if (end1 <= j0) {
j1 += templatewidth1;
continue;
}
/* compute the raw intersection */
start = max(j0, j1);
start = max(start, 0);
/* the start is correct now, update the corresponding fields */
result[offset].gstart = start;
end = min(end0, end1);
if (end0 == end) {
j0 += templatewidth0;
l += nbcol0;
}
if (end1 == end)
j1 += templatewidth1;
/* throw the limit if they go out of the matrix */
end = min(end, n);
assert(end > start);
/* it is a bit tricky to see why the length is always positive after all
* this min and max, first we have the property that every interval
* considered is at least partly into the submatrix, second we arrive
* here only if the raw intersection is non-void, if we remove a limit
* that means the corresponding frontier is in both intervals which
* proove the final interval is non-void, clear ?? */
result[offset].len = end - start;
offset += 1;
} /* while */
return offset;
}
| void scanD0 | ( | ) |
| void scanD0 | ( | char * | uplo, |
| char * | diag, | ||
| int | action, | ||
| ptrbuff | , | ||
| int * | ptrsizebuff, | ||
| int | m, | ||
| int | n, | ||
| MDESC * | ma, | ||
| int | ia, | ||
| int | ja, | ||
| int | p0, | ||
| int | q0, | ||
| MDESC * | mb, | ||
| int | ib, | ||
| int | jb, | ||
| int | p1, | ||
| int | q1, | ||
| IDESC * | v_inter, | ||
| int | vinter_nb, | ||
| IDESC * | h_inter, | ||
| int | hinter_nb, | ||
| double *ptrbuff * | ptrblock | ||
| ) |
Definition at line 313 of file pdtrmr2.c.
{/* Rmk: the a+au type addresses are strict bounds as a+au does not belong to
* the [a..a+au-1] interval of length au */
int templateheight1, templatewidth1;
int templateheight0, templatewidth0;
int h, v; /* for scanning the intervals */
/* initializations */
templateheight1 = p1 * mb->nbrow;
templateheight0 = p0 * ma->nbrow;
templatewidth1 = q1 * mb->nbcol;
templatewidth0 = q0 * ma->nbcol;
/* we now will deal will logical grids, that's to say we change our
* numbering of processors so that (0,0) begin on logical processor (0,0) */
/* in case we will not enter the while loop */
(*ptrsizebuff) = 0;
for (h = 0; h < hinter_nb; h++)
for (v = 0; v < vinter_nb; v++) {
int j;
for (j = 0; j < h_inter[h].len; j++)
intersect(uplo, diag, j + h_inter[h].gstart,
v_inter[v].gstart, v_inter[v].gstart + v_inter[v].len,
action, ptrsizebuff, &ptrbuff, ptrblock, m, n,
ma, ia, ja, templateheight0, templatewidth0,
mb, ib, jb, templateheight1, templatewidth1);
}
}/* scanD0() */
| void setmemory | ( | ) |
| void setmemory | ( | double ** | adpointer, |
| int | blocksize | ||
| ) |
Definition at line 113 of file pdtrmr2.c.
{
assert(blocksize >= 0);
if (blocksize == 0) {
*adpointer = NULL;
return;
}
*adpointer = (double *) mr2d_malloc(
blocksize * sizeof(double));
}