SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ Creshape()

void Creshape ( Int  context_in,
Int  major_in,
Int context_out,
Int  major_out,
Int  first_proc,
Int  nprow_new,
Int  npcol_new 
)

called subprograms

variables

Definition at line 7 of file reshape.c.

11{
12
14 void proc_inc();
15 void Cblacs_gridinfo();
17 void Cblacs_get();
18 void Cblacs_gridmap();
19
21 Int i, j;
22 Int nprow_in, npcol_in, myrow_in, mycol_in;
23 Int nprocs_new;
24 Int myrow_old, mycol_old, myrow_new, mycol_new;
25 Int pnum;
26 Int *grid_new;
27
28/********** executable statements ************/
29
30 nprocs_new = nprow_new * npcol_new;
31
32 Cblacs_gridinfo( context_in, &nprow_in, &npcol_in, &myrow_in, &mycol_in );
33
34 /* Quick return if possible */
35 if( ( nprow_in == nprow_new ) && ( npcol_in == npcol_new ) &&
36 ( first_proc == 0 ) && ( major_in == major_out ) )
37 {
38 *context_out = context_in;
39 return;
40 }
41
42 /* allocate space for new process mapping */
43 grid_new = (Int *) malloc( nprocs_new * sizeof( Int ) );
44
45 /* set place in old grid to start grabbing processors for new grid */
46 myrow_old = 0; mycol_old = 0;
47 if ( major_in == 1 ) /* row major */
48 {
49 myrow_old = first_proc / nprow_in;
50 mycol_old = first_proc % nprow_in;
51 }
52 else /* col major */
53 {
54 myrow_old = first_proc % nprow_in;
55 mycol_old = first_proc / nprow_in;
56 }
57
58 myrow_new = 0; mycol_new = 0;
59
60 /* Set up array of process numbers for new grid */
61 for (i=0; i< nprocs_new; i++ )
62 {
63 pnum = Cblacs_pnum( context_in, myrow_old, mycol_old );
64 grid_new[ (mycol_new * nprow_new) + myrow_new ] = pnum;
65 proc_inc( &myrow_old, &mycol_old, nprow_in, npcol_in, major_in );
66 proc_inc( &myrow_new, &mycol_new, nprow_new, npcol_new, major_out );
67 }
68
69 /* get context */
70 Cblacs_get( context_in, 10, context_out );
71
72 /* allocate grid */
73 Cblacs_gridmap( context_out, grid_new, nprow_new, nprow_new, npcol_new );
74
75 /* free malloced space */
76 free( grid_new );
77}
void Cblacs_gridmap()
Int Cblacs_pnum()
void Cblacs_get()
void Cblacs_gridinfo()
void proc_inc(Int *myrow, Int *mycol, Int nprow, Int npcol, Int major)
Definition reshape.c:101
#define Int
Definition reshape.c:4
Here is the call graph for this function:
Here is the caller graph for this function: