4#ifndef PARALLELGRAVITY_H
5#define PARALLELGRAVITY_H
23#include "parameters.h"
30#include "TaggedVector3D.h"
56#define MERGE_REMOTE_REQUESTS_VERBOSE(X)
61 if (!cond) CkAbort(
"%s", err);
82#ifdef SELECTIVE_TRACING
112 if (p.isUnpacking()) {
129 int64_t nMaxOrderGas;
130 int64_t nMaxOrderDark;
132 void pup(PUP::er& p) {
141#include "ParallelGravity.decl.h"
143extern CProxy_Main mainChare;
147extern int _cacheLineDepth;
148extern unsigned int _yieldPeriod;
150extern double dExtraStore;
151extern double dMaxBalance;
152extern double dGlassDamper;
153extern int bUseCkLoopPar;
155extern CProxy_TreePiece treeProxy;
156#ifdef REDUCTION_HELPER
157extern CProxy_ReductionHelper reductionHelperProxy;
159extern CProxy_LvArray lvProxy;
160extern CProxy_LvArray smoothProxy;
161extern CProxy_LvArray gravityProxy;
162extern CProxy_TreePiece streamingProxy;
163extern CProxy_DataManager dMProxy;
164extern CProxy_IntraNodeLBManager nodeLBMgrProxy;
165extern unsigned int numTreePieces;
166extern unsigned int particlesPerChare;
167extern int nIOProcessor;
169extern CProxy_DumpFrameData dfDataProxy;
170extern CProxy_PETreeMerger peTreeMergerProxy;
171extern CProxy_CkCacheManager<KeyType> cacheGravPart;
172extern CProxy_CkCacheManager<KeyType> cacheSmoothPart;
173extern CProxy_CkCacheManager<KeyType> cacheNode;
176extern CkGroupID dataManagerID;
182extern int boundaryEvaluationUE;
183extern int weightBalanceUE;
184extern int networkProgressUE;
185extern int nodeForceUE;
186extern int partForceUE;
188extern int tbFlushRequestsUE;
189extern int prefetchDoneUE;
192extern int _randChunks;
193extern int _numChunks;
194extern unsigned int bucketSize;
197extern int localNodesPerReq;
198extern int remoteNodesPerReq;
199extern int remoteResumeNodesPerReq;
200extern int localPartsPerReq;
201extern int remotePartsPerReq;
202extern int remoteResumePartsPerReq;
204extern double largePhaseThreshold;
206extern cosmoType theta;
207extern cosmoType thetaMono;
209extern int numInitDecompBins;
210extern int octRefineLevel;
218class TreePieceStatistics {
219 u_int64_t nodesOpenedLocal;
220 u_int64_t nodesOpenedRemote;
221 u_int64_t nodeInterLocal;
222 u_int64_t nodeInterRemote;
223 u_int64_t particleInterLocal;
224 u_int64_t particleInterRemote;
225 u_int64_t openCriterionCalls;
228 TreePieceStatistics() : nodesOpenedLocal(0), nodesOpenedRemote(0),
229 nodeInterLocal(0), nodeInterRemote(0), particleInterLocal(0),
230 particleInterRemote(0), openCriterionCalls(0), nActive(0) { }
233 TreePieceStatistics(u_int64_t nol, u_int64_t nor, u_int64_t occ, u_int64_t nil, u_int64_t nir,
234 u_int64_t pil, u_int64_t pir,
int na) :
235 nodesOpenedLocal(nol), nodesOpenedRemote(nor), nodeInterLocal(nil),
236 nodeInterRemote(nir), particleInterLocal(pil), particleInterRemote(pir),
237 openCriterionCalls(occ), nActive(na) { }
239 void printTo(CkOStream &os) {
240 os <<
" TreePiece: " << nActive <<
" particles active." << endl;
241 os <<
" TreePiece: " << nodesOpenedLocal <<
" local nodes opened, ";
242 os << nodesOpenedRemote <<
" remote" << endl;
243 os <<
" TreePiece: " << openCriterionCalls <<
" num of open criterion calls" << endl;
244 os <<
" TreePiece: " << nodeInterLocal <<
" local particle-node interactions, ";
245 os << nodeInterRemote <<
" remote" << endl;
246 os <<
" TreePiece: " << particleInterLocal <<
" local particle-particle interactions, ";
247 os << particleInterRemote <<
" remote" << endl;
249 << (particleInterLocal + particleInterRemote)/(
double) nActive
251 << (nodeInterLocal + nodeInterRemote)/(
double) nActive
252 <<
" nodes per particle" << endl;
255 static CkReduction::reducerType sum;
257 static CkReductionMsg *sumFn(
int nMsg, CkReductionMsg **msgs) {
258 TreePieceStatistics ret;
259 for (
int i=0; i<nMsg; ++i) {
260 CkAssert(msgs[i]->getSize() ==
sizeof(TreePieceStatistics));
261 TreePieceStatistics *data = (TreePieceStatistics *)msgs[i]->getData();
262 ret.nodesOpenedLocal += data->nodesOpenedLocal;
263 ret.nodesOpenedRemote += data->nodesOpenedRemote;
264 ret.openCriterionCalls += data->openCriterionCalls;
265 ret.nodeInterLocal += data->nodeInterLocal;
266 ret.nodeInterRemote += data->nodeInterRemote;
267 ret.particleInterLocal += data->particleInterLocal;
268 ret.particleInterRemote += data->particleInterRemote;
269 ret.nActive += data->nActive;
271 return CkReductionMsg::buildNew(
sizeof(TreePieceStatistics), &ret);
277class ComputeChunkMsg :
public CMessage_ComputeChunkMsg {
282 ComputeChunkMsg(
int i) : chunkNum(i) {
291class ORBSplittersMsg :
public CMessage_ORBSplittersMsg{
302 ORBSplittersMsg(
int len, CkCallback callback):
length (len),
cb(callback) {}
307class ParticleShuffleMsg :
public CMessage_ParticleShuffleMsg{
314 unsigned int *parts_per_phase;
318 ParticleShuffleMsg(
int nload,
int npart,
int nsph,
int nstar):
319 nloads(nload), n(npart), nSPH(nsph), nStar(nstar) {}
323#include "ckmulticast.h"
325struct BucketMsg :
public CkMcastBaseMsg,
public CMessage_BucketMsg {
352 void pup(PUP::er& p) {
378const int MAXRUNG = 30;
379const int MAXSUBSTEPS = 1 << MAXRUNG;
380const double MAXSUBSTEPS_INV = 1 / (double)MAXSUBSTEPS;
384 CkAssert(iRung <= MAXRUNG);
385 return 1 << (MAXRUNG - iRung);
390inline int DtToRung(
double dDelta,
double dTideal) {
391 int iSteps = (int) ceil(dDelta/dTideal);
424 double l2 = p->soft*p->soft;
428 double e2 = p->soft*p->soft;
429 if (l2 < e2) l2 = e2;
432 return l2*dResolveJeans*p->fDensity;
437const double GAMMA_NONCOOL = 5.0/3.0;
449class Main :
public CBase_Main {
451 std::string basefilename;
455 std::vector<std::string> NCgasNames;
456 std::vector<std::string> NCdarkNames;
457 std::vector<std::string> NCstarNames;
461 Ck::IO::File fIOFile;
462 CProxy_Sorter sorter;
463 int64_t nTotalParticles;
469 int64_t nMaxOrderGas;
470 int64_t nMaxOrderDark;
481 CkVec<double> vdOutTime;
492 double dSimStartTime;
499 double localNodesPerReqDouble;
500 double remoteNodesPerReqDouble;
501 double remoteResumeNodesPerReqDouble;
502 double localPartsPerReqDouble;
503 double remotePartsPerReqDouble;
504 double remoteResumePartsPerReqDouble;
507#ifdef CHECK_TIME_WITHIN_BIGSTEP
508 double wallTimeStart;
513 class timing_fields {
531 tGrav = tColl = tuDot = tDD = tLoadB = tTBuild = tAdjust
532 = tEmergAdjust = tKick = tDrift = tCache = 0.0;
536 CkVec<timing_fields> timings;
537 void writeTimings(
int iStep);
539#ifdef SELECTIVE_TRACING
542 int numTraceIterations;
543 int numSkipIterations;
549 void turnProjectionsOn(
int activeRung);
550 void turnProjectionsOff();
557 Main(CkMigrateMessage *m);
563 void restart(CkCheckpointStatusMsg *msg);
570 void startGravity(
const CkCallback& cbGravity,
int iActiveRung,
573 void updateuDot(
int iActiveRung,
const double duKick[],
574 const double dStartTime[],
int bUpdateState,
int bAll);
575 void kick(
bool bClosing,
int iActiveRung,
int nextMaxRung,
576 const CkCallback &cbGravity,
double gravStartTime);
577 void advanceBigCollStep(
int);
578 int adjust(
int iKickRung);
585 void calcEnergy(
double,
double,
const char *);
591 const CkCallback& cb);
592 void cbOpen(Ck::IO::FileReadyMsg *msg);
593 void cbIOReady(Ck::IO::SessionReadyMsg *msg);
597 void writeNCXML(std::string filename);
598 void NCXMLattrib(ofstream *desc, std::vector<std::string>& names,
601 void growMass(
double dTime,
double dDelta);
606 void initHMStarLog();
607 int ReadASCII(
char *extension,
int nDataPerLine,
double *dDataOut);
609 void doSph(
int activeRung,
int bNeedDensity = 1);
612 void doCollisions(
double dTime,
double dDelta,
int activeRung,
int iStep,
double dCentMass);
613 void doNearCollisions(
double dTime,
double dDelta,
int activeRung);
615 void FormStars(
double dTime,
double dDelta);
619 void FormSinks(
double dTime,
double dDelta,
int iKickRung);
620 void doSinks(
double dTime,
double dDelta,
int iKickRung);
621 int DumpFrameInit(
double dTime,
double dStep,
int bRestart);
622 void DumpFrame(
double dTime,
double dStep);
623 int nextMaxRungIncDF(
int nextMaxRung);
627 void pup(PUP::er& p);
628 void liveVizImagePrep(liveVizRequestMsg *msg);
629 void doSIDM(
double dTime,
double dDelta,
int activeRung);
665 Vector3D<cosmoType> offset;
666#if defined CHANGA_REFACTOR_PRINT_INTERACTIONS || defined CHANGA_REFACTOR_WALKCHECK_INTERLIST || defined CUDA
678 Vector3D<cosmoType> offset;
679#if defined CHANGA_REFACTOR_PRINT_INTERACTIONS || defined CHANGA_REFACTOR_WALKCHECK_INTERLIST || defined CUDA
682#if COSMO_DEBUG > 1 || defined CUDA
707struct BucketActiveInfo{
716#if INTERLIST_VER > 0 && defined CUDA
717template<
typename T>
class GenericList;
721struct NonLocalMomentsClient {
725 NonLocalMomentsClient() :
726 clientTreePiece(NULL),
737struct NonLocalMomentsClientList {
739 CkVec<NonLocalMomentsClient> clients;
741 NonLocalMomentsClientList() :
750 clients.push_back(cli);
755class TreePiece :
public CBase_TreePiece {
757 friend class PrefetchCompute;
758 friend class GravityCompute;
759 friend class SmoothCompute;
760 friend class KNearestSmoothCompute;
761 friend class ReSmoothCompute;
762 friend class MarkSmoothCompute;
763 friend class ListCompute;
764 friend class NearNeighborState;
765 friend class ReNearNeighborState;
766 friend class MarkNeighborState;
767 friend class BottomUpTreeWalk;
768#if INTERLIST_VER > 0 && defined CUDA
770 template<
typename T>
friend class GenericList;
773 friend class RemoteTreeBuilder;
774 friend class LocalTreeBuilder;
782 State *sInterListStateRemoteResume;
785 SmoothCompute *sSmooth;
787 Opt *sLocal, *sRemote, *sPref;
790 State *sPrefetchState;
792 State *sLocalGravityState, *sRemoteGravityState, *sSmoothState;
793 typedef std::map<KeyType, CkVec<int>* > SmPartRequestType;
795 SmPartRequestType smPartRequests;
797 CkVec<ActiveWalk> activeWalks;
798 int completedActiveWalks;
805 unsigned int nPrevActiveParts;
806 std::vector<double> savedPhaseLoad;
807 std::vector<unsigned int> savedPhaseParticle;
809 std::vector<double> savedPhaseLoadTmp;
811 std::vector<unsigned int> savedPhaseParticleTmp;
813 int memWithCache, memPostCache;
814 int nNodeCacheEntries, nPartCacheEntries;
818 bool createdSpanningTree;
819 CProxySection_TreePiece allTreePieceSection;
820 CkVec<GravityParticle> foreignParticles;
821 CkVec<double> foreignParticleAccelerations;
823 map<int,CkSectionInfo> cookieJar;
825 BucketMsg *createBucketMsg();
826 void unpackBuckets(BucketMsg *,
GenericTreeNode *&foreignBuckets,
int &numForeignBuckets);
827 void calculateForces(
GenericTreeNode *foreignBuckets,
int numForeignBuckets);
834 void startPushGravity(
int am,
double myTheta);
835 void recvPushBuckets(BucketMsg *);
836 void recvPushAccelerations(CkReductionMsg *);
839#if COSMO_PRINT_BK > 1
840 State *getSRemoteGravityState(){
return sRemoteGravityState; }
841 State *getSLocalGravityState(){
return sLocalGravityState; }
843 void memCacheStats(
const CkCallback &cb);
861 nodeInterRemote[chunk] += howmany;
866 particleInterRemote[chunk] += howmany;
871 nodeInterLocal += howmany;
876 particleInterLocal += howmany;
887 return myNumParticles;
904 int numActiveBuckets;
905 int myNumActiveParticles;
907 int FirstGPUParticleIndex;
908 int LastGPUParticleIndex;
909 int NumberOfGPUParticles;
910 BucketActiveInfo *bucketActiveInfo;
919 size_t sCompactParts;
927 int getActiveRung(){
return activeRung; }
931 int getDMNumParticles(){
933 return myNumParticles;
936 return myNumActiveParticles;
940 int getNumActiveParticles(){
941 return myNumActiveParticles;
944 void calculateNumActiveParticles(){
945 myNumActiveParticles = 0;
946 for(
int i = 1; i <= myNumParticles; i++){
947 if(myParticles[i].rung >= activeRung){
948 myNumActiveParticles++;
954 return (1.0*myNumActiveParticles/myNumParticles) >= largePhaseThreshold;
958 NumberOfGPUParticles = 0;
959 FirstGPUParticleIndex = fillIndex;
961 for(
int b = 0; b < numBuckets; b++){
962 GenericTreeNode *bucket = bucketList[b];
966 bucket->bucketArrayIndex = fillIndex;
967 for(
int i = buckstart; i <= buckend; i++){
968 fillArray[fillIndex] = buckparts[i-buckstart];
974 for(
int b = 0; b < numBuckets; b++){
975 GenericTreeNode *bucket = bucketList[b];
976 if(bucket->
rungs < activeRung){
979 BucketActiveInfo *binfo = &(bucketActiveInfo[b]);
985 binfo->start = fillIndex;
986 for(
int i = buckstart; i <= buckend; i++){
987 if(buckparts[i-buckstart].rung >= activeRung){
988 fillArray[fillIndex] = buckparts[i-buckstart];
992 binfo->size = fillIndex-binfo->start;
996 if(FirstGPUParticleIndex == fillIndex){
998 FirstGPUParticleIndex = -1;
999 LastGPUParticleIndex = -1;
1000 NumberOfGPUParticles = 0;
1003 LastGPUParticleIndex = fillIndex - 1;
1004 NumberOfGPUParticles = LastGPUParticleIndex - FirstGPUParticleIndex + 1;
1008 bool isActive(
int partNum){
1009 return myParticles[partNum].rung >= activeRung;
1012 void clearMarkedBuckets(CkVec<GenericTreeNode *> &markedBuckets);
1013 void clearMarkedBucketsAll();
1016 long long localNodeInteractions;
1017 long long localPartInteractions;
1018 long long remoteNodeInteractions;
1019 long long remotePartInteractions;
1020 long long remoteResumeNodeInteractions;
1021 long long remoteResumePartInteractions;
1028 void fillGPUBuffer(intptr_t bufLocalParts,
1029 intptr_t bufLocalMoments,
1030 intptr_t pLocalMoments,
int partIndex,
int nParts, intptr_t node);
1031 void updateParticles(intptr_t data,
int partIndex);
1035 void continueWrapUp();
1037#if INTERLIST_VER > 0
1039 void updateBucketState(
int start,
int end,
int n,
int chunk, State *state);
1040 void updateUnfinishedBucketState(
int start,
int end,
int n,
int chunk, State *state);
1043#if defined CHANGA_REFACTOR_WALKCHECK || defined CHANGA_REFACTOR_WALKCHECK_INTERLIST
1044 void addToBucketChecklist(
int bucketIndex, NodeKey k){
1045 bucketcheckList[bucketIndex].insert(k);
1046 if(bucketIndex == TEST_BUCKET && thisIndex == TEST_TP)
1047 CkPrintf(
"[%d] add %ld\n", thisIndex, k);
1051#if INTERLIST_VER > 0
1052 GenericTreeNode *
getStartAncestor(
int current,
int previous, GenericTreeNode *dflt);
1056 NodeLookupType::iterator iter = nodeLookupTable.find(k);
1057 if (iter != nodeLookupTable.end())
return iter->second;
1062 return bucketList[i];
1072 liveVizRequestMsg * savedLiveVizMsg;
1076 Vector3D<float> savedCentroid;
1084 CkCallback callback;
1086 CkCallback cbGravity;
1088 CkCallback cbSmooth;
1089 CkCallback after_dd_callback;
1091 unsigned int myNumParticles;
1092 unsigned int numActiveParticles;
1095 int nbor_msgs_count_;
1099 bool bBucketsInited;
1104 std::vector<GravityParticle> myTmpShuffleParticle;
1105 std::vector<extraSPHData> myTmpShuffleSphParticle;
1106 std::vector<extraStarData> myTmpShuffleStarParticle;
1110 int myTreeParticles;
1122 unsigned int myNumSPH;
1128 unsigned int myNumStar;
1141 std::vector<GenericTreeNode *> bucketList;
1144 std::vector<GravityParticle> mySortedParticles;
1146 std::vector<extraSPHData> mySortedParticlesSPH;
1148 std::vector<extraStarData> mySortedParticlesStar;
1150 std::vector<ParticleShuffleMsg*> incomingParticlesMsg;
1152 int incomingParticlesArrived;
1157 bool incomingParticlesSelf;
1174 CProxy_TreePiece pieces;
1182#ifndef REDUCTION_HELPER
1183 CkVec<int64_t> myBinCounts;
1185 std::vector<int> myBinCountsORB;
1190 SFC::Key leftSplitter, rightSplitter;
1192 std::string basefilename;
1194 OrientedBox<float> boundingBox;
1195 unsigned iterationNo;
1201 typedef std::map<NodeKey, CkVec<int>* > MomentRequestType;
1205 MomentRequestType momentRequests;
1222 Vector3D<cosmoType> fPeriod;
1236 clDerivsData *CoolData;
1239 std::vector<int> iSeTab;
1241 int nSetupWriteStage;
1242 int64_t nStartWrite;
1253 OrientedBox<cosmoType> prefetchReq;
1259 u_int64_t myNumMACChecks;
1260 u_int64_t nodesOpenedLocal;
1261 u_int64_t nodesOpenedRemote;
1262 u_int64_t numOpenCriterionCalls;
1265 u_int64_t nodeInterLocal;
1267 u_int64_t *nodeInterRemote;
1269 u_int64_t particleInterLocal;
1271 u_int64_t *particleInterRemote;
1276 unsigned int numBuckets;
1277#if INTERLIST_VER > 0
1279 int prevRemoteBucket;
1284 unsigned int ewaldCurrentBucket;
1300#if COSMO_DEBUG > 1 || defined CHANGA_REFACTOR_WALKCHECK || defined CHANGA_REFACTOR_WALKCHECK_INTERLIST
1302 typedef std::vector< std::multiset<Tree::NodeKey> > DebugList;
1303 DebugList bucketcheckList;
1312 std::vector<int> tempBinCounts;
1315 std::list<GravityParticle *> orbBoundaries;
1318 int myExpectedCount;
1321 int myExpectedCountSPH;
1324 int myExpectedCountStar;
1327 unsigned int chunkRootLevel;
1331 OrientedBox<float>* boxes;
1340 #if INTERLIST_VER > 0
1346 void finishedChunk(
int chunk);
1356 CkCallback *cbEwaldGPU;
1361#if COSMO_DEBUG > 1 || defined CHANGA_REFACTOR_WALKCHECK || defined CHANGA_REFACTOR_WALKCHECK_INTERLIST
1363 void checkWalkCorrectness();
1372 return nodeLookupTable;
1376 return nodeLookupTable.size();
1381 if(pTreeNodes != NULL) {
1385 nodeLookupTable.clear();
1389 root->fullyDelete();
1392 nodeLookupTable.clear();
1416 template <
class Tsmooth>
1417 void initBucketsSmooth(Tsmooth tSmooth);
1418 void smoothNextBucket();
1419 void reSmoothNextBucket();
1420 void markSmoothNextBucket();
1421 void smoothBucketComputation();
1434 TreePiece() : pieces(thisArrayID), root(0),
1435 iPrevRungLB (-1), sTopDown(0), sGravity(0),
1436 sPrefetch(0), sLocal(0), sRemote(0), sPref(0), sSmooth(0),
1437 nPrevActiveParts(0) {
1447 nNodeCacheEntries = 0;
1448 nPartCacheEntries = 0;
1449 completedActiveWalks = 0;
1451 nSetupWriteStage = -1;
1456 nodesOpenedLocal = 0;
1457 nodesOpenedRemote = 0;
1459 particleInterLocal = 0;
1461 numOpenCriterionCalls=0;
1468 particleInterRemote = NULL;
1469 nodeInterRemote = NULL;
1471#if INTERLIST_VER > 0
1472 sInterListWalk = NULL;
1476 numActiveBuckets = -1;
1478 localNodeInteractions = 0;
1479 localPartInteractions = 0;
1480 remoteNodeInteractions = 0;
1481 remotePartInteractions = 0;
1482 remoteResumeNodeInteractions = 0;
1483 remoteResumePartInteractions = 0;
1491 prefetchRoots = NULL;
1495 incomingParticlesMsg.clear();
1496 incomingParticlesArrived = 0;
1497 incomingParticlesSelf =
false;
1500 mySPHParticles = NULL;
1501 myStarParticles = NULL;
1502 myNumParticles = myNumSPH = myNumStar = 0;
1503 nStore = nStoreSPH = nStoreStar = 0;
1504 bBucketsInited =
false;
1505 myTreeParticles = -1;
1506 orbBoundaries.clear();
1512 createdSpanningTree =
false;
1515 localTreeBuildComplete =
false;
1518 TreePiece(CkMigrateMessage* m): pieces(thisArrayID) {
1528 nNodeCacheEntries = 0;
1529 nPartCacheEntries = 0;
1530 completedActiveWalks = 0;
1531 prefetchRoots = NULL;
1541#if INTERLIST_VER > 0
1542 sInterListWalk = NULL;
1545 incomingParticlesMsg.clear();
1546 incomingParticlesArrived = 0;
1547 incomingParticlesSelf =
false;
1550 nodeInterRemote = NULL;
1551 particleInterRemote = NULL;
1553 orbBoundaries.clear();
1556 bBucketsInited =
false;
1557 myTreeParticles = -1;
1560 localTreeBuildComplete =
false;
1564 void freeWalkObjects();
1565 void allocateStars() {
1566 nStoreStar = (int) (myNumStar*(1.0 +
dExtraStore));
1570 myStarParticles =
new extraStarData[nStoreStar];
1575 if (
verbosity>1) ckout <<
"Deallocating treepiece "<<thisIndex<<endl;
1576 if(nStore > 0)
delete[] myParticles;
1577 if(nStoreSPH > 0)
delete[] mySPHParticles;
1578 if(nStoreStar > 0)
delete[] myStarParticles;
1579 delete[] nodeInterRemote;
1580 delete[] particleInterRemote;
1581 delete[] bucketReqs;
1586 if(boxes!= NULL )
delete[] boxes;
1587 if(splitDims != NULL)
delete[] splitDims;
1591 CoolDerivsFinalize(CoolData);
1593 if (
verbosity>1) ckout <<
"Finished deallocation of treepiece "<<thisIndex<<endl;
1596 void setPeriodic(
int nReplicas, Vector3D<cosmoType> fPeriod,
int bEwald,
1597 double fEwCut,
double fEwhCut,
int bPeriod,
1598 int bComove,
double dRhoFac);
1599 void BucketEwald(GenericTreeNode *req,
int nReps,
double fEwCut);
1601 void ewaldCPU(EwaldMsg *msg);
1603 void calculateEwaldUsingCkLoop(
int yield_num);
1604 void callBucketEwald(
int id);
1605 void doParallelNextBucketWork(
int id,
LoopParData* lpdata);
1607 void initLWData(
const CkCallback& cb);
1610 void velScale(
double dScale,
const CkCallback& cb);
1615 void loadNChilada(
const std::string& filename,
const double dTuFac,
1616 const CkCallback& cb);
1618 const CkCallback& cb);
1625 void loadTipsy(
const std::string& filename,
const double dTuFac,
1626 const bool bDoublePos,
1627 const bool bDoubleVel,
1628 const CkCallback& cb);
1633 void RestartEnergy(
double dTuFac,
const CkCallback& cb);
1634 void findTotalMass(
const CkCallback &cb);
1635 void recvTotalMass(CkReductionMsg *msg);
1638 void writeTipsy(Tipsy::TipsyWriter& w,
1640 const double duTFac,
1641 const bool bDoublePos,
1642 const bool bDoubleVel,
1645 void setupWrite(
int iStage, u_int64_t iPrevOffset,
1646 const std::string& filename,
const double dTime,
1647 const double dvFac,
const double duTFac,
1648 const bool bDoublePos,
1649 const bool bDoubleVel,
1650 const int bCool,
const CkCallback& cb);
1653 const std::string& filename,
const double dTime,
1655 const double duTFac,
1656 const bool bDoublePos,
1657 const bool bDoubleVel,
1660 void serialWrite(u_int64_t iPrevOffset,
const std::string& filename,
1662 const double dvFac,
const double duTFac,
1663 const bool bDoublePos,
1664 const bool bDoubleVel,
1665 const int bCool,
const CkCallback& cb);
1671 GravityParticle *particles,
1674 extraStarData *pStar,
1677 const u_int64_t iPrevOffset,
1678 const std::string& filename,
1681 const double duTFac,
1683 const bool bDoublePos,
1684 const bool bDoubleVel,
1686 const CkCallback &cb);
1688 void reOrder(int64_t nMaxOrder,
const CkCallback& cb);
1697 void evaluateBoundaries(SFC::Key* keys,
const int n,
int isRefine,
const CkCallback& cb);
1700 void shuffleAfterQD();
1701 void unshuffleParticlesWoDD(
const CkCallback& cb);
1702 void acceptSortedParticlesFromOther(ParticleShuffleMsg *);
1703 void setNumExpectedNeighborMsgs();
1708 unsigned int myCountStar,
1709 const CkCallback& cb,
const CkCallback& cback);
1710 void sendORBParticles();
1711 void acceptORBParticles(
const GravityParticle* particles,
const int n);
1712 void acceptORBParticles(
const GravityParticle* particles,
const int n,
1713 const extraSPHData *pGas,
const int nGasIn,
1714 const extraStarData *pStar,
const int nStarIn);
1719 void kick(
int iKickRung,
double dDelta[MAXRUNG+1],
int bClosing,
1720 int bNeedVPred,
int bGasIsothermal,
double dMaxEnergy,
double duDelta[MAXRUNG+1],
1721 double gammam1,
double dThermalCondSatCoeff,
1722 double dMultiPhaseMaxTime,
double dMultiPhaseMinTemp,
double dEvapCoeff,
const CkCallback& cb);
1723 void drift(
double dDelta,
int bNeedVPred,
int bGasIsothermal,
double dvDelta,
1724 double duDelta,
int nGrowMass,
bool buildTree,
double dMaxEnergy,
1725 const CkCallback& cb);
1726 void initAccel(
int iKickRung,
const CkCallback& cb);
1727#ifdef COOLING_MOLECULARH
1728 void distribLymanWerner(
const CkCallback& cb);
1731 void applyFrameAcc(
int iKickRung, Vector3D<double> frameAcc,
const CkCallback& cb);
1738 void externalForce(
int activeRung,
const ExternalForce& exForce,
int bKepStep,
1739 const CkCallback& cb);
1763 void adjust(
int iKickRung,
int bCollStep,
int bEpsAccStep,
1764 int bGravStep,
int bKepStep,
int bSphStep,
1765 int bViscosityLimitdt,
double dEta,
double dEtaCourant,
1766 double dEtauDot,
double dDiffCoeff,
double dEtaDiffusion,
1767 double dDelta,
double dAccFac,
1768 double dCosmoFac,
double dhMinOverSoft,
1769 double dResolveJeans,
1771 const CkCallback& cb);
1773 void adjust(
int iKickRung,
int bEpsAccStep,
1774 int bGravStep,
int bSphStep,
1775 int bViscosityLimitdt,
double dEta,
double dEtaCourant,
1776 double dEtauDot,
double dDiffCoeff,
double dEtaDiffusion,
1777 double dDelta,
double dAccFac,
1778 double dCosmoFac,
double dhMinOverSoft,
1779 double dResolveJeans,
1781 const CkCallback& cb);
1788 void truncateRung(
int iCurrMaxRung,
const CkCallback& cb);
1789 void rungStats(
const CkCallback& cb);
1790 void countActive(
int activeRung,
const CkCallback& cb);
1792 void countType(
int iType,
const CkCallback& cb);
1794 long lFPos,
const CkCallback &cb);
1796 void SetSink(
double dSinkMassMin,
const CkCallback &cb);
1798 void SinkStep(
int iCurrSinkRung,
int iKickRung,
const CkCallback &cb);
1799 void formSinks(
int bJeans,
double dJConst2,
int bDensity,
1800 double dDensityCut,
double dTime,
int iKickRung,
int bSimple,
1801 const CkCallback &cb);
1803 const CkCallback &cb);
1805 void starCenterOfMass(
const CkCallback& cb);
1806 void calcEnergy(
const CkCallback& cb);
1813 void newOrder(
const NewMaxOrder *nStarts,
const int n,
int bUseStoch,
const CkCallback &cb) ;
1816 void setNParts(int64_t _nTotalSPH, int64_t _nTotalDark,
1817 int64_t _nTotalStar,
const CkCallback &cb);
1819 void setSoft(
const double dSoft,
const CkCallback &cb);
1820 void physicalSoft(
const double dSoftMax,
const double dFac,
1821 const int bSoftMaxMul,
const CkCallback& cb);
1822 void growMass(
int nGrowMass,
double dDeltaM,
const CkCallback& cb);
1823 void InitEnergy(
double dTuFac,
double z,
double dTime,
double gammam1,
1824 const CkCallback& cb);
1825 void updateuDot(
int activeRung,
double duDelta[MAXRUNG+1],
1826 double dStartTime[MAXRUNG+1],
int bCool,
int bAll,
1827 int bUpdateState,
double gammam1,
double dResolveJeans,
const CkCallback& cb);
1828 void ballMax(
int activeRung,
double dFac,
const CkCallback& cb);
1829 void sphViscosityLimiter(
int bOn,
int activeRung,
const CkCallback& cb);
1830 void getAdiabaticGasPressure(
double gamma,
double gammam1,
double dTuFac,
double dThermalCondCoeff,
1831 double dThermalCond2Coeff,
double dThermalCondSatCoeff,
double dThermalCond2SatCoeff,
1832 double dEvapMinTemp,
double dDtCourantFac,
double dResolveJeans,
const CkCallback &cb);
1833 void getCoolingGasPressure(
double gamma,
double gammam1,
double dThermalCondCoeff,
1834 double dThermalCond2Coeff,
double dThermalCondSatCoeff,
double dThermalCond2SatCoeff,
1835 double dEvapMinTemp,
double dDtCourantFac,
double dResolveJeans,
const CkCallback &cb);
1837 void SplitGas(
double dInitGasMass,
const CkCallback& cb);
1839 inline COOL* Cool() {
return dm->Cool;}
1840 inline LWDATA* LWData() {
return dm->LWData;}
1842 void initRand(
int iRand,
const CkCallback &cb);
1843 void FormStars(Stfm param,
double dTime,
double dDelta,
double dCosmoFac,
1844 const CkCallback& cb);
1847 void Feedback(
const Fdbk &fb,
double dTime,
double dDelta,
1848 const CkCallback& cb);
1851 void delEjected(
double dDelDist,
const CkCallback& cb);
1852 void getNearCollPartners(
const CkCallback& cb);
1853 void getCollInfo(
const CkCallback& cb);
1854 void getCollInfo(int64_t iOrder,
const CkCallback& cb);
1855 void logOverlaps(
const CkCallback& cb);
1856 void resolveCollision(Collision coll,
const ColliderInfo &c1,
const ColliderInfo &c2,
1857 double baseStep,
double timeNow,
double dCentMass,
const CkCallback& cb);
1858 void sameHigherRung(int64_t iord1,
int rung1, int64_t iord2,
int rung2,
const CkCallback& cb);
1859 void resolveWallCollision(Collision coll,
const ColliderInfo &c1,
const CkCallback& cb);
1860 void unKickCollStep(
int iKickRung,
double dDeltaBase,
const CkCallback& cb);
1861 void placeOnCollRung(int64_t iOrder,
int collStepRung,
const CkCallback& cb);
1862 void resetRungs(
const CkCallback& cb);
1863 void getNeedCollStep(
int collStepRung,
const CkCallback& cb);
1866 struct SortStruct *ss,
int nss,
int *pniOrder,
int *pnSet);
1867 void setTypeFromFile(
int iSetMask,
char *file,
const CkCallback& cb);
1868 void getCOM(
const CkCallback& cb,
int bLiveViz);
1869 void getCOMByType(
int iType,
const CkCallback& cb,
int bLiveViz);
1870 void DumpFrame(InDumpFrame in,
const CkCallback& cb,
int liveVizDump) ;
1871 void liveVizDumpFrameInit(liveVizRequestMsg *msg);
1872 void setProjections(
int bOn);
1883 void recvBoundary(SFC::Key key,
NborDir dir);
1884 void recvdBoundaries(CkReductionMsg* m);
1888 void startORBTreeBuild(CkReductionMsg* m);
1889 OrientedBox<float> constructBoundingBox(GenericTreeNode *node,
int level,
int numChild);
1890 void buildORBTree(GenericTreeNode * node,
int level);
1898 int firstParticle,
int numParticles,
int remIdx,
1899 const MultipoleMoments& moments,
const OrientedBox<double>& box,
1900 const OrientedBox<double>& boxBall,
1901 const unsigned int iParticleTypes,
const int64_t nSPH);
1912 intptr_t d_localParts,
1913 intptr_t d_localVars,
1914 intptr_t streams,
int numStreams,
1915 size_t sMoments,
size_t sCompactParts,
size_t sVarParts);
1925 void executeCkLoopParallelization(
LoopParData *lpdata,
int startbucket,
1926 int yield_num,
int chunkNum, State* gravityState);
1927 int doBookKeepingForTargetActive(
int curbucket,
int end,
int chunkNum,
bool
1928 updatestate, State* gravityState);
1929 int doBookKeepingForTargetInactive(
int chunkNum,
bool updatestate,
1930 State* gravityState);
1934 void calculateReSmoothLocal();
1935 void calculateMarkSmoothLocal();
1936 void nextBucketSmooth(dummyMsg *msg);
1937 void nextBucketReSmooth(dummyMsg *msg);
1938 void nextBucketMarkSmooth(dummyMsg *msg);
1939#if INTERLIST_VER > 0
1941 void calculateForceRemoteBucket(
int bucketIndex,
int chunk);
1942 void calculateForceLocalBucket(
int bucketIndex);
1951 void startGravity(
int am,
int bUseCpu_,
double myTheta,
const CkCallback& cb);
1961 void startSmooth(SmoothParams *p,
int iLowhFix,
int nSmooth,
1962 double dfBall2OverSoft2,
const CkCallback &cb);
1963 void startReSmooth(SmoothParams *p,
const CkCallback& cb);
1964 void startMarkSmooth(SmoothParams *p,
const CkCallback& cb);
1969 GenericTreeNode*
requestNode(
int remoteIndex, Tree::NodeKey lookupKey,
1970 int chunk,
int reqID,
int awi,
void *source);
1979 void receiveNode(GenericTreeNode &node,
int chunk,
unsigned int reqID);
1982 const GenericTreeNode*
lookupNode(Tree::NodeKey key);
1998#if INTERLIST_VER > 0
2000 int level,
int chunk);
2002 int level,
int chunk);
2006 int remoteIndex,
int begin,
2007 int end,
int reqID,
int awi,
2010 int remoteIndex,
int begin,
int end,
2011 int reqID,
int awi,
void *source);
2012 void fillRequestParticles(CkCacheRequestMsg<KeyType> *msg);
2013 void fillRequestSmoothParticles(CkCacheRequestMsg<KeyType> *msg);
2015 void processReqSmoothParticles();
2017 void startlb(
const CkCallback &cb,
int activeRung,
bool bDoLB);
2019 void populateSavedPhaseData(
int phase,
double tpload,
unsigned int activeparts);
2020 bool havePhaseData(
int phase);
2021 void savePhaseData(std::vector<double> &loads, std::vector<unsigned int>
2022 &parts_per_phase,
double* shuffleloads,
unsigned int *shuffleparts,
2024 void ResumeFromSync();
2027 const CkCallback& cb);
2028 void oneNodeOutVec(
OutputParams& params, Vector3D<double>* avOut,
2029 int nPart,
int iIndex,
int bDone,
2030 const CkCallback& cb) ;
2031 void oneNodeOutArr(
OutputParams& params,
double* adOut,
2032 int nPart,
int iIndex,
int bDone,
2033 const CkCallback& cb) ;
2034 void oneNodeOutIntArr(
OutputParams& params,
int *aiOut,
2035 int nPart,
int iIndex,
const CkCallback& cb);
2037 const CkCallback& cb);
2039 void minmaxNCOut(
OutputParams& params,
const CkCallback& cb);
2041 void outputStatistics(
const CkCallback& cb);
2053 void nextBucketUsingCkLoop(
dummyMsg *m);
2058 void pup(PUP::er& p);
2064 inline Vector3D<cosmoType> decodeOffset(
int reqID) {
2065 int offsetcode = reqID >> 22;
2066 int x = (offsetcode & 0x7) - 3;
2067 int y = ((offsetcode >> 3) & 0x7) - 3;
2068 int z = ((offsetcode >> 6) & 0x7) - 3;
2070 Vector3D<cosmoType> offset(x*fPeriod.x, y*fPeriod.y, z*fPeriod.z);
2075 void receiveNodeCallback(GenericTreeNode *node,
int chunk,
int reqID,
int awi,
void *source);
2076 void receiveParticlesCallback(ExternalGravityParticle *egp,
int num,
int chunk,
int reqID, Tree::NodeKey &remoteBucket,
int awi,
void *source);
2077 void receiveParticlesFullCallback(GravityParticle *egp,
int num,
int chunk,
int reqID, Tree::NodeKey &remoteBucket,
int awi,
void *source);
2079 void balanceBeforeInitialForces(
const CkCallback &cb);
2084 void sendRequestForNonLocalMoments(GenericTreeNode *pickedNode);
2085 void mergeNonLocalRequestsDone();
2087 std::map<NodeKey,NonLocalMomentsClientList>::iterator createTreeBuildMomentsEntry(GenericTreeNode *pickedNode);
2092 std::map<NodeKey,NonLocalMomentsClientList> nonLocalMomentsClients;
2093 bool localTreeBuildComplete;
2094 int getResponsibleIndex(
int first,
int last);
2097 GenericTreeNode *boundaryParentReady(GenericTreeNode *parent);
2098 void accumulateMomentsFromChild(GenericTreeNode *parent, GenericTreeNode *child);
2100 void deliverMomentsToClients(GenericTreeNode *);
2101 void deliverMomentsToClients(
const std::map<NodeKey,NonLocalMomentsClientList>::iterator &it);
2102 void treeBuildComplete();
2103 void processRemoteRequestsForMoments();
2104 void sendParticlesDuringDD(
bool withqd);
2105 void mergeAllParticlesAndSaveCentroid();
2106 bool otherIdlePesAvail();
2112class LvArray :
public CBase_LvArray {
2115 LvArray(CkMigrateMessage* m) {}
2124#ifdef REDUCTION_HELPER
2126class TreePieceCounter :
public CkLocIterator {
2128 TreePieceCounter() { reset(); }
2129 void addLocation(CkLocation &loc);
2133 CkVec<TreePiece *> presentTreePieces;
2138class ReductionHelper :
public CBase_ReductionHelper {
2141 ReductionHelper(CkMigrateMessage *);
2142 void pup(PUP::er &p);
2144 void countTreePieces(
const CkCallback &cb);
2145 void reduceBinCounts(
int nBins, int64_t *binCounts,
const CkCallback &cb);
2146 void evaluateBoundaries(SFC::Key *keys,
const int n,
int isRefine,
const CkCallback& cb);
2147 void evaluateBoundaries(
const CkBitVector &binsToSplit,
const CkCallback& cb);
2150 void senseLocalTreePieces();
2154 CkVec<int64_t> myBinCounts;
2155 int numTreePiecesCheckedIn;
2157 TreePieceCounter localTreePieces;
2158 std::vector<SFC::Key> splitters;
2163class NonEmptyTreePieceCounter :
public CkLocIterator {
2165 NonEmptyTreePieceCounter() { reset(); }
2166 void addLocation(CkLocation &loc);
std::map< NodeKey, GenericTreeNode * > NodeLookupType
Definition GenericTreeNode.h:352
GenericTrees
Definition GenericTreeNode.h:995
void operator|(PUP::er &p, NodeType &nt)
PUP a NodeType.
Definition GenericTreeNode.h:1039
KeyType NodeKey
This key is the identification of a node inside the global tree, and it is unique for the node....
Definition GenericTreeNode.h:35
int decodeReqID(int)
Given a requestID, return the bucket number.
Definition TreePiece.cpp:3622
int verbosity
verbosity level. Higher is more verbose.
Definition ParallelGravity.cpp:66
bool bIsReplica(int reqID)
is this a periodic replica?
Definition TreePiece.cpp:3611
struct OffsetNodeStruct OffsetNode
Remote Cell interaction lists for all tree levels.
int DtToRung(double dDelta, double dTideal)
Given the size of the big step, and a desired timestep, return the rung of the largest timestep less ...
Definition ParallelGravity.h:390
double RungToDt(double dDelta, int iRung)
Given the size of the big step, and a rung, return the corresponding timestep size.
Definition ParallelGravity.h:404
struct particlesInfoR RemotePartInfo
Remote particles in an interaction list.
double PoverRhoFloorJeans(double dResolveJeans, GravityParticle *p)
Pressure floor to force Jeans length to be larger than the spatial resolution.
Definition ParallelGravity.h:414
int RungToSubsteps(int iRung)
Given a rung, return the number of substeps in one big step.
Definition ParallelGravity.h:383
void printGenericTree(GenericTreeNode *node, std::ostream &os)
Print a text version of a tree.
Definition TreePiece.cpp:6138
const int PHASE_FEEDBACK
slot in MultistepLB to hold feedback phase load information
Definition ParallelGravity.h:409
void CkMustAssert(bool cond, const char *err)
CkAssert() replacement works even in production mode.
Definition ParallelGravity.h:59
CkVec< UndecidedList > UndecidedLists
Vector of undecided lists, one for each level.
Definition ParallelGravity.h:658
LBStrategy
Load balancers that need the spatial information.
Definition ParallelGravity.h:69
const double GAMMA_JEANS
Adiabatic index to use with the Jeans pressure floor.
Definition ParallelGravity.h:436
struct particlesInfoL LocalPartInfo
Local particles in an interaction list.
CkQ< OffsetNode > CheckList
Queue of nodes to check for interactions.
Definition ParallelGravity.h:654
double dExtraStore
fraction of extra particle storage
Definition ParallelGravity.cpp:105
DomainsDec
Possible domain decomposition methods.
Definition ParallelGravity.h:90
const double ddTolerance
tolerance for unequal pieces in SFC based decompositions.
Definition ParallelGravity.h:108
unsigned int bucketSize
Definition ParallelGravity.cpp:130
int encodeOffset(int reqID, int x, int y, int z)
Given a bucket number and a periodic offset, encode these into one number.
Definition TreePiece.cpp:3631
CkVec< OffsetNode > UndecidedList
Vector of nodes that are undecided at this level.
Definition ParallelGravity.h:656
NborDir
Directions for sending boundaries.
Definition ParallelGravity.h:101
struct ewaldTable EWT
Coefficients for the Fourier space part of the Ewald sum.
struct LoopParDataStruct LoopParData
Data needed for the CkLoop intranode parallelization.
Object to bookkeep a Bucket Walk.
Definition GravityParticle.h:18
Used to pass information about collision partners between processes.
Definition collision.h:7
Base clase for all tree based computations.
Definition Compute.h:26
Class to count added and deleted particles.
Definition ParallelGravity.h:342
Definition DataManager.h:60
Cache interface to the Tree Nodes.
Definition CacheInterface.h:96
Cache interface to particles for the gravity calculation. This is a read-only cache of particles.
Definition CacheInterface.h:37
Cache interface to the particles for smooth calculations. This cache is a writeback cache.
Definition CacheInterface.h:73
Information needed to calculate gravity.
Definition GravityParticle.h:33
Fundamental type for a particle.
Definition GravityParticle.h:364
cosmoType fBall
Neighbor search radius for smoothing.
Definition GravityParticle.h:387
std::string getNCNextOutput(OutputParams ¶ms)
Definition InOutput.cpp:2043
void restart(CkCheckpointStatusMsg *msg)
Callback to restart simulation after a checkpoint or after writing a checkpoint.
Definition ParallelGravity.cpp:2860
void waitForGravity(const CkCallback &cb, double startTime, int activeRung)
wait for gravity in the case of concurrent SPH
Definition ParallelGravity.cpp:1641
void loadBalance(int iPhase)
Perform load balance.
Definition ParallelGravity.cpp:1939
void updateuDot(int iActiveRung, const double duKick[], const double dStartTime[], int bUpdateState, int bAll)
Update time derivative of thermal energy.
Definition ParallelGravity.cpp:2095
void countActive(int activeRung)
determine number of active particles in the given rung
Definition ParallelGravity.cpp:4151
void updateSoft()
Change the softening in comoving coordinates.
Definition ParallelGravity.cpp:4202
void AGORAfeedbackPreCheck(double dTime, double dDelta, double dTimeToSF)
This routine is called when AGORA feedback is enabled. It checks for any star particles that will hav...
Definition feedback.cpp:193
void restartGas()
Read in array files for complete gas information.
Definition Sph.cpp:342
void getStartTime()
determine start time of simulation
Definition ParallelGravity.cpp:1447
void buildTree(int iPhase)
Build Tree.
Definition ParallelGravity.cpp:1974
void doSinks(double dTime, double dDelta, int iKickRung)
Process sink particles.
Definition sinks.cpp:867
void memoryStatsCache()
Definition ParallelGravity.cpp:4464
void growMass(double dTime, double dDelta)
Slowly increase mass of a subset of particles.
Definition ParallelGravity.cpp:4219
void starCenterOfMass()
Main::starCenterOfMass Calculates the total mass and center of mass of all the star particles and sav...
Definition ParallelGravity.cpp:3457
void doSph(int activeRung, int bNeedDensity=1)
Perform the SPH force calculation.
Definition Sph.cpp:712
Main(CkArgMsg *m)
Main routine to start simulation.
Definition ParallelGravity.cpp:225
void niceExit()
entry method to cleanly shutdown. Only used for debugging.
Definition ParallelGravity.cpp:1438
void writeOutput(int iStep)
Output a snapshot.
Definition ParallelGravity.cpp:3664
void emergencyAdjust(int iRung)
Change timesteps of particles experiencing sudden gas forces.
Definition ParallelGravity.cpp:4175
int adjust(int iKickRung)
Calculate timesteps of particles.
Definition ParallelGravity.cpp:4070
void initialForces()
Initial calculation of forces.
Definition ParallelGravity.cpp:3008
int ReadASCII(char *extension, int nDataPerLine, double *dDataOut)
function from PKDGRAV to read an ASCII table
Definition Sph.cpp:182
void advanceBigStep(int)
Take one base timestep of the simulation.
Definition ParallelGravity.cpp:2195
int bOutTime()
Return true if we need to write an output.
Definition ParallelGravity.cpp:1545
void addDelParticles()
Coalesce all added and deleted particles and update global quantities.
Definition ParallelGravity.cpp:4404
void domainDecomp(int iPhase)
Perform domain decomposition.
Definition ParallelGravity.cpp:1897
void outputBlackHoles(double dTime)
Output black hole orbit information.
Definition sinks.cpp:227
void SetSink()
Initial identify sinks.
Definition sinks.cpp:298
void FormSinks(double dTime, double dDelta, int iKickRung)
Form sink particles; main routine.
Definition sinks.cpp:353
void memoryStats()
Definition ParallelGravity.cpp:4450
void FormStars(double dTime, double dDelta)
Definition starform.cpp:174
void getOutTimes()
Read in desired output times and reshifts from a file.
Definition ParallelGravity.cpp:1562
void cbIOComplete(CkMessage *msg)
All IO has completed. Close the file.
Definition InOutput.cpp:2150
void outputBinary(OutputParams ¶ms, int bParaWrite, const CkCallback &cb)
Output a Tipsy or NChilada XDR binary float array file.
Definition InOutput.cpp:1998
void externalForce(int iActiveRung)
Apply external gravitational field.
Definition ParallelGravity.cpp:2075
void doSIDM(double dTime, double dDelta, int activeRung)
Main method to perform Self Interacting Dark Matter interactions.
Definition SIDM.cpp:59
void startGravity(const CkCallback &cbGravity, int iActiveRung, double *startTime)
Routine to start self gravity; if gravity is not being calculated, then clear the accelerations.
Definition ParallelGravity.cpp:1999
void initSph()
initialize SPH quantities
Definition Sph.cpp:24
void doSimulation()
Principal method which does all the coordination of the simulation over timesteps.
Definition ParallelGravity.cpp:3106
void calcEnergy(double, double, const char *)
Calculate various energy and momentum quantities, and output them to a log file.
Definition ParallelGravity.cpp:3565
void cbIOClosed(CkMessage *msg)
File is closed. Update header for NChilada. Resume main program.
Definition InOutput.cpp:2158
void restartNSIDM()
Read in array files for SIDM interact count, if needed.
Definition SIDM.cpp:18
void setupICs()
Load particles into pieces.
Definition ParallelGravity.cpp:2465
void StellarFeedback(double dTime, double dDelta)
Definition feedback.cpp:270
void writeCollLog(const char *)
Write collision events in buffer to log file and clear the buffer.
Definition ParallelGravity.cpp:3540
void kick(bool bClosing, int iActiveRung, int nextMaxRung, const CkCallback &cbGravity, double gravStartTime)
Update velocities.
Definition ParallelGravity.cpp:2128
void cbIOReady(Ck::IO::SessionReadyMsg *msg)
Session is ready; write my data.
Definition InOutput.cpp:2143
void rungStats()
Count and print out the number of particles in each timestep bin.
Definition ParallelGravity.cpp:4131
void initCooling()
Initialize cooling constants and integration data structures.
Definition Sph.cpp:74
void cbOpen(Ck::IO::FileReadyMsg *msg)
Definition InOutput.cpp:2071
Class for new maxOrder broadcast.
Definition ParallelGravity.h:127
char * dim
Dimension of splits.
Definition ParallelGravity.h:298
int length
Number of splits.
Definition ParallelGravity.h:294
double * pos
Positions of splits.
Definition ParallelGravity.h:296
CkCallback cb
Callback for reduction of particle counts.
Definition ParallelGravity.h:300
Base class for optimizing walk actions.
Definition Opt.h:12
Base class for output parameters.
Definition InOutput.h:17
Message for shuffling particles during domain decomposition.
Definition ParallelGravity.h:307
basic random number generator This is implemented as an object so that it can easily be used in threa...
Definition rand.h:9
Super class for Smooth and Resmooth computation.
Definition smooth.h:79
A base class from which parameters for all smooth operations can be derived.
Definition smoothparams.h:9
Base class for maintaining the state of a tree walk.
Definition State.h:6
Fundamental structure that holds particle and tree data.
Definition ParallelGravity.h:755
void outputBinary(Ck::IO::Session, OutputParams ¶ms)
Output a Tipsy XDR binary float array file.
Definition InOutput.cpp:2298
void pup(PUP::er &p)
@TODO Fix pup routine to handle correctly the tree
Definition TreePiece.cpp:5782
void newParticle(GravityParticle *p)
add new particle
Definition TreePiece.cpp:2167
void flushStarLog(const CkCallback &cb)
flush starlog table to disk.
Definition starform.cpp:586
void Feedback(const Fdbk &fb, double dTime, double dDelta, const CkCallback &cb)
Definition feedback.cpp:382
void setNParts(int64_t _nTotalSPH, int64_t _nTotalDark, int64_t _nTotalStar, const CkCallback &cb)
Update total particle numbers.
Definition TreePiece.cpp:2347
const GravityParticle * lookupParticles(int begin)
Find the particles starting at "begin", and return a pointer to it.
Definition TreePiece.cpp:5558
void evaluateParticleCounts(ORBSplittersMsg *splittersMsg)
Evaluate particle counts for ORB decomposition.
Definition TreePiece.cpp:469
void EwaldGPU()
Transfer Ewald data to GPU memory and launch EwaldHost kernel.
Definition Ewald.cpp:387
void calculateRemoteMoments(GenericTreeNode *node)
void startRemoteChunk()
Start a new remote computation upon prefetch finished.
Definition TreePiece.cpp:5397
void adjustTreePointers(GenericTreeNode *node, GravityParticle *newParts)
Adjust particlePointer attribute of all the nodes in the tree.
Definition TreePiece.cpp:2151
void startOctTreeBuild(CkReductionMsg *m)
Real tree build, independent of other TreePieces.
Definition TreePiece.cpp:3022
int64_t nTotalStar
Total Star Particles.
Definition ParallelGravity.h:1119
void requestRemoteMoments(const Tree::NodeKey key, int sender)
Request the moments for this node.
Definition TreePiece.cpp:3358
void calculateGravityRemote(ComputeChunkMsg *msg)
Definition TreePiece.cpp:4310
void setupWrite(int iStage, u_int64_t iPrevOffset, const std::string &filename, const double dTime, const double dvFac, const double duTFac, const bool bDoublePos, const bool bDoubleVel, const int bCool, const CkCallback &cb)
Find starting offsets and begin parallel write.
Definition InOutput.cpp:1051
void getMaxIOrds(const CkCallback &cb)
return maximum iOrders. Like the above, but the file has already been read
Definition InOutput.cpp:338
void report()
Write a file containing a graphviz dot graph of my tree.
Definition TreePiece.cpp:6116
void initBuckets()
Definition TreePiece.cpp:3659
void outputBinaryStart(OutputParams ¶ms, int64_t nStart, const CkCallback &cb)
Determine start offsets for this piece based on previous pieces.
Definition InOutput.cpp:2115
void finalizeBoundaries(ORBSplittersMsg *splittersMsg)
Determine my boundaries at the end of ORB decomposition.
Definition TreePiece.cpp:405
void finishSmoothWalk()
Called when smooth walk on all TreePieces is done.
Definition smooth.cpp:702
void startNextBucket()
Start the treewalk for the next bucket among those belonging to me. The buckets are simply ordered in...
Definition TreePiece.cpp:3702
void readTipsyArray(OutputParams ¶ms, const CkCallback &cb)
read a tipsy array file (binary or ascii)
Definition InOutput.cpp:355
void startSmooth(SmoothParams *p, int iLowhFix, int nSmooth, double dfBall2OverSoft2, const CkCallback &cb)
Definition smooth.cpp:339
void SetSink(double dSinkMassMin, const CkCallback &cb)
set sink type based on formation time.
Definition sinks.cpp:313
void addToNodeInterRemote(int chunk, int howmany)
accumulate node interaction count for statistics
Definition ParallelGravity.h:860
void initBeforeORBSend(unsigned int myCount, unsigned int myCountGas, unsigned int myCountStar, const CkCallback &cb, const CkCallback &cback)
Definition TreePiece.cpp:244
GenericTreeNode * requestNode(int remoteIndex, Tree::NodeKey lookupKey, int chunk, int reqID, int awi, void *source)
Retrieve the remote node, goes through the cache if present.
Definition TreePiece.cpp:5562
GenericTreeNode * getStartAncestor(int current, int previous, GenericTreeNode *dflt)
return the largest node which contains current bucket, but which does not contain previous bucket....
Definition TreePiece.cpp:4757
void startGravity(int am, int bUseCpu_, double myTheta, const CkCallback &cb)
Start a tree based gravity computation.
Definition TreePiece.cpp:5023
void checkTree(GenericTreeNode *node)
Definition TreePiece.cpp:5930
void initRand(int iRand, const CkCallback &cb)
initialize random seed for star formation
Definition starform.cpp:165
void startlb(const CkCallback &cb, int activeRung, bool bDoLB)
Save piece loads and call AtSync() if we should load balance.
Definition TreePiece.cpp:5490
void assignKeys(CkReductionMsg *m)
After the bounding box has been found, we can assign keys to the particles.
Definition TreePiece.cpp:126
void printTreeViz(GenericTreeNode *node, std::ostream &os)
Print a graphviz version of A tree.
Definition TreePiece.cpp:6061
int64_t nTotalDark
Total Dark Particles.
Definition ParallelGravity.h:1117
void initORBPieces(const CkCallback &cb)
Initialize stuff before doing ORB decomposition.
Definition TreePiece.cpp:205
void formSinks(int bJeans, double dJConst2, int bDensity, double dDensityCut, double dTime, int iKickRung, int bSimple, const CkCallback &cb)
Form sink particles: per processor routine.
Definition sinks.cpp:420
void getBucketsBeneathBounds(GenericTreeNode *&node, int &start, int &end)
get range of bucket numbers beneath a given TreeNode.
Definition TreePiece.cpp:6463
void commenceCalculateGravityLocal()
Entry method wrapper for calculateGravityLocal If using the GPU, this TreePiece is assigned a cudaStr...
Definition TreePiece.cpp:5387
void addToNodeInterLocal(int howmany)
accumulate node interaction count for statistics
Definition ParallelGravity.h:870
void readFloatBinary(OutputParams ¶ms, int bParaRead, const CkCallback &cb)
Definition InOutput.cpp:960
void physicalSoft(const double dSoftMax, const double dFac, const int bSoftMaxMul, const CkCallback &cb)
Adjust comoving softening to maintain constant physical softening.
Definition TreePiece.cpp:2373
void flushHMStarLog(const CkCallback &cb)
flush hmstarlog table to disk
Definition starform.cpp:606
void receiveRemoteMoments(const Tree::NodeKey key, Tree::NodeType type, int firstParticle, int numParticles, int remIdx, const MultipoleMoments &moments, const OrientedBox< double > &box, const OrientedBox< double > &boxBall, const unsigned int iParticleTypes, const int64_t nSPH)
response from requestRemoteMoments
Definition TreePiece.cpp:3428
void loadTipsy(const std::string &filename, const double dTuFac, const bool bDoublePos, const bool bDoubleVel, const CkCallback &cb)
Load I.C. from Tipsy file.
Definition InOutput.cpp:183
void addToParticleInterRemote(int chunk, int howmany)
accumulate particle interaction count for statistics
Definition ParallelGravity.h:865
void setTreePieceLoad(int activeRung)
Sets the load of the TreePiece object based on the rung.
Definition TreePiece.cpp:5466
void calculateSmoothLocal()
As above but for the Smooth operation.
Definition smooth.cpp:413
void countType(int iType, const CkCallback &cb)
count total number of particles of given type
Definition TreePiece.cpp:1956
void continueStartRemoteChunk(int chunk)
Main work of StartRemoteChunk() Schedule a TreePiece::calculateGravityRemote() then start prefetching...
Definition TreePiece.cpp:5428
void fillRequestNode(CkCacheRequestMsg< KeyType > *msg)
Receive a request for Nodes from a remote processor, copy the data into it, and send back a message.
Definition CacheInterface.cpp:440
void markSmoothWalkDone()
Called when smooth walk on the current TreePiece is done.
Definition smooth.cpp:694
GravityParticle * getParticles()
Return the pointer to the particles on this TreePiece.
Definition ParallelGravity.h:891
void parallelWrite(int iPass, const CkCallback &cb, const std::string &filename, const double dTime, const double dvFac, const double duTFac, const bool bDoublePos, const bool bDoubleVel, const int bCool)
Control the parallelism in the tipsy output by breaking it up into nIOProcessor pieces.
Definition InOutput.cpp:1115
void nextBucket(dummyMsg *m)
Entry method used to split the processing of all the buckets in small pieces. It calls startNextBucke...
Definition TreePiece.cpp:3983
void finishWalk()
Called when walk on all TreePieces is done.
Definition TreePiece.cpp:6431
void ioAcceptSortedParticles(ParticleShuffleMsg *)
Accept particles from other TreePieces once the sorting has finished.
Definition InOutput.cpp:1629
void colNParts(const CkCallback &cb)
Count add/deleted particles, and compact main particle storage.
Definition TreePiece.cpp:2245
bool nodeOwnership(const Tree::NodeKey nkey, int &firstOwner, int &lastOwner)
Definition TreePiece.cpp:3236
void deleteTree()
delete treenodes if allocated
Definition ParallelGravity.h:1380
bool(* compFuncPtr[3])(GravityParticle, GravityParticle)
Array of comparison function pointers.
Definition ParallelGravity.h:1349
void updateuDot(int activeRung, double duDelta[MAXRUNG+1], double dStartTime[MAXRUNG+1], int bCool, int bAll, int bUpdateState, double gammam1, double dResolveJeans, const CkCallback &cb)
Update the cooling rate (uDot)
Definition Sph.cpp:860
void resetMetals(const CkCallback &cb)
Set total metals based on Ox and Fe mass fractions.
Definition Sph.cpp:322
double dStartTime
Time read in from input file.
Definition ParallelGravity.h:1066
void newOrder(const NewMaxOrder *nStarts, const int n, int bUseStoch, const CkCallback &cb)
Assign iOrders to recently added particles.
Definition TreePiece.cpp:2299
void FormStars(Stfm param, double dTime, double dDelta, double dCosmoFac, const CkCallback &cb)
Definition starform.cpp:219
void serialWrite(u_int64_t iPrevOffset, const std::string &filename, const double dTime, const double dvFac, const double duTFac, const bool bDoublePos, const bool bDoubleVel, const int bCool, const CkCallback &cb)
Serial output of tipsy file.
Definition InOutput.cpp:1160
int64_t nTotalSPH
Total Gas Particles.
Definition ParallelGravity.h:1115
void collectStatistics(const CkCallback &cb)
Collect the total statistics from the various chares.
Definition TreePiece.cpp:6197
void evaluateBoundaries(SFC::Key *keys, const int n, int isRefine, const CkCallback &cb)
Definition TreePiece.cpp:592
void loadNChilada(const std::string &filename, const double dTuFac, const CkCallback &cb)
Load I.C. from NChilada file.
Definition InOutput.cpp:843
void emergencyAdjust(int iRung, double dDelta, double dDeltaThresh, const CkCallback &cb)
Look for gas particles reporting small new timesteps and move their timesteps down,...
Definition TreePiece.cpp:1976
void doAllBuckets()
Start a full step of bucket computation, it sends a message to trigger nextBucket() which will loop o...
Definition TreePiece.cpp:3939
void printTree(GenericTreeNode *node, std::ostream &os)
Print a text version of a tree.
Definition TreePiece.cpp:6005
void EwaldGPUComplete()
Callback for EwaldGPU. Clean up device memory + host buffer and call finishBucket.
Definition Ewald.cpp:533
void truncateRung(int iCurrMaxRung, const CkCallback &cb)
Truncate the highest rung.
Definition TreePiece.cpp:1911
GenericTreeNode * keyToNode(const Tree::NodeKey k)
convert a key to a node using the nodeLookupTable
Definition ParallelGravity.h:1055
bool sendFillReqNodeWhenNull(CkCacheRequestMsg< KeyType > *msg)
When the node is found to be NULL, forward the request.
Definition TreePiece.cpp:3300
void unshuffleParticles(CkReductionMsg *m)
Definition TreePiece.cpp:1006
void externalForce(int activeRung, const ExternalForce &exForce, int bKepStep, const CkCallback &cb)
Apply an external force.
Definition externalForce.cpp:111
void acceptSortedParticles(ParticleShuffleMsg *)
Accept particles from other TreePieces once the sorting has finished.
Definition TreePiece.cpp:1183
void outputBlackHoles(const std::string &pszFileName, double dvFac, long lFPos, const CkCallback &cb)
processor specific routine to output black hole orbits.
Definition sinks.cpp:263
void ioShuffle(CkReductionMsg *msg)
Perform the shuffle for reOrder.
Definition InOutput.cpp:1525
void addToParticleInterLocal(int howmany)
accumulate particle interaction count for statistics
Definition ParallelGravity.h:875
int getNumParticles()
Return the number of particles on this TreePiece.
Definition ParallelGravity.h:886
void SinkStep(int iCurrSinkRung, int iKickRung, const CkCallback &cb)
set sink timesteps.
Definition sinks.cpp:333
void cachedWalkBucketTree(GenericTreeNode *node, int chunk, int reqID)
Routine which does the tree walk on non-local nodes. It is called back for every incoming node (which...
void massMetalsEnergyCheck(int bPreDist, const CkCallback &cb)
total feedback quantities for conservation check
Definition feedback.cpp:1125
void buildTree(int bucketSize, const CkCallback &cb)
Charm entry point to build the tree (called by Main).
Definition TreePiece.cpp:2621
void calculateGravityLocal()
This function could be replaced by the doAllBuckets() call.
Definition TreePiece.cpp:4185
void initiatePrefetch(int chunk)
Definition TreePiece.cpp:5335
void reOrder(int64_t nMaxOrder, const CkCallback &cb)
Reorder particles for output.
Definition InOutput.cpp:1478
void oneNodeWrite(int iIndex, int iOutParticles, int iOutSPH, int iOutStar, GravityParticle *particles, extraSPHData *pGas, extraStarData *pStar, int *piSPH, int *piStar, const u_int64_t iPrevOffset, const std::string &filename, const double dTime, const double dvFac, const double duTFac, const bool bDoublePos, const bool bDoubleVel, const int bCool, const CkCallback &cb)
write out the particles I have been sent
Definition InOutput.cpp:1214
void markWalkDone()
Called when walk on the current TreePiece is done.
Definition TreePiece.cpp:6412
void setupSmooth()
Setup utility function for all the smooths. Initializes caches.
Definition smooth.cpp:316
void SetTypeFromFileSweep(int iSetMask, char *file, struct SortStruct *ss, int nss, int *pniOrder, int *pnSet)
Read file of iOrders to set particle type.
Definition TreePiece.cpp:2481
void initCoolingData(const CkCallback &cb)
Definition Sph.cpp:153
void resetObjectLoad(const CkCallback &cb)
Set the load balancing data after a restart from checkpoint.
Definition TreePiece.cpp:697
void calculateEwald(EwaldMsg *m)
Start the ewald calculation on this TreePiece.
Definition TreePiece.cpp:4223
const GenericTreeNode * lookupNode(Tree::NodeKey key)
Receive the node from the cache as following a previous request which returned NULL,...
Definition TreePiece.cpp:5554
void finishNodeCache(const CkCallback &cb)
We are done with the node Cache.
Definition TreePiece.cpp:4780
void flushSmoothParticles(CkCacheFillMsg< KeyType > *msg)
Definition CacheInterface.cpp:310
void finishBucket(int iBucket)
Check if we have done with the treewalk on a specific bucket, and if we have, check also if we are do...
Definition TreePiece.cpp:3793
void assignDomain(const CkCallback &cb)
assign domain number to each particle for diagnostic
Definition TreePiece.cpp:2016
void setSoft(const double dSoft, const CkCallback &cb)
Set the gravitational softening on all particles.
Definition TreePiece.cpp:2359
int64_t nTotalParticles
Total Particles in the simulation.
Definition ParallelGravity.h:1113
void adjust(int iKickRung, int bEpsAccStep, int bGravStep, int bSphStep, int bViscosityLimitdt, double dEta, double dEtaCourant, double dEtauDot, double dDiffCoeff, double dEtaDiffusion, double dDelta, double dAccFac, double dCosmoFac, double dhMinOverSoft, double dResolveJeans, int bDoGas, const CkCallback &cb)
Definition TreePiece.cpp:1736
Base class for walking trees.
Definition TreeWalk.h:11
Base class for tree nodes.
Definition GenericTreeNode.h:59
int rungs
Definition GenericTreeNode.h:122
int lastParticle
An index to the last particle contained by this node, myNumParticles+1 means outside the node.
Definition GenericTreeNode.h:108
GravityParticle * particlePointer
Pointer to the first particle in this node.
Definition GenericTreeNode.h:117
int firstParticle
An index for the first particle contained by this node, 0 means outside the node.
Definition GenericTreeNode.h:106
Utility to pool allocations of tree nodes.
Definition GenericTreeNode.h:332
Message to efficiently start entry methods with no arguments.
Definition ParallelGravity.h:213
struct CompactPartData CompactPartData
Particle data needed on the GPU to calculate gravity.
Particle data needed on the GPU to calculate gravity.
Definition cuda_typedef.h:240
Version of MultipoleMoments using cudatype.
Definition cuda_typedef.h:104
Global simulation parameters for dumpframe.
Definition dumpframe.h:209
structure to hold information specific to GPU Ewald
Definition EwaldCUDA.h:51
Definition ParallelGravity.h:336
Data needed for the CkLoop intranode parallelization.
Definition ParallelGravity.h:693
CkVec< CkVec< RemotePartInfo > > rpilists
Remote particle interactions.
Definition ParallelGravity.h:699
CkVec< CkVec< OffsetNode > > clists
Cell interactions.
Definition ParallelGravity.h:698
CkVec< int > chunkids
remote walk chunk number
Definition ParallelGravity.h:697
CkVec< CkVec< LocalPartInfo > > lpilists
Local particle interactions.
Definition ParallelGravity.h:700
CkVec< int > bucketids
startBucket number
Definition ParallelGravity.h:696
TreePiece * tp
Treepiece that owns this data.
Definition ParallelGravity.h:701
CkVec< GenericTreeNode * > lowNodes
Definition ParallelGravity.h:694
client that has requested a moment.
Definition ParallelGravity.h:721
Remote Cell interaction lists for all tree levels.
Definition ParallelGravity.h:647
Particle data that gets calculated by the GPU.
Definition cuda_typedef.h:268
Coefficients for the Fourier space part of the Ewald sum.
Definition ParallelGravity.h:636
Local particles in an interaction list.
Definition ParallelGravity.h:675
Remote particles in an interaction list.
Definition ParallelGravity.h:662