OpenAtom  Version1.5a
TopoMap.C
Go to the documentation of this file.
1 /** \file TopoMap.C
2  * Author: Abhinav S Bhatele
3  * Date Created: January 04th, 2006
4  * The functions in this file generate a topology sensitive
5  * mapping scheme for the GSpace, PairCalc and RealSpace objects.
6  * and also for the density objects - RhoR, RhoG, RhoGHart.
7  *
8  * Heavily refactored by EJB 2006/5/31 to accelerate map creation
9  *
10  * !!!!!! THIS CODE IS NOW DEFUNCT !!!!!!!
11  * !!!!!! THIS CODE IS NOW DEFUNCT !!!!!!!
12  * !!!!!! THIS CODE IS NOW DEFUNCT !!!!!!!
13 
14  * Look in MapTable.[Ch] for actual maps
15 
16  */
17 
18 #include "charm++.h"
19 #include "main/cpaimd.h"
20 #include "utility/util.h"
21 #include "PeList.h"
22 
23 /**
24  * Function for GSpace objects
25  * Does a hybrid chunking of the GSpace grid. Depending on the
26  * no. of processors and the input parameter, Gstates_per_pe (l),
27  * the other dimension 'm' is decided. And then this chunk of
28  * size l by m is placed on a processor.
29  */
30 
31 int GSMap::procNum(int handle, const CkArrayIndex &iIndex)
32 {
33 #if CMK_TRACE_ENABLED
34  double StartTime=CmiWallTimer();
35 #endif
36 
37  int *index=(int *) iIndex.data();
38 #if 0
39  if(maptable==NULL)
40  {
41  CkPrintf("Warning! GSMap::procnum had to assign maptable on pe %d!\n",CkMyPe());
42 #ifdef USE_INT_MAP
43  maptable= &GSImaptable;
44 #else
45  maptable= &GSmaptable;
46 #endif
47  }
48 #endif
49 
50 #ifdef USE_INT_MAP
51  int retval=maptable->get(index[0],index[1]);
52 #else
53  int retval=maptable->get(intdual(index[0],index[1]));
54 #endif
55 #if CMK_TRACE_ENABLED
56  traceUserBracketEvent(10000, StartTime, CmiWallTimer());
57 #endif
58 
59  return retval;
60 }
61 
62 /** Function for PairCalc objects
63  *
64  */
65 
66 /**
67  *
68  */
69 int SCalcMap::procNum(int handle, const CkArrayIndex &iIndex)
70 {
71 #if CMK_TRACE_ENABLED
72  double StartTime=CmiWallTimer();
73 #endif
74 
75 
76 #if 0
77  /* this works due to 4D being stored as 2 ints */
78  if(maptable==NULL)
79  {
80  CkPrintf("Warning! SCalc::Procnum had to assign maptable on %d !\n",CkMyPe());
81 #ifdef USE_INT_MAP
82  if(symmetric)
83  maptable= &SymScalcImaptable;
84  else
85  maptable= &AsymScalcImaptable;
86 #else
87  if(symmetric)
88  maptable= &SymScalcmaptable;
89  else
90  maptable= &AsymScalcmaptable;
91 #endif
92  }
93 #endif
94 #ifdef USE_INT_MAP
95  short *sindex=(short *) iIndex.data();
96  int retval=maptable->get(sindex[0], sindex[1], sindex[2], sindex[3]);
97 #else
98  int *index=(int *) iIndex.data();
99  int retval=maptable->get(intdual(index[0], index[1]));
100 #endif
101 #if CMK_TRACE_ENABLED
102  traceUserBracketEvent(30000, StartTime, CmiWallTimer());
103 #endif
104  return retval;
105 }
106 
107 /** Function for RealSpace objects
108  *
109  */
110 
111 int RSMap::procNum(int handle, const CkArrayIndex &iIndex)
112 {
113 #if CMK_TRACE_ENABLED
114  double StartTime=CmiWallTimer();
115 #endif
116 
117  int *index=(int *) iIndex.data();
118 #if 0
119  if(maptable==NULL)
120  {
121  CkPrintf("Warning! RSMap::Procnum had to assign maptable on %d!\n",CkMyPe());
122 #ifdef USE_INT_MAP
123  maptable= &RSImaptable;
124 #else
125  maptable= &RSmaptable;
126 #endif
127  }
128 #endif
129 
130 #ifdef USE_INT_MAP
131  int retval=maptable->get(index[0], index[1]);
132 #else
133  int retval=maptable->get(intdual(index[0], index[1]));
134 #endif
135 #if CMK_TRACE_ENABLED
136  traceUserBracketEvent(20000, StartTime, CmiWallTimer());
137 #endif
138 
139  return retval;
140 
141 }
142 
143 int RSPMap::procNum(int handle, const CkArrayIndex &index)
144 {
145  CkArrayIndex2D idx2d = *(CkArrayIndex2D *) &index;
146 
147 #if 0
148  if(maptable==NULL)
149  {
150  CkPrintf("Warning! RSMap::Procnum had to assign maptable on %d!\n",CkMyPe());
151 #ifdef USE_INT_MAP
152  maptable= &RSPImaptable;
153 #else
154  maptable= &RSPmaptable;
155 #endif
156  }
157 #endif
158 
159 #ifdef USE_INT_MAP
160  int retval=maptable->get(idx2d.index[0], idx2d.index[1]);
161 #else
162  int retval=maptable->get(intdual(idx2d.index[0], idx2d.index[1]));
163 #endif
164  return retval;
165 
166 }
167 
168 /**
169  * New functions beind added for the topology mapping of the
170  * density objects - RhoR, RhoG, RhoGHartExt
171  */
172 
173 int RhoRSMap::procNum(int arrayHdl, const CkArrayIndex &iIndex)
174 {
175  int *index=(int *) iIndex.data();
176 
177  if(maptable==NULL)
178  {
179  CkPrintf("Warning! RhoRSMap::Procnum had to assign maptable on %d!\n",CkMyPe() );
180 #ifdef USE_INT_MAP
181  maptable= &RhoRSImaptable;
182 #else
183  maptable= &RhoRSmaptable;
184 #endif
185 
186  }
187 #ifdef USE_INT_MAP
188  int retval=maptable->get(index[0], 0);
189 #else
190  int retval=maptable->get(intdual(index[0], 0));
191 #endif
192  return retval;
193 
194 }
195 
196 
197 int RhoGSMap::procNum(int arrayHdl, const CkArrayIndex &iIndex)
198 {
199  int *index=(int *) iIndex.data();
200  if(maptable==NULL)
201  {
202  CkPrintf("Warning! RhoGSMap::Procnum had to assign maptable on %d!\n",CkMyPe() );
203 #ifdef USE_INT_MAP
204  maptable= &RhoGSImaptable;
205 #else
206  maptable= &RhoGSmaptable;
207 #endif
208  }
209 #ifdef USE_INT_MAP
210  int retval=maptable->get(index[0], 0);
211 #else
212  int retval=maptable->get(intdual(index[0], 0));
213 #endif
214  CkAssert(retval>=0);
215  CkAssert(retval<CkNumPes());
216  return retval;
217 
218 }
219 
220 
221 int RhoGHartMap::procNum(int arrayHdl, const CkArrayIndex &iIndex)
222 {
223  int *index=(int *) iIndex.data();
224  if(maptable==NULL)
225  {
226  CkPrintf("Warning! RhoGHartMap::Procnum had to assign maptable on %d!\n",CkMyPe() );
227 #ifdef USE_INT_MAP
228  maptable= &RhoGHartImaptable;
229 #else
230  maptable= &RhoGHartmaptable;
231 #endif
232 
233  }
234 #ifdef USE_INT_MAP
235  int retval=maptable->get(index[0], 0);
236 #else
237  int retval=maptable->get(intdual(index[0], 0));
238 #endif
239  CkAssert(retval>=0);
240  CkAssert(retval<CkNumPes());
241  return retval;
242 
243 }
244 
245 int RhoRHartMap::procNum(int arrayHdl, const CkArrayIndex &idx)
246 {
247  CkArrayIndex2D idx2d = *(CkArrayIndex2D *) &idx;
248  if(maptable==NULL)
249  {
250  CkPrintf("Warning! RhoRHartMap::Procnum had to assign maptable on %d!\n",CkMyPe() );
251 #ifdef USE_INT_MAP
252  maptable= &RhoRHartImaptable;
253 #else
254  maptable= &RhoRHartmaptable;
255 #endif
256 
257  }
258 #ifdef USE_INT_MAP
259  int retval=maptable->get(idx2d.index[0], 0);
260 #else
261  int retval=maptable->get(intdual(idx2d.index[0], 0));
262 #endif
263  CkAssert(retval>=0);
264  CkAssert(retval<CkNumPes());
265  return retval;
266 
267 }
int procNum(int, const CkArrayIndex &iIndex)
this one uses a lookup table built by calling the slow version
Definition: pcMaps.h:27
int procNum(int, const CkArrayIndex &iIndex)
New functions beind added for the topology mapping of the density objects - RhoR, RhoG...
Definition: cpaimd.h:472
int procNum(int, const CkArrayIndex &iIndex)
int GSMap::slowprocNum(int arrayHdl, const CkArrayIndex2D &idx2d)
Definition: cpaimd.h:315
Some basic data structures and the array map classes are defined here.
int procNum(int, const CkArrayIndex &iIndex)
Function for RealSpace objects.
Definition: cpaimd.h:371
Author: Eric J Bohm Date Created: May 31, 2006.