OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pdtrmr2.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  MDESC
struct  IDESC

Macros

#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)
#define max(A, B)
#define min(A, B)
#define DIVUP(a, b)
#define ROUNDUP(a, 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

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 ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
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)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 36 of file pdtrmr2.c.

◆ Clacpy

#define Clacpy   Cdtrlacpy

Definition at line 23 of file pdtrmr2.c.

◆ dcopy_

#define dcopy_   dcopy

Definition at line 20 of file pdtrmr2.c.

◆ dispmat

#define dispmat   dtrdispmat

Definition at line 83 of file pdtrmr2.c.

◆ DIVUP

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

Definition at line 44 of file pdtrmr2.c.

◆ dlacpy_

#define dlacpy_   dlacpy

Definition at line 21 of file pdtrmr2.c.

◆ fortran_mr2d

#define fortran_mr2d   pdtrmr2do

Definition at line 18 of file pdtrmr2.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pdtrmr2d

Definition at line 19 of file pdtrmr2.c.

◆ freememory

#define freememory   dtrfreememory

Definition at line 85 of file pdtrmr2.c.

◆ max

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

Definition at line 42 of file pdtrmr2.c.

◆ min

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

Definition at line 43 of file pdtrmr2.c.

◆ NDEBUG

#define NDEBUG

Definition at line 102 of file pdtrmr2.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 96 of file pdtrmr2.c.

◆ ROUNDUP

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

Definition at line 45 of file pdtrmr2.c.

◆ scan_intervals

#define scan_intervals   dtrscan_intervals

Definition at line 86 of file pdtrmr2.c.

◆ scanD0

#define scanD0   dtrscanD0

Definition at line 82 of file pdtrmr2.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 95 of file pdtrmr2.c.

◆ setmemory

#define setmemory   dtrsetmemory

Definition at line 84 of file pdtrmr2.c.

◆ SHIFT

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

Definition at line 41 of file pdtrmr2.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 97 of file pdtrmr2.c.

◆ static2

#define static2   static

Definition at line 8 of file pdtrmr2.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

◆ Cdgerv2d()

void Cdgerv2d ( )
extern

◆ Cdgesd2d()

void Cdgesd2d ( )
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

◆ Cpdtrmr2d()

void Cpdtrmr2d ( )
extern

◆ Cpdtrmr2do()

void Cpdtrmr2do ( )
extern

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ freememory()

void freememory ( double * ptrtobefreed)

Definition at line 126 of file pdtrmr2.c.

127{
128 if (ptrtobefreed == NULL)
129 return;
130 free((char *) ptrtobefreed);
131}

◆ insidemat()

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

Definition at line 138 of file pdtrmr2.c.

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

◆ intersect()

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 173 of file pdtrmr2.c.

192{
193 /* int un = 1; only when we use dcopy instead of memcpy */
194 double *ptrstart;
195 Int offset, nbline;
196 Int intervalsize;
197 assert(start < end);
198 assert(j >= 0 && j < n);
199 nbline =
200 insidemat(uplo, diag, start, j, m, n, &offset);
201 if (nbline <= 0)
202 return;
203 start += offset;
204 if (start >= end)
205 return;
206 intervalsize = min(end - start, nbline);
207 (*ptrsizebuff) += intervalsize;
208 switch (action) {
209 case SENDBUFF: /* fill buff with local elements to be sent */
210 ptrstart = ptrblock + localindice(start + ia, j + ja,
211 templateheight0, templatewidth0, ma);
212 memcpy((char *) (*pptrbuff), (char *) ptrstart,
213 intervalsize * sizeof(double));
214 /* dcopy_(&intervalsize, (char *) (ptrstart), &un, (char *) (*pptrbuff),
215 * &un); */
216 (*pptrbuff) += intervalsize;
217 break;
218 case RECVBUFF: /* fill local memory with the values received */
219 ptrstart = ptrblock + localindice(start + ib, j + jb,
220 templateheight1, templatewidth1, mb);
221 memcpy((char *) ptrstart, (char *) (*pptrbuff),
222 intervalsize * sizeof(double));
223 /* dcopy_(&intervalsize, (char *) (*pptrbuff), &un, (char *) (ptrstart),
224 * &un); */
225 (*pptrbuff) += intervalsize;
226 break;
227 case SIZEBUFF: /* computation of sizebuff */
228 break;
229 default:
230 printf("action is %d outside the scope of the case [0..2] !! \n ", action);
231 exit(0);
232 break;
233 }; /* switch (action) */
234}/* 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 pdtrmr2.c:138
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 240 of file pdtrmr2.c.

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

Definition at line 310 of file pdtrmr2.c.

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

◆ setmemory()

void setmemory ( double ** adpointer,
Int blocksize )

Definition at line 113 of file pdtrmr2.c.

114{
115 assert(blocksize >= 0);
116 if (blocksize == 0) {
117 *adpointer = NULL;
118 return;
119 }
120 *adpointer = (double *) mr2d_malloc(
121 blocksize * sizeof(double));
122}
void * mr2d_malloc()