OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pstrmr2.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   pstrmr2do
#define fortran_mr2dnew   pstrmr2d
#define scopy_   scopy
#define slacpy_   slacpy
#define Clacpy   Cstrlacpy
#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   strscanD0
#define dispmat   strdispmat
#define setmemory   strsetmemory
#define freememory   strfreememory
#define scan_intervals   strscan_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 Csgesd2d ()
void Csgerv2d ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
void Cpstrmr2do ()
void Cpstrmr2d ()
void setmemory (float **adpointer, Int blocksize)
void freememory (float *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, float **pptrbuff, float *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, float *ptrbuff *ptrblock)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 36 of file pstrmr2.c.

◆ Clacpy

#define Clacpy   Cstrlacpy

Definition at line 23 of file pstrmr2.c.

◆ dispmat

#define dispmat   strdispmat

Definition at line 83 of file pstrmr2.c.

◆ DIVUP

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

Definition at line 44 of file pstrmr2.c.

◆ fortran_mr2d

#define fortran_mr2d   pstrmr2do

Definition at line 18 of file pstrmr2.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pstrmr2d

Definition at line 19 of file pstrmr2.c.

◆ freememory

#define freememory   strfreememory

Definition at line 85 of file pstrmr2.c.

◆ max

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

Definition at line 42 of file pstrmr2.c.

◆ min

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

Definition at line 43 of file pstrmr2.c.

◆ NDEBUG

#define NDEBUG

Definition at line 102 of file pstrmr2.c.

◆ RECVBUFF

#define RECVBUFF   1

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

◆ scan_intervals

#define scan_intervals   strscan_intervals

Definition at line 86 of file pstrmr2.c.

◆ scanD0

#define scanD0   strscanD0

Definition at line 82 of file pstrmr2.c.

◆ scopy_

#define scopy_   scopy

Definition at line 20 of file pstrmr2.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 95 of file pstrmr2.c.

◆ setmemory

#define setmemory   strsetmemory

Definition at line 84 of file pstrmr2.c.

◆ SHIFT

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

Definition at line 41 of file pstrmr2.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 97 of file pstrmr2.c.

◆ slacpy_

#define slacpy_   slacpy

Definition at line 21 of file pstrmr2.c.

◆ static2

#define static2   static

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

◆ Cpstrmr2d()

void Cpstrmr2d ( )
extern

◆ Cpstrmr2do()

void Cpstrmr2do ( )
extern

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ Csgerv2d()

void Csgerv2d ( )
extern

◆ Csgesd2d()

void Csgesd2d ( )
extern

◆ freememory()

void freememory ( float * ptrtobefreed)

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

◆ intersect()

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

192{
193 /* int un = 1; only when we use dcopy instead of memcpy */
194 float *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(float));
214 /* scopy_(&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(float));
223 /* scopy_(&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 pstrmr2.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 pstrmr2.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 Cpstrmr2d */
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 pstrmr2.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,
float *ptrbuff * ptrblock )

Definition at line 310 of file pstrmr2.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, float **pptrbuff, float *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 pstrmr2.c:173

◆ setmemory()

void setmemory ( float ** adpointer,
Int blocksize )

Definition at line 113 of file pstrmr2.c.

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