OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pitrmr.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   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
#define DESCLEN   9
#define NBPARAM
#define MAGIC_MAX   100000000

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 fortran_mr2d (char *uplo, char *diag, Int *m, Int *n, Int *A, Int *ia, Int *ja, Int desc_A[DESCLEN], Int *B, Int *ib, Int *jb, Int desc_B[DESCLEN])
void fortran_mr2dnew (char *uplo, char *diag, Int *m, Int *n, Int *A, Int *ia, Int *ja, Int desc_A[DESCLEN], Int *B, Int *ib, Int *jb, Int desc_B[DESCLEN], Int *gcontext)
static2 void init_chenille ()
static2 Int inter_len ()
static2 Int block2buff ()
static2 void buff2block ()
static2 void gridreshape ()
void Cpitrmr2do (char *uplo, char *diag, Int m, Int n, Int *ptrmyblock, Int ia, Int ja, MDESC *ma, Int *ptrmynewblock, Int ib, Int jb, MDESC *mb)
void Cpitrmr2d (char *uplo, char *diag, Int m, Int n, Int *ptrmyblock, Int ia, Int ja, MDESC *ma, Int *ptrmynewblock, Int ib, Int jb, MDESC *mb, Int globcontext)
static2 void init_chenille (Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, Int **psend, Int **precv, Int *myrang)
void Clacpy (Int m, Int n, Int *a, Int lda, Int *b, Int ldb)
static2 void gridreshape (Int *ctxtp)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 186 of file pitrmr.c.

◆ Clacpy

#define Clacpy   Citrlacpy

Definition at line 173 of file pitrmr.c.

◆ DESCLEN

#define DESCLEN   9

Definition at line 257 of file pitrmr.c.

◆ dispmat

#define dispmat   itrdispmat

Definition at line 233 of file pitrmr.c.

◆ DIVUP

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

Definition at line 194 of file pitrmr.c.

◆ fortran_mr2d

#define fortran_mr2d   pitrmr2do

Definition at line 168 of file pitrmr.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pitrmr2d

Definition at line 169 of file pitrmr.c.

◆ freememory

#define freememory   itrfreememory

Definition at line 235 of file pitrmr.c.

◆ icopy_

#define icopy_   icopy

Definition at line 170 of file pitrmr.c.

◆ ilacpy_

#define ilacpy_   ilacpy

Definition at line 171 of file pitrmr.c.

◆ MAGIC_MAX

#define MAGIC_MAX   100000000

Definition at line 302 of file pitrmr.c.

◆ max

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

Definition at line 192 of file pitrmr.c.

◆ min

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

Definition at line 193 of file pitrmr.c.

◆ NBPARAM

#define NBPARAM
Value:
20 /* p0,q0,p1,q1, puis ma,na,mba,nba,rowa,cola puis
* idem B puis ia,ja puis ib,jb */

Definition at line 301 of file pitrmr.c.

◆ NDEBUG

#define NDEBUG

Definition at line 252 of file pitrmr.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 246 of file pitrmr.c.

◆ ROUNDUP

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

Definition at line 195 of file pitrmr.c.

◆ scan_intervals

#define scan_intervals   itrscan_intervals

Definition at line 236 of file pitrmr.c.

◆ scanD0

#define scanD0   itrscanD0

Definition at line 232 of file pitrmr.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 245 of file pitrmr.c.

◆ setmemory

#define setmemory   itrsetmemory

Definition at line 234 of file pitrmr.c.

◆ SHIFT

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

Definition at line 191 of file pitrmr.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 247 of file pitrmr.c.

◆ static2

#define static2   static

Id
pitrmr.c,v 1.1.1.1 2000/02/15 18:04:08 susan Exp

– ScaLAPACK routine (version 1.7) – Oak Ridge National Laboratory, Univ. of Tennessee, and Univ. of California, Berkeley. October 31, 1994.

SUBROUTINE PITRMR2D(UPLO, DIAG, M, N, $ A, IA, JA, ADESC, $ B, IB, JB, BDESC,

$ CTXT)

Purpose

PITRMR2D copies a submatrix of A on a submatrix of B. A and B can have different distributions: they can be on different processor grids, they can have different blocksizes, the beginning of the area to be copied can be at a different places on A and B.

The parameters can be confusing when the grids of A and B are partially or completly disjoint, in the case a processor calls this routines but is either not in the A context or B context, the ADESC[CTXT] or BDESC[CTXT] must be equal to -1, to ensure the routine recognise this situation. To summarize the rule:

  • If a processor is in A context, all parameters related to A must be valid.
  • If a processor is in B context, all parameters related to B must be valid.
  • ADESC[CTXT] and BDESC[CTXT] must be either valid contexts or equal to -1.
  • M and N must be valid for everyone.
  • other parameters are not examined.

The submatrix to be copied is assumed to be trapezoidal. So only the upper or the lower part will be copied. The other part is unchanged.

Notes

A description vector is associated with each 2D block-cyclicly dis- tributed matrix. This vector stores the information required to establish the mapping between a matrix entry and its corresponding process and memory location.

In the following comments, the character _ should be read as "of the distributed matrix". Let A be a generic term for any 2D block cyclicly distributed matrix. Its description vector is DESC_A:

NOTATION STORED IN EXPLANATION


DT_A (global) DESCA( DT_ ) The descriptor type. CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating the BLACS process grid A is distribu- ted over. The context itself is glo- bal, but the handle (the integer value) may vary. M_A (global) DESCA( M_ ) The number of rows in the distributed matrix A. N_A (global) DESCA( N_ ) The number of columns in the distri- buted matrix A. MB_A (global) DESCA( MB_ ) The blocking factor used to distribute the rows of A. NB_A (global) DESCA( NB_ ) The blocking factor used to distribute the columns of A. RSRC_A (global) DESCA( RSRC_ ) The process row over which the first row of the matrix A is distributed. CSRC_A (global) DESCA( CSRC_ ) The process column over which the first column of A is distributed. LLD_A (local) DESCA( LLD_ ) The leading dimension of the local array storing the local blocks of the distributed matrix A. LLD_A >= MAX(1,LOCp(M_A)).

Important notice

The parameters of the routine have changed in April 1996 There is a new last argument. It must be a context englobing all processors involved in the initial and final distribution.

Be aware that all processors included in this context must call the redistribution routine.

Parameters

UPLO (input) CHARACTER*1. On entry, UPLO specifies whether we should copy the upper part of the lower part of the defined submatrix: UPLO = 'U' or 'u' copy the upper triangular part. UPLO = 'L' or 'l' copy the lower triangular part. Unchanged on exit.

DIAG (input) CHARACTER*1. On entry, DIAG specifies whether we should copy the diagonal. DIAG = 'U' or 'u' do NOT copy the diagonal of the submatrix. DIAG = 'N' or 'n' DO copy the diagonal of the submatrix. Unchanged on exit.

M (input) INTEGER. On entry, M specifies the number of rows of the submatrix to be copied. M must be at least zero. Unchanged on exit.

N (input) INTEGER. On entry, N specifies the number of cols of the submatrix to be redistributed.rows of B. M must be at least zero. Unchanged on exit.

A (input) INTEGER On entry, the source matrix. Unchanged on exit.

IA,JA (input) INTEGER On entry,the coordinates of the beginning of the submatrix of A to copy. 1 <= IA <= M_A - M + 1,1 <= JA <= N_A - N + 1, Unchanged on exit.

ADESC (input) A description vector (see Notes above) If the current processor is not part of the context of A the ADESC[CTXT] must be equal to -1.

B (output) INTEGER On entry, the destination matrix. The portion corresponding to the defined submatrix are updated.

IB,JB (input) INTEGER On entry,the coordinates of the beginning of the submatrix of B that will be updated. 1 <= IB <= M_B - M + 1,1 <= JB <= N_B - N + 1, Unchanged on exit.

BDESC (input) B description vector (see Notes above) For processors not part of the context of B BDESC[CTXT] must be equal to -1.

CTXT (input) a context englobing at least all processors included in either A context or B context

Memory requirement :

for the processors belonging to grid 0, one buffer of size block 0 and for the processors belonging to grid 1, also one buffer of size block 1.


Created March 1993 by B. Tourancheau (See sccs for modifications).

Modifications by Loic PRYLLI 1995

Definition at line 158 of file pitrmr.c.

Function Documentation

◆ block2buff()

static2 Int block2buff ( )

◆ buff2block()

static2 void buff2block ( )

◆ 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

◆ Clacpy()

void Clacpy ( Int m,
Int n,
Int * a,
Int lda,
Int * b,
Int ldb )

Definition at line 640 of file pitrmr.c.

642{
643 Int i, j;
644 lda -= m;
645 ldb -= m;
646 assert(lda >= 0 && ldb >= 0);
647 for (j = 0; j < n; j++) {
648 for (i = 0; i < m; i++)
649 *b++ = *a++;
650 b += ldb;
651 a += lda;
652 }
#define Int
Definition Bconfig.h:22
n

◆ Cpitrmr2d() [1/2]

void Cpitrmr2d ( )
extern

◆ Cpitrmr2d() [2/2]

void Cpitrmr2d ( char * uplo,
char * diag,
Int m,
Int n,
Int * ptrmyblock,
Int ia,
Int ja,
MDESC * ma,
Int * ptrmynewblock,
Int ib,
Int jb,
MDESC * mb,
Int globcontext )

Definition at line 304 of file pitrmr.c.

314{
315 Int *ptrsendbuff, *ptrrecvbuff, *ptrNULL = 0;
316 Int *recvptr;
317 MDESC newa, newb;
318 Int *proc0, *proc1, *param;
319 Int mypnum, myprow0, mypcol0, myprow1, mypcol1, nprocs;
320 Int i, j;
321 Int nprow, npcol, gcontext;
322 Int recvsize, sendsize;
323 IDESC *h_inter; /* to store the horizontal intersections */
324 IDESC *v_inter; /* to store the vertical intersections */
325 Int hinter_nb, vinter_nb; /* number of intrsections in both directions */
326 Int dummy;
327 Int p0, q0, p1, q1;
328 Int *ra, *ca;
329 /* end of variables */
330 /* To simplify further calcul we change the matrix indexation from
331 * 1..m,1..n (fortran) to 0..m-1,0..n-1 */
332 if (m == 0 || n == 0)
333 return;
334 ia -= 1;
335 ja -= 1;
336 ib -= 1;
337 jb -= 1;
338 Cblacs_gridinfo(globcontext, &nprow, &npcol, &dummy, &mypnum);
339 gcontext = globcontext;
340 nprocs = nprow * npcol;
341 /* if the global context that is given to us has not the shape of a line
342 * (nprow != 1), create a new context. TODO: to be optimal, we should
343 * avoid this because it is an uncessary synchronisation */
344 if (nprow != 1) {
345 gridreshape(&gcontext);
346 Cblacs_gridinfo(gcontext, &dummy, &dummy, &dummy, &mypnum);
347 }
348 Cblacs_gridinfo(ma->ctxt, &p0, &q0, &myprow0, &mypcol0);
349 /* compatibility T3D, must check myprow and mypcol are within bounds */
350 if (myprow0 >= p0 || mypcol0 >= q0)
351 myprow0 = mypcol0 = -1;
352 assert((myprow0 < p0 && mypcol0 < q0) || (myprow0 == -1 && mypcol0 == -1));
353 Cblacs_gridinfo(mb->ctxt, &p1, &q1, &myprow1, &mypcol1);
354 if (myprow1 >= p1 || mypcol1 >= q1)
355 myprow1 = mypcol1 = -1;
356 assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
357 /* exchange the missing parameters among the processors: shape of grids and
358 * location of the processors */
359 param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
360 ra = param + nprocs * 2 + NBPARAM;
361 ca = param + (nprocs * 2 + NBPARAM) * 2;
362 for (i = 0; i < nprocs * 2 + NBPARAM; i++)
363 param[i] = MAGIC_MAX;
364 proc0 = param + NBPARAM;
365 proc1 = param + NBPARAM + nprocs;
366 /* we calulate proc0 and proc1 that will give the number of a proc in
367 * respectively a or b in the global context */
368 if (myprow0 >= 0) {
369 proc0[myprow0 * q0 + mypcol0] = mypnum;
370 param[0] = p0;
371 param[1] = q0;
372 param[4] = ma->m;
373 param[5] = ma->n;
374 param[6] = ma->nbrow;
375 param[7] = ma->nbcol;
376 param[8] = ma->sprow;
377 param[9] = ma->spcol;
378 param[10] = ia;
379 param[11] = ja;
380 }
381 if (myprow1 >= 0) {
382 proc1[myprow1 * q1 + mypcol1] = mypnum;
383 param[2] = p1;
384 param[3] = q1;
385 param[12] = mb->m;
386 param[13] = mb->n;
387 param[14] = mb->nbrow;
388 param[15] = mb->nbcol;
389 param[16] = mb->sprow;
390 param[17] = mb->spcol;
391 param[18] = ib;
392 param[19] = jb;
393 }
394 Cigamn2d(gcontext, "All", "H", 2 * nprocs + NBPARAM, (Int)1, param, 2 * nprocs + NBPARAM,
395 ra, ca, 2 * nprocs + NBPARAM, (Int)-1, (Int)-1);
396 newa = *ma;
397 newb = *mb;
398 ma = &newa;
399 mb = &newb;
400 if (myprow0 == -1) {
401 p0 = param[0];
402 q0 = param[1];
403 ma->m = param[4];
404 ma->n = param[5];
405 ma->nbrow = param[6];
406 ma->nbcol = param[7];
407 ma->sprow = param[8];
408 ma->spcol = param[9];
409 ia = param[10];
410 ja = param[11];
411 }
412 if (myprow1 == -1) {
413 p1 = param[2];
414 q1 = param[3];
415 mb->m = param[12];
416 mb->n = param[13];
417 mb->nbrow = param[14];
418 mb->nbcol = param[15];
419 mb->sprow = param[16];
420 mb->spcol = param[17];
421 ib = param[18];
422 jb = param[19];
423 }
424 for (i = 0; i < NBPARAM; i++) {
425 if (param[i] == MAGIC_MAX) {
426 fprintf(stderr, "xxGEMR2D:something wrong in the parameters\n");
427 exit(1);
428 }
429 }
430#ifndef NDEBUG
431 for (i = 0; i < p0 * q0; i++)
432 assert(proc0[i] >= 0 && proc0[i] < nprocs);
433 for (i = 0; i < p1 * q1; i++)
434 assert(proc1[i] >= 0 && proc1[i] < nprocs);
435#endif
436 /* check the validity of the parameters */
437 paramcheck(ma, ia, ja, m, n, p0, q0, gcontext);
438 paramcheck(mb, ib, jb, m, n, p1, q1, gcontext);
439 /* we change the problem so that ia < a->nbrow ... andia + m = a->m ... */
440 {
441 Int decal;
442 ia = changeorigin(myprow0, ma->sprow, p0,
443 ma->nbrow, ia, &decal, &ma->sprow);
444 ptrmyblock += decal;
445 ja = changeorigin(mypcol0, ma->spcol, q0,
446 ma->nbcol, ja, &decal, &ma->spcol);
447 ptrmyblock += decal * ma->lda;
448 ma->m = ia + m;
449 ma->n = ja + n;
450 ib = changeorigin(myprow1, mb->sprow, p1,
451 mb->nbrow, ib, &decal, &mb->sprow);
452 ptrmynewblock += decal;
453 jb = changeorigin(mypcol1, mb->spcol, q1,
454 mb->nbcol, jb, &decal, &mb->spcol);
455 ptrmynewblock += decal * mb->lda;
456 mb->m = ib + m;
457 mb->n = jb + n;
458 if (p0 == 1)
459 ma->nbrow = ma->m;
460 if (q0 == 1)
461 ma->nbcol = ma->n;
462 if (p1 == 1)
463 mb->nbrow = mb->m;
464 if (q1 == 1)
465 mb->nbcol = mb->n;
466#ifndef NDEBUG
467 paramcheck(ma, ia, ja, m, n, p0, q0, gcontext);
468 paramcheck(mb, ib, jb, m, n, p1, q1, gcontext);
469#endif
470 }
471 /* We compute the size of the memory buffer ( we choose the worst case,
472 * when the buffer sizes == the memory block sizes). */
473 if (myprow0 >= 0 && mypcol0 >= 0) {
474 /* Initialize pointer variables */
475 setmemory(&ptrsendbuff, memoryblocksize(ma));
476 }; /* if (mypnum < p0 * q0) */
477 if (myprow1 >= 0 && mypcol1 >= 0) {
478 /* Initialize pointer variables */
479 setmemory(&ptrrecvbuff, memoryblocksize(mb));
480 }; /* if (mypnum < p1 * q1) */
481 /* allocing room for the tabs, alloc for the worst case,local_n or local_m
482 * intervals, in fact the worst case should be less, perhaps half that,I
483 * should think of that one day. */
484 h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
485 ma->nbcol * sizeof(IDESC));
486 v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
487 * ma->nbrow * sizeof(IDESC));
488 /* We go for the scanning of indices. For each processor including mypnum,
489 * we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
490 * it. Then for each processor, we compute the size of message to be
491 * receive scanD0(SIZEBUFF)), post a receive and then allocate the elements
492 * of recvbuff the right place (scanD)(RECVBUFF)) */
493 recvptr = ptrrecvbuff;
494 {
495 Int tot, myrang, step, sens;
496 Int *sender, *recver;
497 Int mesending, merecving;
498 tot = max(p0 * q0, p1 * q1);
499 init_chenille(mypnum, nprocs, p0 * q0, proc0, p1 * q1, proc1,
500 &sender, &recver, &myrang);
501 if (myrang == -1)
502 goto after_comm;
503 mesending = myprow0 >= 0;
504 assert(sender[myrang] >= 0 || !mesending);
505 assert(!mesending || proc0[sender[myrang]] == mypnum);
506 merecving = myprow1 >= 0;
507 assert(recver[myrang] >= 0 || !merecving);
508 assert(!merecving || proc1[recver[myrang]] == mypnum);
509 step = tot - 1 - myrang;
510 do {
511 for (sens = 0; sens < 2; sens++) {
512 /* be careful here, when we communicating with ourselves, we must
513 * send first (myrang > step == 0) */
514 if (mesending && recver[step] >= 0 &&
515 (sens == 0)) {
516 i = recver[step] / q1;
517 j = recver[step] % q1;
518 vinter_nb = scan_intervals('r', ia, ib, m, ma, mb, p0, p1, myprow0, i,
519 v_inter);
520 hinter_nb = scan_intervals('c', ja, jb, n, ma, mb, q0, q1, mypcol0, j,
521 h_inter);
522 scanD0(uplo, diag, SENDBUFF, ptrsendbuff, &sendsize,
523 m, n, ma, ia, ja, p0, q0, mb, ib, jb, p1, q1,
524 v_inter, vinter_nb, h_inter, hinter_nb,
525 ptrmyblock);
526 } /* if (mesending...) { */
527 if (mesending && recver[step] >= 0 &&
528 (sens == myrang > step)) {
529 i = recver[step] / q1;
530 j = recver[step] % q1;
531 if (sendsize > 0
532 && (step != myrang || !merecving)
533 ) {
534 Cigesd2d(gcontext, sendsize, (Int)1, ptrsendbuff, sendsize,
535 (Int)0, proc1[i * q1 + j]);
536 } /* sendsize > 0 */
537 } /* if (mesending ... */
538 if (merecving && sender[step] >= 0 &&
539 (sens == myrang <= step)) {
540 i = sender[step] / q0;
541 j = sender[step] % q0;
542 vinter_nb = scan_intervals('r', ib, ia, m, mb, ma, p1, p0, myprow1, i,
543 v_inter);
544 hinter_nb = scan_intervals('c', jb, ja, n, mb, ma, q1, q0, mypcol1, j,
545 h_inter);
546 scanD0(uplo, diag, SIZEBUFF, ptrNULL, &recvsize,
547 m, n, ma, ia, ja, p0, q0, mb, ib, jb, p1, q1,
548 v_inter, vinter_nb, h_inter, hinter_nb, ptrNULL);
549 if (recvsize > 0) {
550 if (step == myrang && mesending) {
551 Clacpy(recvsize, (Int)1,
552 ptrsendbuff, recvsize,
553 ptrrecvbuff, recvsize);
554 } else {
555 Cigerv2d(gcontext, recvsize, (Int)1, ptrrecvbuff, recvsize,
556 (Int)0, proc0[i * q0 + j]);
557 }
558 } /* recvsize > 0 */
559 } /* if (merecving ...) */
560 if (merecving && sender[step] >= 0 && sens == 1) {
561 scanD0(uplo, diag, RECVBUFF, ptrrecvbuff, &recvsize,
562 m, n, ma, ia, ja, p0, q0, mb, ib, jb, p1, q1,
563 v_inter, vinter_nb, h_inter, hinter_nb, ptrmynewblock);
564 } /* if (merecving...) */
565 } /* for (sens = 0) */
566 step -= 1;
567 if (step < 0)
568 step = tot - 1;
569 } while (step != tot - 1 - myrang);
570after_comm:
571 free(sender);
572 } /* { int tot,nr,ns ...} */
573 /* don't forget to clean up things! */
574 if (myprow1 >= 0 && mypcol1 >= 0) {
575 freememory((char *) ptrrecvbuff);
576 };
577 if (myprow0 >= 0 && mypcol0 >= 0) {
578 freememory((char *) ptrsendbuff);
579 };
580 if (nprow != 1)
581 Cblacs_gridexit(gcontext);
582 free(v_inter);
583 free(h_inter);
584 free(param);
integer, save, private nprocs
Definition cmumps_load.F:57
#define SIZEBUFF
Definition pcgemr.c:235
#define NBPARAM
Definition pcgemr.c:288
#define SENDBUFF
Definition pcgemr.c:233
#define RECVBUFF
Definition pcgemr.c:234
#define MAGIC_MAX
Definition pcgemr.c:289
Int memoryblocksize()
Int changeorigin()
#define freememory
Definition pitrmr.c:235
#define scan_intervals
Definition pitrmr.c:236
void Cblacs_gridexit()
#define max(A, B)
Definition pitrmr.c:192
#define scanD0
Definition pitrmr.c:232
static2 void gridreshape()
#define DIVUP(a, b)
Definition pitrmr.c:194
#define Clacpy
Definition pitrmr.c:173
void Cigamn2d()
#define setmemory
Definition pitrmr.c:234
void Cigerv2d()
void paramcheck()
void Cblacs_gridinfo()
void Cigesd2d()
void * mr2d_malloc()
static2 void init_chenille()
Int m
Definition pcgemr.c:166
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 n
Definition pcgemr.c:167
Int lda
Definition pcgemr.c:172

◆ Cpitrmr2do() [1/2]

void Cpitrmr2do ( )
extern

◆ Cpitrmr2do() [2/2]

void Cpitrmr2do ( char * uplo,
char * diag,
Int m,
Int n,
Int * ptrmyblock,
Int ia,
Int ja,
MDESC * ma,
Int * ptrmynewblock,
Int ib,
Int jb,
MDESC * mb )

Definition at line 280 of file pitrmr.c.

289{
290 Int dummy, nprocs;
291 Int gcontext;
292 /* first we initialize a global grid which serve as a reference to
293 * communicate from grid a to grid b */
294 Cblacs_pinfo(&dummy, &nprocs);
295 Cblacs_get((Int)0, (Int)0, &gcontext);
296 Cblacs_gridinit(&gcontext, "R", (Int)1, nprocs);
297 Cpitrmr2d(uplo, diag, m, n, ptrmyblock, ia, ja, ma,
298 ptrmynewblock, ib, jb, mb, gcontext);
299 Cblacs_gridexit(gcontext);
300}
void Cblacs_pinfo()
void Cblacs_get()
void Cpitrmr2d()
void Cblacs_gridinit()

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ fortran_mr2d()

void fortran_mr2d ( char * uplo,
char * diag,
Int * m,
Int * n,
Int * A,
Int * ia,
Int * ja,
Int desc_A[DESCLEN],
Int * B,
Int * ib,
Int * jb,
Int desc_B[DESCLEN] )

Definition at line 259 of file pitrmr.c.

261{
262 Cpitrmr2do(uplo, diag, *m, *n, A, *ia, *ja, (MDESC *) desc_A,
263 B, *ib, *jb, (MDESC *) desc_B);
264 return;
265}
void Cpitrmr2do()

◆ fortran_mr2dnew()

void fortran_mr2dnew ( char * uplo,
char * diag,
Int * m,
Int * n,
Int * A,
Int * ia,
Int * ja,
Int desc_A[DESCLEN],
Int * B,
Int * ib,
Int * jb,
Int desc_B[DESCLEN],
Int * gcontext )

Definition at line 267 of file pitrmr.c.

269{
270 Cpitrmr2d(uplo, diag, *m, *n, A, *ia, *ja, (MDESC *) desc_A,
271 B, *ib, *jb, (MDESC *) desc_B, *gcontext);
272 return;
273}

◆ gridreshape() [1/2]

static2 void gridreshape ( )

◆ gridreshape() [2/2]

static2 void gridreshape ( Int * ctxtp)

Definition at line 654 of file pitrmr.c.

656{
657 Int ori, final; /* original context, and new context created, with
658 * line form */
659 Int nprow, npcol, myrow, mycol;
660 Int *usermap;
661 Int i, j;
662 ori = *ctxtp;
663 Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
664 usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
665 for (i = 0; i < nprow; i++)
666 for (j = 0; j < npcol; j++) {
667 usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
668 }
669 /* Cblacs_get(0, 0, &final); */
670 Cblacs_get(ori, (Int)10, &final);
671 Cblacs_gridmap(&final, usermap, (Int)1, (Int)1, nprow * npcol);
672 *ctxtp = final;
673 free(usermap);
void Cblacs_gridmap()
Int Cblacs_pnum()

◆ init_chenille() [1/2]

static2 void init_chenille ( )

◆ init_chenille() [2/2]

static2 void init_chenille ( Int mypnum,
Int nprocs,
Int n0,
Int * proc0,
Int n1,
Int * proc1,
Int ** psend,
Int ** precv,
Int * myrang )

Definition at line 586 of file pitrmr.c.

588{
589 Int ns, nr, i, tot;
590 Int *sender, *recver, *g0, *g1;
591 tot = max(n0, n1);
592 sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
593 recver = sender + tot;
594 *psend = sender;
595 *precv = recver;
596 g0 = recver + tot;
597 g1 = g0 + nprocs;
598 for (i = 0; i < nprocs; i++) {
599 g0[i] = -1;
600 g1[i] = -1;
601 }
602 for (i = 0; i < tot; i++) {
603 sender[i] = -1;
604 recver[i] = -1;
605 }
606 for (i = 0; i < n0; i++)
607 g0[proc0[i]] = i;
608 for (i = 0; i < n1; i++)
609 g1[proc1[i]] = i;
610 ns = 0;
611 nr = 0;
612 *myrang = -1;
613 for (i = 0; i < nprocs; i++)
614 if (g0[i] >= 0 && g1[i] >= 0) {
615 if (i == mypnum)
616 *myrang = nr;
617 sender[ns] = g0[i];
618 ns += 1;
619 recver[nr] = g1[i];
620 nr += 1;
621 assert(ns <= n0 && nr <= n1 && nr == ns);
622 }
623 for (i = 0; i < nprocs; i++)
624 if (g0[i] >= 0 && g1[i] < 0) {
625 if (i == mypnum)
626 *myrang = ns;
627 sender[ns] = g0[i];
628 ns += 1;
629 assert(ns <= n0);
630 }
631 for (i = 0; i < nprocs; i++)
632 if (g1[i] >= 0 && g0[i] < 0) {
633 if (i == mypnum)
634 *myrang = nr;
635 recver[nr] = g1[i];
636 nr += 1;
637 assert(nr <= n1);
638 }

◆ inter_len()

static2 Int inter_len ( )

◆ 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