OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pztrmr2.c File Reference
#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 Structures

struct  dcomplex
struct  MDESC
struct  IDESC

Macros

#define static2   static
#define fortran_mr2d   pztrmr2do
#define fortran_mr2dnew   pztrmr2d
#define zcopy_   zcopy
#define zlacpy_   zlacpy
#define Clacpy   Cztrlacpy
#define BLOCK_CYCLIC_2D   1
#define SHIFT(row, sprow, nbrow)
#define max(A, B)
#define min(A, B)
#define DIVUP(a, b)
#define ROUNDUP(a, b)
#define scanD0   ztrscanD0
#define dispmat   ztrdispmat
#define setmemory   ztrsetmemory
#define freememory   ztrfreememory
#define scan_intervals   ztrscan_intervals
#define SENDBUFF   0
#define RECVBUFF   1
#define SIZEBUFF   2
#define NDEBUG

Functions

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 Czgesd2d ()
void Czgerv2d ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
void Cpztrmr2do ()
void Cpztrmr2d ()
void setmemory (dcomplex **adpointer, Int blocksize)
void freememory (dcomplex *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, dcomplex **pptrbuff, dcomplex *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, dcomplex *ptrbuff *ptrblock)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 39 of file pztrmr2.c.

◆ Clacpy

#define Clacpy   Cztrlacpy

Definition at line 23 of file pztrmr2.c.

◆ dispmat

#define dispmat   ztrdispmat

Definition at line 86 of file pztrmr2.c.

◆ DIVUP

#define DIVUP ( a,
b )
Value:
( ((a)-1) /(b)+1)

Definition at line 47 of file pztrmr2.c.

◆ fortran_mr2d

#define fortran_mr2d   pztrmr2do

Definition at line 18 of file pztrmr2.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pztrmr2d

Definition at line 19 of file pztrmr2.c.

◆ freememory

#define freememory   ztrfreememory

Definition at line 88 of file pztrmr2.c.

◆ max

#define max ( A,
B )
Value:
((A)>(B)?(A):(B))

Definition at line 45 of file pztrmr2.c.

◆ min

#define min ( A,
B )
Value:
((A)>(B)?(B):(A))

Definition at line 46 of file pztrmr2.c.

◆ NDEBUG

#define NDEBUG

Definition at line 105 of file pztrmr2.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 99 of file pztrmr2.c.

◆ ROUNDUP

#define ROUNDUP ( a,
b )
Value:
(DIVUP(a,b)*(b))
#define DIVUP(a, b)
Definition pcgemr.c:182

Definition at line 48 of file pztrmr2.c.

◆ scan_intervals

#define scan_intervals   ztrscan_intervals

Definition at line 89 of file pztrmr2.c.

◆ scanD0

#define scanD0   ztrscanD0

Definition at line 85 of file pztrmr2.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 98 of file pztrmr2.c.

◆ setmemory

#define setmemory   ztrsetmemory

Definition at line 87 of file pztrmr2.c.

◆ SHIFT

#define SHIFT ( row,
sprow,
nbrow )
Value:
((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow)))

Definition at line 44 of file pztrmr2.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 100 of file pztrmr2.c.

◆ static2

#define static2   static

Definition at line 8 of file pztrmr2.c.

◆ zcopy_

#define zcopy_   zcopy

Definition at line 20 of file pztrmr2.c.

◆ zlacpy_

#define zlacpy_   zlacpy

Definition at line 21 of file pztrmr2.c.

Function Documentation

◆ Cblacs_exit()

void Cblacs_exit ( )
extern

◆ Cblacs_get()

void Cblacs_get ( )
extern

◆ Cblacs_gridexit()

void Cblacs_gridexit ( )
extern

◆ Cblacs_gridinfo()

void Cblacs_gridinfo ( )
extern

◆ Cblacs_gridinit()

void Cblacs_gridinit ( )
extern

◆ Cblacs_pcoord()

void Cblacs_pcoord ( )
extern

◆ Cblacs_pinfo()

void Cblacs_pinfo ( )
extern

◆ Cblacs_pnum()

Int Cblacs_pnum ( )
extern

◆ Cblacs_setup()

void Cblacs_setup ( )
extern

◆ changeorigin()

Int changeorigin ( )
extern

◆ Cigamn2d()

void Cigamn2d ( )
extern

◆ Cigamx2d()

void Cigamx2d ( )
extern

◆ Cigebr2d()

void Cigebr2d ( )
extern

◆ Cigebs2d()

void Cigebs2d ( )
extern

◆ Cigerv2d()

void Cigerv2d ( )
extern

◆ Cigesd2d()

void Cigesd2d ( )
extern

◆ Cigsum2d()

void Cigsum2d ( )
extern

◆ Cpztrmr2d()

void Cpztrmr2d ( )
extern

◆ Cpztrmr2do()

void Cpztrmr2do ( )
extern

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ Czgerv2d()

void Czgerv2d ( )
extern

◆ Czgesd2d()

void Czgesd2d ( )
extern

◆ freememory()

void freememory ( dcomplex * ptrtobefreed)

Definition at line 129 of file pztrmr2.c.

130{
131 if (ptrtobefreed == NULL)
132 return;
133 free((char *) ptrtobefreed);
134}

◆ insidemat()

static2 Int insidemat ( char * uplo,
char * diag,
Int i,
Int j,
Int m,
Int n,
Int * offset )

Definition at line 141 of file pztrmr2.c.

145{
146 /* tests outside mxn */
147 assert(j >= 0 && j < n);
148 assert(i >= 0);
149 if (toupper(*uplo) == 'U') {
150 Int nbline; /* number of lines in the j_th column */
151 Int virtualnbline; /* number of line if we were not limited by m */
152 *offset = 0;
153 virtualnbline = max(m - n, 0) + j + (toupper(*diag) == 'N');
154 nbline = min(virtualnbline, m);
155 return nbline - i;
156 } else {
157 Int firstline; /* first line in the j_th column */
158 Int diagcol; /* column where the diag begin */
159 Int virtualline; /* virtual first line if the matrix was extended with
160 * negative indices */
161 Int off;
162 diagcol = max(n - m, 0);;
163 virtualline = j - diagcol + (toupper(*diag) == 'U');
164 firstline = max(0, virtualline);
165 off = max(firstline - i, 0);
166 *offset = off;
167 i += off;
168 return m - i;
169 }
170}/* insidemat() */
#define Int
Definition Bconfig.h:22
integer, dimension(:), allocatable offset
Definition rad2r.F:53
#define max(A, B)
Definition pztrmr2.c:45
#define min(A, B)
Definition pztrmr2.c:46
n

◆ intersect()

static2 void intersect ( char * uplo,
char * diag,
Int j,
Int start,
Int end,
Int action,
Int * ptrsizebuff,
dcomplex ** pptrbuff,
dcomplex * 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 pztrmr2.c.

195{
196 /* int un = 1; only when we use dcopy instead of memcpy */
197 dcomplex *ptrstart;
198 Int offset, nbline;
199 Int intervalsize;
200 assert(start < end);
201 assert(j >= 0 && j < n);
202 nbline =
203 insidemat(uplo, diag, start, j, m, n, &offset);
204 if (nbline <= 0)
205 return;
206 start += offset;
207 if (start >= end)
208 return;
209 intervalsize = min(end - start, nbline);
210 (*ptrsizebuff) += intervalsize;
211 switch (action) {
212 case SENDBUFF: /* fill buff with local elements to be sent */
213 ptrstart = ptrblock + localindice(start + ia, j + ja,
214 templateheight0, templatewidth0, ma);
215 memcpy((char *) (*pptrbuff), (char *) ptrstart,
216 intervalsize * sizeof(dcomplex));
217 /* zcopy_(&intervalsize, (char *) (ptrstart), &un, (char *) (*pptrbuff),
218 * &un); */
219 (*pptrbuff) += intervalsize;
220 break;
221 case RECVBUFF: /* fill local memory with the values received */
222 ptrstart = ptrblock + localindice(start + ib, j + jb,
223 templateheight1, templatewidth1, mb);
224 memcpy((char *) ptrstart, (char *) (*pptrbuff),
225 intervalsize * sizeof(dcomplex));
226 /* zcopy_(&intervalsize, (char *) (*pptrbuff), &un, (char *) (ptrstart),
227 * &un); */
228 (*pptrbuff) += intervalsize;
229 break;
230 case SIZEBUFF: /* computation of sizebuff */
231 break;
232 default:
233 printf("action is %d outside the scope of the case [0..2] !! \n ", action);
234 exit(0);
235 break;
236 }; /* switch (action) */
237}/* intersect() */
end[inform, rinform, sol, inst, schur, redrhs, pivnul_list, sym_perm, uns_perm, icntl, cntl, colsca_out, rowsca_out, keep_out, dkeep_out]
Definition dmumps.m:40
#define SIZEBUFF
Definition pcgemr.c:235
#define SENDBUFF
Definition pcgemr.c:233
#define RECVBUFF
Definition pcgemr.c:234
static2 Int insidemat(char *uplo, char *diag, Int i, Int j, Int m, Int n, Int *offset)
Definition pztrmr2.c:141
Int localindice()

◆ localindice()

Int localindice ( )
extern

◆ localsize()

Int localsize ( )
extern

◆ memoryblocksize()

Int memoryblocksize ( )
extern

◆ mr2d_malloc()

void * mr2d_malloc ( )
extern

◆ paramcheck()

void paramcheck ( )
extern

◆ ppcm()

Int ppcm ( )
extern

◆ 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 pztrmr2.c.

249{
250 Int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
251 Int l; /* local indice on the beginning of the interval */
252 assert(type == 'c' || type == 'r');
253 nbcol0 = (type == 'c' ? ma->nbcol : ma->nbrow);
254 nbcol1 = (type == 'c' ? mb->nbcol : mb->nbrow);
255 templatewidth0 = q0 * nbcol0;
256 templatewidth1 = q1 * nbcol1;
257 {
258 Int sp0 = (type == 'c' ? ma->spcol : ma->sprow);
259 Int sp1 = (type == 'c' ? mb->spcol : mb->sprow);
260 j0 = SHIFT(col0, sp0, q0) * nbcol0 - ja;
261 j1 = SHIFT(col1, sp1, q1) * nbcol1 - jb;
262 }
263 offset = 0;
264 l = 0;
265 /* a small check to verify that the submatrix begin inside the first block
266 * of the original matrix, this done by a sort of coordinate change at the
267 * beginning of the Cpztrmr2d */
268 assert(j0 + nbcol0 > 0);
269 assert(j1 + nbcol1 > 0);
270 while ((j0 < n) && (j1 < n)) {
271 Int end0, end1;
272 Int start, end;
273 end0 = j0 + nbcol0;
274 end1 = j1 + nbcol1;
275 if (end0 <= j1) {
276 j0 += templatewidth0;
277 l += nbcol0;
278 continue;
279 }
280 if (end1 <= j0) {
281 j1 += templatewidth1;
282 continue;
283 }
284 /* compute the raw intersection */
285 start = max(j0, j1);
286 start = max(start, 0);
287 /* the start is correct now, update the corresponding fields */
288 result[offset].gstart = start;
289 end = min(end0, end1);
290 if (end0 == end) {
291 j0 += templatewidth0;
292 l += nbcol0;
293 }
294 if (end1 == end)
295 j1 += templatewidth1;
296 /* throw the limit if they go out of the matrix */
297 end = min(end, n);
298 assert(end > start);
299 /* it is a bit tricky to see why the length is always positive after all
300 * this min and max, first we have the property that every interval
301 * considered is at least partly into the submatrix, second we arrive
302 * here only if the raw intersection is non-void, if we remove a limit
303 * that means the corresponding frontier is in both intervals which
304 * proove the final interval is non-void, clear ?? */
305 result[offset].len = end - start;
306 offset += 1;
307 } /* while */
308 return offset;
309}
#define SHIFT(row, sprow, nbrow)
Definition pztrmr2.c:44
Int len
Definition pcgemr.c:177
Int gstart
Definition pctrmr.c:191
Int spcol
Definition pcgemr.c:171
Int nbcol
Definition pcgemr.c:169
Int sprow
Definition pcgemr.c:170
Int nbrow
Definition pcgemr.c:168

◆ 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,
dcomplex *ptrbuff * ptrblock )

Definition at line 313 of file pztrmr2.c.

333{/* Rmk: the a+au type addresses are strict bounds as a+au does not belong to
334 * the [a..a+au-1] interval of length au */
335 Int templateheight1, templatewidth1;
336 Int templateheight0, templatewidth0;
337 Int h, v; /* for scanning the intervals */
338 /* initializations */
339 templateheight1 = p1 * mb->nbrow;
340 templateheight0 = p0 * ma->nbrow;
341 templatewidth1 = q1 * mb->nbcol;
342 templatewidth0 = q0 * ma->nbcol;
343 /* we now will deal will logical grids, that's to say we change our
344 * numbering of processors so that (0,0) begin on logical processor (0,0) */
345 /* in case we will not enter the while loop */
346 (*ptrsizebuff) = 0;
347 for (h = 0; h < hinter_nb; h++)
348 for (v = 0; v < vinter_nb; v++) {
349 Int j;
350 for (j = 0; j < h_inter[h].len; j++)
351 intersect(uplo, diag, j + h_inter[h].gstart,
352 v_inter[v].gstart, v_inter[v].gstart + v_inter[v].len,
353 action, ptrsizebuff, &ptrbuff, ptrblock, m, n,
354 ma, ia, ja, templateheight0, templatewidth0,
355 mb, ib, jb, templateheight1, templatewidth1);
356 }
357}/* scanD0() */
static2 void intersect(char *uplo, char *diag, Int j, Int start, Int end, Int action, Int *ptrsizebuff, dcomplex **pptrbuff, dcomplex *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 pztrmr2.c:176

◆ setmemory()

void setmemory ( dcomplex ** adpointer,
Int blocksize )

Definition at line 116 of file pztrmr2.c.

117{
118 assert(blocksize >= 0);
119 if (blocksize == 0) {
120 *adpointer = NULL;
121 return;
122 }
123 *adpointer = (dcomplex *) mr2d_malloc(
124 blocksize * sizeof(dcomplex));
125}
void * mr2d_malloc()