OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
reshape.c File Reference
#include <stdlib.h>

Go to the source code of this file.

Macros

#define Int   int

Functions

void Creshape (Int context_in, Int major_in, Int *context_out, Int major_out, Int first_proc, Int nprow_new, Int npcol_new)
void reshape (Int *context_in, Int *major_in, Int *context_out, Int *major_out, Int *first_proc, Int *nprow_new, Int *npcol_new)
void RESHAPE (Int *context_in, Int *major_in, Int *context_out, Int *major_out, Int *first_proc, Int *nprow_new, Int *npcol_new)
void reshape_ (Int *context_in, Int *major_in, Int *context_out, Int *major_out, Int *first_proc, Int *nprow_new, Int *npcol_new)
void proc_inc (Int *myrow, Int *mycol, Int nprow, Int npcol, Int major)

Macro Definition Documentation

◆ Int

#define Int   int

Definition at line 4 of file reshape.c.

Function Documentation

◆ 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}
#define Int
Definition Bconfig.h:22
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

◆ proc_inc()

void proc_inc ( Int * myrow,
Int * mycol,
Int nprow,
Int npcol,
Int major )

Definition at line 101 of file reshape.c.

102{
103 if( major == 1) /* row major */
104 {
105 if( *mycol == npcol-1 )
106 {
107 *mycol = 0;
108 if( *myrow == nprow-1 )
109 {
110 *myrow = 0;
111 }
112 else
113 {
114 *myrow = *myrow + 1;
115 }
116 }
117 else
118 {
119 *mycol = *mycol + 1;
120 }
121 }
122 else /* col major */
123 {
124 if( *myrow == nprow-1 )
125 {
126 *myrow = 0;
127 if( *mycol == npcol-1 )
128 {
129 *mycol = 0;
130 }
131 else
132 {
133 *mycol = *mycol + 1;
134 }
135 }
136 else
137 {
138 *myrow = *myrow + 1;
139 }
140 }
141}

◆ RESHAPE()

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

Definition at line 87 of file reshape.c.

89{
90 Creshape( *context_in, *major_in, context_out, *major_out,
91 *first_proc, *nprow_new, *npcol_new );
92}
void Creshape(Int context_in, Int major_in, Int *context_out, Int major_out, Int first_proc, Int nprow_new, Int npcol_new)
Definition reshape.c:7

◆ reshape()

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

Definition at line 80 of file reshape.c.

82{
83 Creshape( *context_in, *major_in, context_out, *major_out,
84 *first_proc, *nprow_new, *npcol_new );
85}

◆ reshape_()

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

Definition at line 94 of file reshape.c.

96{
97 Creshape( *context_in, *major_in, context_out, *major_out,
98 *first_proc, *nprow_new, *npcol_new );
99}