OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pitrmr2.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   pitrmr2do
#define fortran_mr2dnew   pitrmr2d
#define icopy_   icopy
#define ilacpy_   ilacpy
#define Clacpy   Citrlacpy
#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   itrscanD0
#define dispmat   itrdispmat
#define setmemory   itrsetmemory
#define freememory   itrfreememory
#define scan_intervals   itrscan_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 ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
void Cpitrmr2do ()
void Cpitrmr2d ()
void setmemory (Int **adpointer, Int blocksize)
void freememory (Int *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, Int **pptrbuff, Int *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, Int *ptrbuff *ptrblock)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 36 of file pitrmr2.c.

◆ Clacpy

#define Clacpy   Citrlacpy

Definition at line 23 of file pitrmr2.c.

◆ dispmat

#define dispmat   itrdispmat

Definition at line 83 of file pitrmr2.c.

◆ DIVUP

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

Definition at line 44 of file pitrmr2.c.

◆ fortran_mr2d

#define fortran_mr2d   pitrmr2do

Definition at line 18 of file pitrmr2.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pitrmr2d

Definition at line 19 of file pitrmr2.c.

◆ freememory

#define freememory   itrfreememory

Definition at line 85 of file pitrmr2.c.

◆ icopy_

#define icopy_   icopy

Definition at line 20 of file pitrmr2.c.

◆ ilacpy_

#define ilacpy_   ilacpy

Definition at line 21 of file pitrmr2.c.

◆ max

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

Definition at line 42 of file pitrmr2.c.

◆ min

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

Definition at line 43 of file pitrmr2.c.

◆ NDEBUG

#define NDEBUG

Definition at line 102 of file pitrmr2.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 96 of file pitrmr2.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 pitrmr2.c.

◆ scan_intervals

#define scan_intervals   itrscan_intervals

Definition at line 86 of file pitrmr2.c.

◆ scanD0

#define scanD0   itrscanD0

Definition at line 82 of file pitrmr2.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 95 of file pitrmr2.c.

◆ setmemory

#define setmemory   itrsetmemory

Definition at line 84 of file pitrmr2.c.

◆ SHIFT

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

Definition at line 41 of file pitrmr2.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 97 of file pitrmr2.c.

◆ static2

#define static2   static

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

◆ Cpitrmr2d()

void Cpitrmr2d ( )
extern

◆ Cpitrmr2do()

void Cpitrmr2do ( )
extern

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ freememory()

void freememory ( Int * ptrtobefreed)

Definition at line 126 of file pitrmr2.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 pitrmr2.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 pitrmr2.c:42
#define min(A, B)
Definition pitrmr2.c:43
n

◆ intersect()

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

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

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

Definition at line 302 of file pitrmr2.c.

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

◆ setmemory()

void setmemory ( Int ** adpointer,
Int blocksize )

Definition at line 113 of file pitrmr2.c.

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