1 #include "orthoBuilder.h"
3 #include "CLA_Matrix.h"
5 #include "paircalc/pcMaps.h"
8 #include "ortho.decl.h"
10 #include "ckmulticast.h"
19 namespace impl {
MapType2 *dirtyGlobalMapTable4Ortho, *dirtyGlobalMapTable4OrthoHelper; }
26 CkPrintf(
"Building Ortho Chares\n");
32 CkGroupID orthoMcastGID;
34 CkGroupID orthoRedGID;
36 CProxy_OrthoHelper orthoHelperProxy;
42 PeList *availGlobR = mapCfg.getPeList();
48 excludePes->TheList[0]=config.numPes;
51 double Timer=CmiWallTimer();
56 if (
cfg.instanceIndex == 0)
61 if(config.loadMapFiles)
65 MapFile *mf =
new MapFile(
"OrthoMap", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
66 success = mf->loadMap(
"OrthoMap", &orthoMapTable);
77 impl::dirtyGlobalMapTable4Ortho =
new MapType2(orthoMapTable);
82 int x = mapCfg.mapOffset.getx();
83 int y = mapCfg.mapOffset.gety();
84 int z = mapCfg.mapOffset.getz();
85 if((CkNumPes()==1) && !mapCfg.isTorusFake)
86 orthoMapTable = *impl::dirtyGlobalMapTable4Ortho;
88 orthoMapTable.translate(impl::dirtyGlobalMapTable4Ortho, x, y, z, mapCfg.isTorusMap);
91 double newtime=CmiWallTimer();
92 CkPrintf(
"OrthoMap created in %g\n\n", newtime-Timer);
95 if(config.dumpMapFiles)
99 MapFile *mf =
new MapFile(
"OrthoMap", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
100 mf->dumpMap(&orthoMapTable,
cfg.instanceIndex);
105 if(config.dumpMapCoordFiles)
109 MapFile *mf =
new MapFile(
"OrthoMap_coord", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
110 mf->dumpMapCoords(&orthoMapTable,
cfg.instanceIndex);
115 CProxy_OrthoMap orthoMap = CProxy_OrthoMap::ckNew(orthoMapTable);
116 CkArrayOptions orthoOpts;
117 orthoOpts.setMap(orthoMap);
118 orthoOpts.setStaticInsertion(
true);
119 orthoOpts.setAnytimeMigration(
false);
120 CProxy_Ortho orthoProxy = CProxy_Ortho::ckNew(orthoOpts);
125 if(config.useOrthoHelpers)
127 double Timer=CmiWallTimer();
129 if (
cfg.instanceIndex == 0)
133 if(config.loadMapFiles)
137 MapFile *mf =
new MapFile(
"OrthoHelperMap", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
138 success = mf->loadMap(
"OrthoHelperMap", &helperMapTable);
147 impl::dirtyGlobalMapTable4OrthoHelper =
new MapType2(orthoMapTable);
151 int x = mapCfg.mapOffset.getx();
152 int y = mapCfg.mapOffset.gety();
153 int z = mapCfg.mapOffset.getz();
154 if((CkNumPes()==1) && !mapCfg.isTorusFake)
155 helperMapTable = *impl::dirtyGlobalMapTable4OrthoHelper;
157 helperMapTable.translate(impl::dirtyGlobalMapTable4OrthoHelper, x, y, z, mapCfg.isTorusMap);
160 double newtime=CmiWallTimer();
161 CkPrintf(
"OrthoHelperMap created in %g\n", newtime-Timer);
162 CProxy_OrthoHelperMap orthoHMap = CProxy_OrthoHelperMap::ckNew(helperMapTable);
163 CkArrayOptions orthoHOpts;
164 orthoHOpts.setMap(orthoHMap);
165 orthoHelperProxy = CProxy_OrthoHelper::ckNew(orthoHOpts);
166 helperAID = orthoHelperProxy.ckGetArrayID();
168 if(config.dumpMapFiles)
172 MapFile *mf =
new MapFile(
"OrthoHelperMap", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
173 mf->dumpMap(&helperMapTable,
cfg.instanceIndex);
177 if(config.dumpMapCoordFiles)
181 MapFile *mf =
new MapFile(
"OrthoHelperMap_coord", 2, size, config.numPes,
"TXYZ", 2, 1, 1, 1);
182 mf->dumpMapCoords(&helperMapTable,
cfg.instanceIndex);
190 Strategy *multistrat =
new DirectMulticastStrategy();
191 orthoInstance=ComlibRegister(multistrat);
196 CkCallback ocb= CkCallback(CkIndex_Ortho::collect_error(NULL), orthoProxy(0, 0));
197 orthoProxy.ckSetReductionClient(&ocb);
200 CkCallback ortho_ready_cb = CkCallback(CkIndex_Ortho::all_ready(), orthoProxy(0, 0));
202 mCastGID = CProxy_CkMulticastMgr::ckNew(config.numMulticastMsgs);
205 orthoMcastGID = (CProxy_CkMulticastMgr::ckNew(config.OrthoMcastSpanFactor));
206 orthoRedGID = (CProxy_CkMulticastMgr::ckNew(config.OrthoRedSpanFactor));
226 make_multiplier(&matA1, &matB1, &matC1,
227 orthoProxy, orthoProxy, orthoProxy,
231 ortho_ready_cb, ortho_ready_cb, ortho_ready_cb,
232 mCastGID, MM_ALG_2D, config.gemmSplitOrtho
235 if(config.useOrthoHelpers)
237 make_multiplier(&matA2, &matB2, &matC2,
238 orthoHelperProxy, orthoHelperProxy, orthoHelperProxy,
242 ortho_ready_cb, ortho_ready_cb, ortho_ready_cb,
243 mCastGID, MM_ALG_2D, config.gemmSplitOrtho
248 make_multiplier(&matA2, &matB2, &matC2,
249 orthoProxy, orthoProxy, orthoProxy,
253 ortho_ready_cb, ortho_ready_cb, ortho_ready_cb,
254 mCastGID, MM_ALG_2D, config.gemmSplitOrtho
258 make_multiplier(&matA3, &matB3, &matC3,
259 orthoProxy, orthoProxy, orthoProxy,
263 ortho_ready_cb, ortho_ready_cb, ortho_ready_cb,
264 mCastGID, MM_ALG_2D, config.gemmSplitOrtho
268 int timekeep=keeperRegister(
"Ortho S to T");
272 for (
int s1 = 0; s1 <= maxorthostateindex; s1 +=
cfg.
grainSize)
273 for (
int s2 = 0; s2 <= maxorthostateindex; s2 +=
cfg.
grainSize)
277 indX = (indX>maxorthoindex) ? maxorthoindex : indX;
278 indY = (indY>maxorthoindex) ? maxorthoindex : indY;
280 orthoProxy(indX, indY).insert(
288 orthoMcastGID, orthoRedGID);
290 if(config.useOrthoHelpers)
292 CkCallback endOfStep2CB(CkIndex_Ortho::recvStep2(NULL), CkArrayIndex2D(indX,indY), orthoProxy);
293 orthoHelperProxy(indX, indY).insert(
300 orthoProxy.doneInserting();
301 if(config.useOrthoHelpers)
302 orthoHelperProxy.doneInserting();
307 return orthoProxy.ckGetArrayID();
int grainSize
The block size for parallelization.
CkGroupID mapperGID
The group providing procNum() for placing the objects of this paircalc array instance.
int numStates
The number of states in the simulation (the dimension of the input square matrix) ...
CkArrayID build(cp::paircalc::InstanceIDs &asymmHandle, const startup::PCMapConfig mapCfg)
Construct an ortho world given the configs.
Paircalc's map group that provides procNum() to place paircalc chares as determined by the map logic...
Author: Abhinav S Bhatele Date Created: December 28th, 2006.
A container for assorted mapping inputs to pass around easily.
A place to collect substep times.
MapType4 * getMapTable()
Let local code access the paircalc maptable I store. (for use by Ortho mapping code) ...
orthoConfig cfg
The configurations for the ortho that should be instantiated.
double Timer
readonly globals
A tiny structure to hold the relevant IDs/ proxies required to interact with a paircalc instance...