OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pstrmr.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   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
#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 Csgesd2d ()
void Csgerv2d ()
Int localindice ()
void * mr2d_malloc ()
Int ppcm ()
Int localsize ()
Int memoryblocksize ()
Int changeorigin ()
void paramcheck ()
void Cpstrmr2do ()
void Cpstrmr2d ()
void fortran_mr2d (char *uplo, char *diag, Int *m, Int *n, float *A, Int *ia, Int *ja, Int desc_A[DESCLEN], float *B, Int *ib, Int *jb, Int desc_B[DESCLEN])
void fortran_mr2dnew (char *uplo, char *diag, Int *m, Int *n, float *A, Int *ia, Int *ja, Int desc_A[DESCLEN], float *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 Cpstrmr2do (char *uplo, char *diag, Int m, Int n, float *ptrmyblock, Int ia, Int ja, MDESC *ma, float *ptrmynewblock, Int ib, Int jb, MDESC *mb)
void Cpstrmr2d (char *uplo, char *diag, Int m, Int n, float *ptrmyblock, Int ia, Int ja, MDESC *ma, float *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, float *a, Int lda, float *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 pstrmr.c.

◆ Clacpy

#define Clacpy   Cstrlacpy

Definition at line 173 of file pstrmr.c.

◆ DESCLEN

#define DESCLEN   9

Definition at line 257 of file pstrmr.c.

◆ dispmat

#define dispmat   strdispmat

Definition at line 233 of file pstrmr.c.

◆ DIVUP

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

Definition at line 194 of file pstrmr.c.

◆ fortran_mr2d

#define fortran_mr2d   pstrmr2do

Definition at line 168 of file pstrmr.c.

◆ fortran_mr2dnew

#define fortran_mr2dnew   pstrmr2d

Definition at line 169 of file pstrmr.c.

◆ freememory

#define freememory   strfreememory

Definition at line 235 of file pstrmr.c.

◆ MAGIC_MAX

#define MAGIC_MAX   100000000

Definition at line 302 of file pstrmr.c.

◆ max

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

Definition at line 192 of file pstrmr.c.

◆ min

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

Definition at line 193 of file pstrmr.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 pstrmr.c.

◆ NDEBUG

#define NDEBUG

Definition at line 252 of file pstrmr.c.

◆ RECVBUFF

#define RECVBUFF   1

Definition at line 246 of file pstrmr.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 pstrmr.c.

◆ scan_intervals

#define scan_intervals   strscan_intervals

Definition at line 236 of file pstrmr.c.

◆ scanD0

#define scanD0   strscanD0

Definition at line 232 of file pstrmr.c.

◆ scopy_

#define scopy_   scopy

Definition at line 170 of file pstrmr.c.

◆ SENDBUFF

#define SENDBUFF   0

Definition at line 245 of file pstrmr.c.

◆ setmemory

#define setmemory   strsetmemory

Definition at line 234 of file pstrmr.c.

◆ SHIFT

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

Definition at line 191 of file pstrmr.c.

◆ SIZEBUFF

#define SIZEBUFF   2

Definition at line 247 of file pstrmr.c.

◆ slacpy_

#define slacpy_   slacpy

Definition at line 171 of file pstrmr.c.

◆ static2

#define static2   static

Id
pstrmr.c,v 1.1.1.1 2000/02/15 18:04:09 susan Exp

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

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

$ CTXT)

Purpose

PSTRMR2D 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) REAL 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) REAL 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 pstrmr.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,
float * a,
Int lda,
float * b,
Int ldb )

Definition at line 634 of file pstrmr.c.

636{
637 Int i, j;
638 lda -= m;
639 ldb -= m;
640 assert(lda >= 0 && ldb >= 0);
641 for (j = 0; j < n; j++) {
642 for (i = 0; i < m; i++)
643 *b++ = *a++;
644 b += ldb;
645 a += lda;
646 }
#define Int
Definition Bconfig.h:22
n

◆ Cpstrmr2d() [1/2]

void Cpstrmr2d ( )
extern

◆ Cpstrmr2d() [2/2]

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

Definition at line 304 of file pstrmr.c.

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

◆ Cpstrmr2do() [1/2]

void Cpstrmr2do ( )
extern

◆ Cpstrmr2do() [2/2]

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

Definition at line 280 of file pstrmr.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 Cpstrmr2d(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 Cblacs_gridinit()
void Cpstrmr2d()

◆ Csetpvmtids()

void Csetpvmtids ( )
extern

◆ Csgerv2d()

void Csgerv2d ( )
extern

◆ Csgesd2d()

void Csgesd2d ( )
extern

◆ fortran_mr2d()

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

Definition at line 259 of file pstrmr.c.

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

◆ fortran_mr2dnew()

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

Definition at line 267 of file pstrmr.c.

269{
270 Cpstrmr2d(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 648 of file pstrmr.c.

650{
651 Int ori, final; /* original context, and new context created, with
652 * line form */
653 Int nprow, npcol, myrow, mycol;
654 Int *usermap;
655 Int i, j;
656 ori = *ctxtp;
657 Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
658 usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
659 for (i = 0; i < nprow; i++)
660 for (j = 0; j < npcol; j++) {
661 usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
662 }
663 /* Cblacs_get(0, 0, &final); */
664 Cblacs_get(ori, (Int)10, &final);
665 Cblacs_gridmap(&final, usermap, (Int)1, (Int)1, nprow * npcol);
666 *ctxtp = final;
667 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 580 of file pstrmr.c.

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

◆ 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