00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _CPAIMD_H
00014 #define _CPAIMD_H
00015
00016 #include "EachToManyMulticastStrategy.h"
00017 #include "RingMulticastStrategy.h"
00018 #include "StreamingStrategy.h"
00019 #include "pairCalculator.h"
00020 #include "ckhashtable.h"
00021 #include "PeList.h"
00022 #define USE_INT_MAP
00023 #ifndef USE_INT_MAP
00024 class IntMap2
00025 {
00026 public:
00027 void pup(PUP::er &p)
00028 {
00029 }
00030 };
00031
00032 typedef IntMap2 IntMap4;
00033 #else
00034 #include "IntMap.h"
00035 typedef IntMap4 MapType4;
00036 typedef IntMap3 MapType3;
00037 class MapType2 : public IntMap2on2 {
00038 public:
00039 int getCentroid (int);
00040 };
00041
00042 #endif
00043
00044 #include "MapTable.h"
00045
00046 #ifdef CMK_VERSION_BLUEGENE
00047
00048 #endif
00049
00050
00051
00052
00053 #define LOAD_BALANCE_STEP 100000000
00054
00055 #define PRE_BALANCE_STEP 2
00056
00057 #define FIRST_BALANCE_STEP 100000000
00058
00059 #ifndef CMK_OPTIMIZE
00060 #define TRACE_ON_STEP 4
00061 #define TRACE_OFF_STEP 7
00062 #endif
00063
00064 #ifndef CmiMemcpy
00065 #define CmiMemcpy(dest, src, size) CmiMemcpy((dest), (src), (size))
00066 #endif
00067
00068 extern bool fakeTorus;
00069
00070 extern MapType2 GSImaptable;
00071 extern MapType2 RSImaptable;
00072 extern MapType2 RPPImaptable;
00073 extern MapType2 RhoGSImaptable;
00074 extern MapType2 RhoRSImaptable;
00075 extern MapType2 RhoGHartImaptable;
00076 extern MapType3 RhoRHartImaptable;
00077 extern MapType4 AsymScalcImaptable;
00078 extern MapType4 SymScalcImaptable;
00079
00080 extern CkHashtableT <intdual, int> GSmaptable;
00081 extern CkHashtableT <intdual, int> RSmaptable;
00082 extern CkHashtableT <intdual, int> RPPmaptable;
00083 extern CkHashtableT <intdual, int> RhoGSmaptable;
00084 extern CkHashtableT <intdual, int> RhoRSmaptable;
00085 extern CkHashtableT <intdual, int> RhoGHartmaptable;
00086 extern CkHashtableT <inttriple, int> RhoRHartmaptable;
00087 extern CkHashtableT <intdual, int> AsymScalcmaptable;
00088 extern CkHashtableT <intdual, int> SymScalcmaptable;
00089 CkReductionMsg *sumFastDouble(int nMsg, CkReductionMsg **msgs);
00090 void fastAdd (double *a, double *b, int nelem);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 class main : public Chare {
00102 public:
00103 main(CkMigrateMessage *m) { }
00104 main(CkArgMsg *);
00105 void doneInit(CkReductionMsg *msg);
00106 ~main();
00107
00108
00109 };
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 class CkArrayMapTable2 : public CkArrayMap
00127 {
00128 public:
00129 MapType2 *maptable;
00130
00131
00132 CkArrayMapTable2() {}
00133 inline int procNum(int, const CkArrayIndex &iIndex){
00134 int *index=(int *) iIndex.data();
00135 int proc;
00136
00137 #ifdef USE_INT_MAP
00138 proc=maptable->get(index[0],index[1]);
00139 #else
00140 proc=maptable->get(intdual(index[0],index[1]));
00141 #endif
00142 CkAssert(proc>=0);
00143 if(fakeTorus)
00144 return(proc%CkNumPes());
00145 else
00146 return(proc);
00147
00148 }
00149 void pup(PUP::er &p)
00150 {
00151 CkArrayMap::pup(p);
00152 }
00153 ~CkArrayMapTable2(){}
00154
00155 };
00156
00157 class CkArrayMapTable3 : public CkArrayMap
00158 {
00159 public:
00160 MapType3 *maptable;
00161
00162
00163 CkArrayMapTable3() {}
00164 inline int procNum(int, const CkArrayIndex &iIndex){
00165 int *index=(int *) iIndex.data();
00166 int proc;
00167
00168 #ifdef USE_INT_MAP
00169 proc=maptable->get(index[0],index[1],index[2]);
00170 #else
00171 proc=maptable->get(inttriple(index[0],index[1],index[2]));
00172 #endif
00173 CkAssert(proc>=0);
00174 if(fakeTorus)
00175 return(proc%CkNumPes());
00176 else
00177 return(proc);
00178
00179
00180 }
00181 void pup(PUP::er &p)
00182 {
00183 CkArrayMap::pup(p);
00184 }
00185 ~CkArrayMapTable3(){}
00186
00187 };
00188
00189 class CkArrayMapTable4 : public CkArrayMap
00190 {
00191 public:
00192 MapType4 *maptable;
00193
00194
00195 CkArrayMapTable4() {}
00196 inline int procNum(int, const CkArrayIndex &iIndex){
00197 int proc;
00198
00199 #ifdef USE_INT_MAP
00200 short *sindex=(short *) iIndex.data();
00201 proc=maptable->get(sindex[0], sindex[1], sindex[2], sindex[3]);
00202 #else
00203 int *index=(int *) iIndex.data();
00204 proc=maptable->get(intdual(index[0], index[1]));
00205 #endif
00206 CkAssert(proc>=0);
00207 if(fakeTorus)
00208 return(proc%CkNumPes());
00209 else
00210 return(proc);
00211
00212 }
00213 void pup(PUP::er &p)
00214 {
00215 CkArrayMap::pup(p);
00216 }
00217 ~CkArrayMapTable4(){}
00218
00219 };
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 class GSMap: public CkArrayMapTable2 {
00233
00234 public:
00235 GSMap()
00236 {
00237 #ifdef USE_INT_MAP
00238 maptable= &GSImaptable;
00239 #else
00240 maptable= &GSmaptable;
00241 #endif
00242 }
00243 void pup(PUP::er &p)
00244 {
00245 CkArrayMapTable2::pup(p);
00246 #ifdef USE_INT_MAP
00247 maptable= &GSImaptable;
00248 #else
00249 maptable= &GSmaptable;
00250 #endif
00251 }
00252 inline int procNum(int, const CkArrayIndex &iIndex){
00253 int *index=(int *) iIndex.data();
00254 int proc;
00255 #ifdef USE_INT_MAP
00256 proc=maptable->get(index[0],index[1]);
00257 #else
00258 proc=maptable->get(intdual(index[0],index[1]));
00259 #endif
00260 CkAssert(proc>=0);
00261 if(fakeTorus)
00262 return(proc%CkNumPes());
00263 else
00264 return(proc);
00265 }
00266
00267
00268 ~GSMap(){
00269 }
00270 };
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 class RSMap: public CkArrayMapTable2 {
00283
00284 public:
00285 RSMap()
00286 {
00287 #ifdef USE_INT_MAP
00288 maptable= &RSImaptable;
00289 #else
00290 maptable= &RSmaptable;
00291 #endif
00292 }
00293 void pup(PUP::er &p)
00294 {
00295 CkArrayMapTable2::pup(p);
00296 #ifdef USE_INT_MAP
00297 maptable= &RSImaptable;
00298 #else
00299 maptable= &RSmaptable;
00300 #endif
00301 }
00302
00303 inline int procNum(int, const CkArrayIndex &iIndex){
00304 int *index=(int *) iIndex.data();
00305 int proc;
00306
00307 #ifdef USE_INT_MAP
00308 proc=maptable->get(index[0],index[1]);
00309 #else
00310 proc=maptable->get(intdual(index[0],index[1]));
00311 #endif
00312 CkAssert(proc>=0);
00313 if(fakeTorus)
00314 return(proc%CkNumPes());
00315 else
00316 return(proc);
00317
00318 }
00319
00320 ~RSMap(){
00321 }
00322 };
00323
00324
00325 class RPPMap: public CkArrayMapTable2 {
00326
00327 public:
00328 RPPMap()
00329 {
00330 #ifdef USE_INT_MAP
00331 maptable= &RPPImaptable;
00332 #else
00333 maptable= &RPPmaptable;
00334 #endif
00335 }
00336 void pup(PUP::er &p)
00337 {
00338 CkArrayMapTable2::pup(p);
00339 #ifdef USE_INT_MAP
00340 maptable= &RPPImaptable;
00341 #else
00342 maptable= &RPPmaptable;
00343 #endif
00344
00345 }
00346
00347 ~RPPMap(){
00348
00349 }
00350 inline int procNum(int, const CkArrayIndex &iIndex){
00351 int *index=(int *) iIndex.data();
00352 int proc;
00353
00354 #ifdef USE_INT_MAP
00355 proc=maptable->get(index[0],index[1]);
00356 #else
00357 proc=maptable->get(intdual(index[0],index[1]));
00358 #endif
00359 CkAssert(proc>=0);
00360 if(fakeTorus)
00361 return(proc%CkNumPes());
00362 else
00363 return(proc);
00364
00365
00366 }
00367
00368 };
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 class SCalcMap : public CkArrayMapTable4 {
00383 bool symmetric;
00384 public:
00385 SCalcMap(bool _symmetric): symmetric(_symmetric){
00386 #ifdef USE_INT_MAP
00387 if(symmetric)
00388 maptable= &SymScalcImaptable;
00389 else
00390 maptable= &AsymScalcImaptable;
00391 #else
00392 if(symmetric)
00393 maptable= &SymScalcmaptable;
00394 else
00395 maptable= &AsymScalcmaptable;
00396 #endif
00397 }
00398 void pup(PUP::er &p)
00399 {
00400 CkArrayMapTable4::pup(p);
00401 p|symmetric;
00402 #ifdef USE_INT_MAP
00403 if(symmetric)
00404 maptable= &SymScalcImaptable;
00405 else
00406 maptable= &AsymScalcImaptable;
00407 #else
00408 if(symmetric)
00409 maptable= &SymScalcmaptable;
00410 else
00411 maptable= &AsymScalcmaptable;
00412 #endif
00413 }
00414
00415 inline int procNum(int, const CkArrayIndex &iIndex){
00416 int proc;
00417
00418 #ifdef USE_INT_MAP
00419 short *sindex=(short *) iIndex.data();
00420 proc=maptable->get(sindex[0], sindex[1], sindex[2], sindex[3]);
00421 #else
00422 int *index=(int *) iIndex.data();
00423 proc=maptable->get(intdual(index[0], index[1]));
00424 #endif
00425 CkAssert(proc>=0);
00426 if(fakeTorus)
00427 return(proc%CkNumPes());
00428 else
00429 return(proc);
00430 }
00431
00432 };
00433
00434
00435
00436
00437 class RhoRSMap : public CkArrayMapTable2 {
00438 public:
00439 int nchareRhoR;
00440 RhoRSMap()
00441 {
00442 #ifdef USE_INT_MAP
00443 maptable= &RhoRSImaptable;
00444 #else
00445 maptable= &RhoRSmaptable;
00446 #endif
00447 }
00448
00449 ~RhoRSMap() {
00450 }
00451
00452 void pup(PUP::er &p)
00453 {
00454 CkArrayMapTable2::pup(p);
00455 #ifdef USE_INT_MAP
00456 maptable= &RhoRSImaptable;
00457 #else
00458 maptable= &RhoRSmaptable;
00459 #endif
00460 }
00461
00462
00463 inline int procNum(int, const CkArrayIndex &iIndex){
00464 int *index=(int *) iIndex.data();
00465 int proc;
00466
00467 #ifdef USE_INT_MAP
00468 proc=maptable->get(index[0],index[1]);
00469 #else
00470 proc=maptable->get(intdual(index[0],index[1]));
00471 #endif
00472 CkAssert(proc>=0);
00473 if(fakeTorus)
00474 return(proc%CkNumPes());
00475 else
00476 return(proc);
00477 }
00478
00479 };
00480
00481
00482
00483
00484
00485 class RhoGSMap : public CkArrayMapTable2 {
00486 public:
00487 RhoGSMap()
00488 {
00489 #ifdef USE_INT_MAP
00490 maptable= &RhoGSImaptable;
00491 #else
00492 maptable= &RhoGSmaptable;
00493 #endif
00494 }
00495
00496 ~RhoGSMap() {
00497 }
00498
00499
00500 inline int procNum(int, const CkArrayIndex &iIndex){
00501 int *index=(int *) iIndex.data();
00502 int proc;
00503
00504 #ifdef USE_INT_MAP
00505 proc=maptable->get(index[0],index[1]);
00506 #else
00507 proc=maptable->get(intdual(index[0],index[1]));
00508 #endif
00509 CkAssert(proc>=0);
00510 if(fakeTorus)
00511 return(proc%CkNumPes());
00512 else
00513 return(proc);
00514
00515 }
00516
00517 void pup(PUP::er &p)
00518 {
00519 CkArrayMapTable2::pup(p);
00520 }
00521 };
00522
00523
00524 class RhoGHartMap : public CkArrayMapTable2 {
00525 public:
00526 RhoGHartMap()
00527 {
00528 #ifdef USE_INT_MAP
00529 maptable= &RhoGHartImaptable;
00530 #else
00531 maptable= &RhoGHartmaptable;
00532 #endif
00533 }
00534
00535 ~RhoGHartMap()
00536 {
00537 }
00538
00539
00540
00541 void pup(PUP::er &p)
00542 {
00543 CkArrayMapTable2::pup(p);
00544 #ifdef USE_INT_MAP
00545 maptable= &RhoGHartImaptable;
00546 #else
00547 maptable= &RhoGHartmaptable;
00548 #endif
00549 }
00550 inline int procNum(int, const CkArrayIndex &iIndex){
00551 int *index=(int *) iIndex.data();
00552 int proc;
00553 #ifdef USE_INT_MAP
00554 proc=maptable->get(index[0],index[1]);
00555 #else
00556 proc=maptable->get(intdual(index[0],index[1]));
00557 #endif
00558 CkAssert(proc>=0);
00559 if(fakeTorus)
00560 return(proc%CkNumPes());
00561 else
00562 return(proc);
00563
00564 }
00565
00566
00567 };
00568
00569 class RhoRHartMap : public CkArrayMapTable3 {
00570 public:
00571 RhoRHartMap()
00572 {
00573 #ifdef USE_INT_MAP
00574 maptable= &RhoRHartImaptable;
00575 #else
00576 maptable= &RhoRHartmaptable;
00577 #endif
00578 }
00579
00580 ~RhoRHartMap()
00581 {
00582 }
00583
00584
00585
00586 void pup(PUP::er &p)
00587 {
00588 CkArrayMapTable3::pup(p);
00589 #ifdef USE_INT_MAP
00590 maptable= &RhoRHartImaptable;
00591 #else
00592 maptable= &RhoRHartmaptable;
00593 #endif
00594 }
00595 inline int procNum(int, const CkArrayIndex &iIndex){
00596 int *index=(int *) iIndex.data();
00597 int proc;
00598
00599 #ifdef USE_INT_MAP
00600 proc=maptable->get(index[0],index[1],index[2]);
00601 #else
00602 proc=maptable->get(inttriple(index[0],index[1],index[2]));
00603 #endif
00604 CkAssert(proc>=0);
00605 if(fakeTorus)
00606 return(proc%CkNumPes());
00607 else
00608 return(proc);
00609 }
00610
00611 };
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 #include "../../include/CPcharmParaInfo.h"
00626 class CPcharmParaInfoGrp: public Group {
00627 public:
00628 CPcharmParaInfoGrp(CkMigrateMessage *m) {}
00629 CPcharmParaInfoGrp(CPcharmParaInfo &s);
00630 ~CPcharmParaInfoGrp();
00631 CPcharmParaInfo *cpcharmParaInfo;
00632 };
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 #define DoFFTContribute_ 100
00646 #define doRealFwFFT_ 110
00647 #define doRealBwFFT_ 120
00648 #define GspaceFwFFT_ 130
00649 #define GspaceBwFFT_ 140
00650 #define RhoRtoGFFT_ 150
00651
00652 #define PostByrdfwFFTGtoR_ 152
00653 #define BwFFTRtoG_ 153
00654 #define ByrdanddoFwFFTGtoR_ 154
00655 #define HartExcVksG_ 160
00656 #define divRhoVksGspace_ 161
00657 #define AcceptStructFact_ 162
00658 #define eesHartExcG_ 163
00659 #define eesEwaldG_ 164
00660 #define eesAtmForcR_ 165
00661 #define eesAtmBspline_ 166
00662 #define eesZmatR_ 167
00663 #define eesEnergyAtmForcR_ 168
00664 #define eesProjG_ 169
00665 #define fwFFTGtoR0_ 170
00666 #define fwFFTGtoRnot0_ 171
00667 #define doNlFFTGtoR_ 172
00668 #define doNlFFTRtoG_ 173
00669 #define eesPsiForcGspace_ 174
00670 #define GradCorrGGA_ 180
00671 #define WhiteByrdFFTX_ 181
00672 #define WhiteByrdFFTY_ 182
00673 #define WhiteByrdFFTZ_ 183
00674 #define enlMatrixCalc_ 300
00675 #define enlAtmForcCalc_ 301
00676 #define enlForcCalc_ 302
00677 #define doEextFFTRtoG_ 303
00678 #define doEextFFTGtoR_ 304
00679 #define doEextFFTGxtoRx_ 305
00680 #define doEextFFTRytoGy_ 306
00681 #define doRhoFFTRytoGy_ 307
00682 #define doRhoFFTGxtoRx_ 308
00683 #define OrthoDGEMM1_ 401
00684 #define OrthoDGEMM2_ 402
00685
00686 #define IntegrateModForces_ 1000
00687 #define Scalcmap_ 2000
00688 #define GHartAtmForcCopy_ 3000
00689 #define GHartAtmForcSend_ 4000
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 class size2d;
00703 void init_pair_calculators(int nstates, int indexSize, int *indexZ, int doublePack,
00704 CPcharmParaInfo *sim, int boxSize);
00705 void init_ortho_chares(int, int, int *);
00706
00707 void init_commlib_strategies(int, int,int);
00708 void lst_sort_clean(int , int *, int *);
00709 void init_state_chares(size2d,int,int,int,int,CPcharmParaInfo *);
00710 void init_eesNL_chares(size2d sizeYZ, int natm_nl,int natm_nl_grp_max,
00711 int doublePack, PeList *exclusion, CPcharmParaInfo *sim);
00712 void init_rho_chares(size2d ,CPcharmParaInfo*);
00713 void control_physics_to_driver();
00714 void get_grp_params(int natm_nl, int numSfGrps, int indexSfGrp, int planeIndex,
00715 int *n_ret, int *istrt_ret, int *iend_ret);
00716 int atmGrpMap(int istart, int nsend, int listsize, int *listpe, int AtmGrp,
00717 int dup, int planeIndex);
00718 int gsprocNum(CPcharmParaInfo *sim,int state, int plane);
00719 bool findCuboid(int &x, int &y, int &z, int &order, int maxX, int maxY, int maxZ, int maxT, int volume, int vn);
00720 void create_Rho_fft_numbers(int ,int ,int , int, int, int, int *,int *,int *,int *, int *);
00721
00722
00723
00724
00725
00726
00727
00728 #include "../../include/Atoms.h"
00729 #include "energy.h"
00730 #include "cpaimd.decl.h"
00731
00732 #endif
00733