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

Macros

#define static2   static
#define fortran_mr2d   pztrmr2do
#define fortran_mr2dnew   pztrmr2d
#define zcopy_   zcopy
#define zlacpy_   zlacpy
#define Clacpy   Cztrlacpy
#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   ztrscanD0
#define dispmat   ztrdispmat
#define setmemory   ztrsetmemory
#define freememory   ztrfreememory
#define scan_intervals   ztrscan_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 ()
void Czgesd2d ()
void Czgerv2d ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
void Cpztrmr2do ()
void Cpztrmr2d ()
void fortran_mr2d (char *uplo, char *diag, Int *m, Int *n, dcomplex *A, Int *ia, Int *ja, Int desc_A[DESCLEN], dcomplex *B, Int *ib, Int *jb, Int desc_B[DESCLEN])
void fortran_mr2dnew (char *uplo, char *diag, Int *m, Int *n, dcomplex *A, Int *ia, Int *ja, Int desc_A[DESCLEN], dcomplex *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 Cpztrmr2do (char *uplo, char *diag, Int m, Int n, dcomplex *ptrmyblock, Int ia, Int ja, MDESC *ma, dcomplex *ptrmynewblock, Int ib, Int jb, MDESC *mb)
void Cpztrmr2d (char *uplo, char *diag, Int m, Int n, dcomplex *ptrmyblock, Int ia, Int ja, MDESC *ma, dcomplex *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, dcomplex *a, Int lda, dcomplex *b, Int ldb)
static2 void gridreshape (Int *ctxtp)

Macro Definition Documentation

◆ BLOCK_CYCLIC_2D

#define BLOCK_CYCLIC_2D   1

Definition at line 189 of file pztrmr.c.

◆ Clacpy

#define Clacpy   Cztrlacpy

Definition at line 173 of file pztrmr.c.

◆ DESCLEN

#define DESCLEN   9

Definition at line 260 of file pztrmr.c.

◆ dispmat

#define dispmat   ztrdispmat

Definition at line 236 of file pztrmr.c.

◆ DIVUP

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

Definition at line 197 of file pztrmr.c.

◆ fortran_mr2d

#define fortran_mr2d   pztrmr2do

Definition at line 168 of file pztrmr.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pztrmr2d

Definition at line 169 of file pztrmr.c.

◆ freememory

#define freememory   ztrfreememory

Definition at line 238 of file pztrmr.c.

◆ MAGIC_MAX

#define MAGIC_MAX   100000000

Definition at line 305 of file pztrmr.c.

◆ max

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

Definition at line 195 of file pztrmr.c.

◆ min

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

Definition at line 196 of file pztrmr.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 304 of file pztrmr.c.

◆ NDEBUG

#define NDEBUG

Definition at line 255 of file pztrmr.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 249 of file pztrmr.c.

◆ ROUNDUP

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

Definition at line 198 of file pztrmr.c.

◆ scan_intervals

#define scan_intervals   ztrscan_intervals

Definition at line 239 of file pztrmr.c.

◆ scanD0

#define scanD0   ztrscanD0

Definition at line 235 of file pztrmr.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 248 of file pztrmr.c.

◆ setmemory

#define setmemory   ztrsetmemory

Definition at line 237 of file pztrmr.c.

◆ SHIFT

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

Definition at line 194 of file pztrmr.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 250 of file pztrmr.c.

◆ static2

#define static2   static

Id
pztrmr.c,v 1.1.1.1 2000/02/15 18:04:10 susan Exp

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

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

$ CTXT)

Purpose

PZTRMR2D 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) COMPLEX*16 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) COMPLEX*16 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 pztrmr.c.

◆ zcopy_

#define zcopy_   zcopy

Definition at line 170 of file pztrmr.c.

◆ zlacpy_

#define zlacpy_   zlacpy

Definition at line 171 of file pztrmr.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,
dcomplex * a,
Int lda,
dcomplex * b,
Int ldb )

Definition at line 643 of file pztrmr.c.

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

◆ Cpztrmr2d() [1/2]

void Cpztrmr2d ( )
extern

◆ Cpztrmr2d() [2/2]

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

Definition at line 307 of file pztrmr.c.

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

◆ Cpztrmr2do() [1/2]

void Cpztrmr2do ( )
extern

◆ Cpztrmr2do() [2/2]

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

Definition at line 283 of file pztrmr.c.

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

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ Czgerv2d()

void Czgerv2d ( )
extern

◆ Czgesd2d()

void Czgesd2d ( )
extern

◆ fortran_mr2d()

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

Definition at line 262 of file pztrmr.c.

264{
265 Cpztrmr2do(uplo, diag, *m, *n, A, *ia, *ja, (MDESC *) desc_A,
266 B, *ib, *jb, (MDESC *) desc_B);
267 return;
268}
void Cpztrmr2do()

◆ fortran_mr2dnew()

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

Definition at line 270 of file pztrmr.c.

272{
273 Cpztrmr2d(uplo, diag, *m, *n, A, *ia, *ja, (MDESC *) desc_A,
274 B, *ib, *jb, (MDESC *) desc_B, *gcontext);
275 return;
276}

◆ gridreshape() [1/2]

static2 void gridreshape ( )

◆ gridreshape() [2/2]

static2 void gridreshape ( Int * ctxtp)

Definition at line 657 of file pztrmr.c.

659{
660 Int ori, final; /* original context, and new context created, with
661 * line form */
662 Int nprow, npcol, myrow, mycol;
663 Int *usermap;
664 Int i, j;
665 ori = *ctxtp;
666 Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
667 usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
668 for (i = 0; i < nprow; i++)
669 for (j = 0; j < npcol; j++) {
670 usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
671 }
672 /* Cblacs_get(0, 0, &final); */
673 Cblacs_get(ori, (Int)10, &final);
674 Cblacs_gridmap(&final, usermap, (Int)1, (Int)1, nprow * npcol);
675 *ctxtp = final;
676 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 589 of file pztrmr.c.

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

◆ 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