OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pgemraux.c File Reference
#include "redist.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  MDESC
struct  IDESC

Macros

#define static2   static
#define fortran_mr2d   pigemr2do
#define fortran_mr2dnew   pigemr2d
#define icopy_   icopy
#define ilacpy_   ilacpy
#define Clacpy   Cigelacpy
#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   igescanD0
#define dispmat   igedispmat
#define setmemory   igesetmemory
#define freememory   igefreememory
#define scan_intervals   igescan_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 Cpigemr2do ()
void Cpigemr2d ()
void * mr2d_malloc (Int n)
Int pgcd (Int a, Int b)
Int ppcm (Int a, Int b)
Int localsize (Int myprow, Int p, Int nbrow, Int m)
Int memoryblocksize (MDESC *a)
void checkequal (Int ctxt, Int a)
void paramcheck (MDESC *a, Int i, Int j, Int m, Int n, Int p, Int q, Int gcontext)
Int changeorigin (Int myp, Int sp, Int p, Int bs, Int i, Int *decal, Int *newsp)
Int localindice (Int ig, Int jg, Int templateheight, Int templatewidth, MDESC *a)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 36 of file pgemraux.c.

◆ Clacpy

#define Clacpy   Cigelacpy

Definition at line 23 of file pgemraux.c.

◆ dispmat

#define dispmat   igedispmat

Definition at line 83 of file pgemraux.c.

◆ DIVUP

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

Definition at line 44 of file pgemraux.c.

◆ fortran_mr2d

#define fortran_mr2d   pigemr2do

Definition at line 18 of file pgemraux.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pigemr2d

Definition at line 19 of file pgemraux.c.

◆ freememory

#define freememory   igefreememory

Definition at line 85 of file pgemraux.c.

◆ icopy_

#define icopy_   icopy

Definition at line 20 of file pgemraux.c.

◆ ilacpy_

void ilacpy_   ilacpy

Definition at line 21 of file pgemraux.c.

◆ max

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

Definition at line 42 of file pgemraux.c.

◆ min

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

Definition at line 43 of file pgemraux.c.

◆ NDEBUG

#define NDEBUG

Definition at line 102 of file pgemraux.c.

◆ RECVBUFF

#define RECVBUFF   1

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

◆ scan_intervals

#define scan_intervals   igescan_intervals

Definition at line 86 of file pgemraux.c.

◆ scanD0

#define scanD0   igescanD0

Definition at line 82 of file pgemraux.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 95 of file pgemraux.c.

◆ setmemory

#define setmemory   igesetmemory

Definition at line 84 of file pgemraux.c.

◆ SHIFT

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

Definition at line 41 of file pgemraux.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 97 of file pgemraux.c.

◆ static2

#define static2   static

Definition at line 8 of file pgemraux.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() [1/2]

Int changeorigin ( )
extern

◆ changeorigin() [2/2]

Int changeorigin ( Int myp,
Int sp,
Int p,
Int bs,
Int i,
Int * decal,
Int * newsp )

Definition at line 250 of file pgemraux.c.

251{
252 Int tempheight, firstblock, firsttemp;
253 /* we begin by changing the parameters so that ia < templatewidth,... */
254 tempheight = bs * p;
255 firsttemp = i / tempheight;
256 firstblock = (i / bs) % p;
257 *newsp = (sp + firstblock) % p;
258 if (myp >= 0)
259 *decal = firsttemp * bs + (SHIFT(myp, sp, p) < firstblock ? bs : 0);
260 else
261 *decal = 0;
262 return i % bs;
263}
#define Int
Definition Bconfig.h:22
integer, parameter sp
#define SHIFT(row, sprow, nbrow)
Definition pgemraux.c:41

◆ checkequal()

void checkequal ( Int ctxt,
Int a )

Definition at line 186 of file pgemraux.c.

187{
188 Int np, dummy, nbrow, myp, b;
189 Cblacs_gridinfo(ctxt, &nbrow, &np, &dummy, &myp);
190 assert(nbrow == 1);
191 if (np == 1)
192 return;
193 if (myp == 0) {
194 Cigesd2d(ctxt, (Int)1, (Int)1, &a, (Int)1, (Int)0, (Int)1);
195 Cigerv2d(ctxt, (Int)1, (Int)1, &b, (Int)1, (Int)0, np - 1);
196 assert(a == b);
197 } else {
198 Cigerv2d(ctxt, (Int)1, (Int)1, &b, (Int)1, (Int)0, myp - 1);
199 assert(a == b);
200 Cigesd2d(ctxt, (Int)1, (Int)1, &a, (Int)1, (Int)0, (myp + 1) % np);
201 }
202}
void Cigerv2d()
void Cblacs_gridinfo()
void Cigesd2d()

◆ 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

◆ Cpigemr2d()

void Cpigemr2d ( )
extern

◆ Cpigemr2do()

void Cpigemr2do ( )
extern

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ localindice() [1/2]

Int localindice ( )
extern

◆ localindice() [2/2]

Int localindice ( Int ig,
Int jg,
Int templateheight,
Int templatewidth,
MDESC * a )

Definition at line 267 of file pgemraux.c.

270{
271 Int vtemp, htemp, vsubtemp, hsubtemp, il, jl;
272 assert(ig >= 0 && ig < a->m && jg >= 0 && jg < a->n);
273 /* coordinates in global matrix with the tests in intersect, ig MUST BE in
274 * [0..m] and jg in [0..n] */
275 /* coordinates of the template that "owns" the element */
276 vtemp = ig / templateheight;
277 htemp = jg / templatewidth;
278 /* coordinates of the element in the subblock of the (vtemp, htemp)
279 * template */
280 vsubtemp = ig % a->nbrow;
281 hsubtemp = jg % a->nbcol;
282 /* coordinates of the element in the local block of the processor */
283 il = a->nbrow * vtemp + vsubtemp;
284 jl = a->nbcol * htemp + hsubtemp;
285 assert(il < a->lda);
286#ifndef NDEBUG
287 {
288 Int pr, pc, p, q, lp, lq;
289 Cblacs_gridinfo(a->ctxt, &p, &q, &pr, &pc);
290 p = templateheight / a->nbrow;
291 q = templatewidth / a->nbcol;
292 lp = ig % templateheight / a->nbrow;
293 lq = jg % templatewidth / a->nbcol;
294 assert(lp == SHIFT(pr, a->sprow, p));
295 assert(lq == SHIFT(pc, a->spcol, q));
296 }
297#endif
298 return (jl * a->lda + il);
299}
n
Int spcol
Definition pcgemr.c:171
Int nbcol
Definition pcgemr.c:169
Int sprow
Definition pcgemr.c:170
Int nbrow
Definition pcgemr.c:168
Int ctxt
Definition pcgemr.c:165
Int lda
Definition pcgemr.c:172

◆ localsize() [1/2]

Int localsize ( )
extern

◆ localsize() [2/2]

Int localsize ( Int myprow,
Int p,
Int nbrow,
Int m )

Definition at line 145 of file pgemraux.c.

146{
147 Int templateheight, blockheight;
148 templateheight = p * nbrow;
149 if (m % templateheight != 0) { /* not an exact boundary */
150 if ((m % templateheight) > (nbrow * myprow)) { /* processor
151 * (myprow,mypcol) has
152 * some elements in that
153 * incomplete template */
154 if ((m % templateheight) >= (nbrow * (myprow + 1))) { /* processor
155 * (myprow,mypcol)'s
156 * part is complete */
157 blockheight = (m / templateheight) * nbrow + nbrow;
158 } else { /* processor (myprow,mypcol)'s part is not complete */
159 blockheight = (m / templateheight) * nbrow + (m % nbrow);
160 }; /* if ((m%templateheight) > (nbrow*(myprow+1))) */
161 } else { /* processor (myprow,mypcol) has no element in that
162 * incomplete template */
163 blockheight = (m / templateheight) * nbrow;
164 }; /* if ((m%templateheight) > (nbrow*myprow)) */
165 } else { /* exact boundary */
166 blockheight = m / p; /* (m/templateheight) * nbrow */
167 }; /* if (m%templateheight !=0) */
168 return blockheight;
169}

◆ memoryblocksize() [1/2]

Int memoryblocksize ( )
extern

◆ memoryblocksize() [2/2]

Int memoryblocksize ( MDESC * a)

Definition at line 173 of file pgemraux.c.

174{
175 Int myprow, mypcol, p, q;
176 /* Compute the (myprow,mypcol) indices of processor mypnum in P0xQ0 We
177 * assume the row-major ordering of the BLACS */
178 Cblacs_gridinfo(a->ctxt, &p, &q, &myprow, &mypcol);
179 myprow = SHIFT(myprow, a->sprow, p);
180 mypcol = SHIFT(mypcol, a->spcol, q);
181 assert(myprow >= 0 && mypcol >= 0);
182 return localsize(myprow, p, a->nbrow, a->m) *
183 localsize(mypcol, q, a->nbcol, a->n);
184}
Int localsize()
Int m
Definition pcgemr.c:166
Int n
Definition pcgemr.c:167

◆ mr2d_malloc() [1/2]

void * mr2d_malloc ( )
extern

◆ mr2d_malloc() [2/2]

void * mr2d_malloc ( Int n)

Definition at line 108 of file pgemraux.c.

109{
110 void *ptr;
111 assert(n > 0);
112 ptr = (void *) malloc(n);
113 if (ptr == NULL) {
114 fprintf(stderr, "xxmr2d:out of memory\n");
115 exit(2);
116 }
117 return ptr;
118}

◆ paramcheck() [1/2]

void paramcheck ( )
extern

◆ paramcheck() [2/2]

void paramcheck ( MDESC * a,
Int i,
Int j,
Int m,
Int n,
Int p,
Int q,
Int gcontext )

Definition at line 204 of file pgemraux.c.

205{
206 Int p2, q2, myprow, mypcol;
207#ifndef NDEBUG
208 checkequal(gcontext, p);
209 checkequal(gcontext, q);
210 checkequal(gcontext, a->sprow);
211 checkequal(gcontext, a->spcol);
212 checkequal(gcontext, a->m);
213 checkequal(gcontext, a->n);
214 checkequal(gcontext, i);
215 checkequal(gcontext, j);
216 checkequal(gcontext, a->nbrow);
217 checkequal(gcontext, a->nbcol);
218#endif
219 Cblacs_gridinfo(a->ctxt, &p2, &q2, &myprow, &mypcol);
220 /* compatibility T3D, must check myprow and mypcol are within bounds */
221 if (myprow >= p2 || mypcol >= q2)
222 myprow = mypcol = -1;
223 if ((myprow >= 0 || mypcol >= 0) && (p2 != p && q2 != q)) {
224 fprintf(stderr, "??MR2D:incoherent p,q parameters\n");
225 exit(1);
226 }
227 assert(myprow < p && mypcol < q);
228 if (a->sprow < 0 || a->sprow >= p || a->spcol < 0 || a->spcol >= q) {
229 fprintf(stderr, "??MR2D:Bad first processor coordinates\n");
230 exit(1);
231 }
232 if (i < 0 || j < 0 || i + m > a->m || j + n > a->n) {
233 fprintf(stderr, "??MR2D:Bad submatrix:i=%d,j=%d,\
234m=%d,n=%d,M=%d,N=%d\n",
235 i, j, m, n, a->m, a->n);
236 exit(1);
237 }
238 if ((myprow >= 0 || mypcol >= 0) &&
239 localsize(SHIFT(myprow, a->sprow, p), p, a->nbrow, a->m) > a->lda) {
240 fprintf(stderr, "??MR2D:bad lda arg:row=%d,m=%d,p=%d,\
241nbrow=%d,lda=%d,sprow=%d\n",
242 myprow, a->m, p, a->nbrow, a->lda, a->sprow);
243 exit(1);
244 }
245}
void checkequal(Int ctxt, Int a)
Definition pgemraux.c:186

◆ pgcd()

Int pgcd ( Int a,
Int b )

Definition at line 120 of file pgemraux.c.

121{
122 Int aux;
123 if (a < b)
124 return pgcd(b, a);
125 else {
126 aux = a % b;
127 if (aux == 0)
128 return b;
129 else
130 return pgcd(b, aux);
131 }
132}
Int pgcd(Int a, Int b)
Definition pgemraux.c:120

◆ ppcm() [1/2]

Int ppcm ( )
extern

◆ ppcm() [2/2]

Int ppcm ( Int a,
Int b )

Definition at line 134 of file pgemraux.c.

135{
136 Int pg;
137 pg = pgcd(a, b);
138 return a * (b / pg);
139}