14#include "ParallelGravity.decl.h"
17#if CHARM_VERSION > 60401 && CMK_BALANCED_INJECTION_API
18#include "ckBIconfig.h"
22struct TreePieceDescriptor{
26 TreePieceDescriptor(){}
27 TreePieceDescriptor(
TreePiece *tp_, GenericTreeNode *r){
35struct UpdateParticlesStruct{
44struct PendingBuffers {
45 CkVec<CudaMultipoleMoments> *moments;
46 CkVec<CompactPartData> *particles;
60class DataManager :
public CBase_DataManager {
61 friend class TreePiece;
62 friend class OctTreeBuildPhaseIWorker;
65 CProxy_TreePiece treePieces;
85 int cumNumReplicatedNodes;
88 int treePiecesDonePrefetch;
89 int treePiecesDoneLocalComputation;
92 int treePiecesDoneRemoteChunkComputation;
93 int treePiecesWantParticlesBack;
96 int treePiecesParticlesUpdated;
97 int savedNumTotalParticles;
98 int savedNumTotalNodes;
107 std::map<NodeKey, int> cachedPartsOnGpu;
112 int treePiecesBufferFilled;
118 CkCallback *localTransferCallback;
120 PendingBuffers *currentChunkBuffers;
122 CkQ<PendingBuffers *> pendingChunkTransferQ;
125 int lastChunkMoments;
126 int lastChunkParticles;
133 CkVec<CudaMultipoleMoments> localMoments;
148 size_t sCompactParts;
152 cudaStream_t *streams;
189 DataManager(
const CkArrayID& treePieceID);
190 DataManager(CkMigrateMessage *);
192 void startLocalWalk();
193 void resumeRemoteChunk();
195 void createStreams(
int _numStreams,
const CkCallback& cb);
196 void donePrefetch(
int chunk);
197 void serializeLocalTree();
199#ifdef GPU_LOCAL_TREE_WALK
200 void transformLocalTreeRecursive(GenericTreeNode *node, CkVec<CudaMultipoleMoments>& localMoments);
204 PendingBuffers *serializeRemoteChunk(GenericTreeNode *);
205 void serializeLocal(GenericTreeNode *);
206 void transferLocalToGPU(
int nParts, GenericTreeNode *node);
207 void freeLocalTreeMemory();
208 void freeRemoteChunkMemory(
int chunk);
209 void transferParticleVarsBack();
210 void updateParticles(UpdateParticlesStruct *data);
211 void updateParticlesFreeMemory(UpdateParticlesStruct *data);
212 void initiateNextChunkTransfer();
223 for (
unsigned int i = 0; i <
nodeTable.length(); i++) {
229 LymanWernerTableFinalize(LWData);
235 for (
int i = 0; i < numStreams; i++) {
236 cudaStreamDestroy(streams[i]);
245 const CkCallback& cb);
254 void acceptFinalKeys(
const SFC::Key* keys,
const int* responsible, uint64_t* bins,
const int n,
const CkCallback& cb);
255 void pup(PUP::er& p);
263 std::map<NodeKey, int> &getCachedPartsOnGpuTable(){
264 return cachedPartsOnGpu;
270 Tree::GenericTreeNode *buildProcessorTree(
int n, Tree::GenericTreeNode **gtn);
271 int createLookupRoots(Tree::GenericTreeNode *node, Tree::NodeKey *keys);
281 void getChunks(
int &num, Tree::NodeKey *&roots);
282 inline Tree::GenericTreeNode *chunkRootToNode(
const Tree::NodeKey k) {
287 inline Tree::GenericTreeNode *getRoot() {
return root; }
288 void initCooling(
double dGmPerCcUnit,
double dComovingGmPerCcUnit,
289 double dErgPerGmUnit,
double dSecUnit,
double dKpcUnit,
290 COOLPARAM inParam,
const CkCallback& cb);
291 void initStarLog(std::string _fileName,
const CkCallback &cb);
292 void initLWData(
const CkCallback& cb);
293 void initHMStarLog(std::string _fileName,
const CkCallback &cb);
294 void dmCoolTableRead(
double *dTableData,
int nData,
const CkCallback& cb);
295 void CoolingSetTime(
double z,
297 const CkCallback& cb);
298 void SetStarCM(
double dCenterOfMass[4],
const CkCallback& cb);
299 void memoryStats(
const CkCallback& cb);
300 void resetReadOnly(Parameters param,
const CkCallback &cb);
303 static Tree::GenericTreeNode *
pickNodeFromMergeList(
int n, GenericTreeNode **gtn,
int &nUnresolved,
int &pickedIndex);
306inline static void setBIconfig()
308#if CHARM_VERSION > 60401 && CMK_BALANCED_INJECTION_API
310#define GNI_BI_DEFAULT 64
311 uint16_t cur_bi = ck_get_GNI_BIConfig();
312 if (cur_bi > GNI_BI_DEFAULT) {
313 ck_set_GNI_BIConfig(GNI_BI_DEFAULT);
317 CkPrintf(
"Balanced injection is set to %d.\n", ck_get_GNI_BIConfig());
326class ProjectionsControl :
public CBase_ProjectionsControl {
328 ProjectionsControl() {
335 cudaGetDeviceCount(&numGpus);
336 cudaSetDevice(CmiMyNode() % numGpus);
340#ifndef LB_MANAGER_VERSION
346 ProjectionsControl(CkMigrateMessage *m) : CBase_ProjectionsControl(m) {
349#ifndef LB_MANAGER_VERSION
356 void on(CkCallback cb) {
358 CkPrintf(
"\n\n**** PROJECTIONS ON *****\n\n");
364 void off(CkCallback cb) {
366 CkPrintf(
"\n\n**** PROJECTIONS OFF *****\n\n");
372 void pup(PUP::er &p){
373 CBase_ProjectionsControl::pup(p);
std::map< NodeKey, GenericTreeNode * > NodeLookupType
Definition GenericTreeNode.h:352
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
Definition DataManager.h:60
std::vector< int > responsibleIndex
An array identifying which chare is responsible for each interval of keys.
Definition DataManager.h:73
void acceptResponsibleIndex(const int *responsible, const int n, const CkCallback &cb)
Definition DataManager.cpp:69
Tree::GenericTreeNode * root
The root of the combined trees.
Definition DataManager.h:156
Tree::NodeKey * chunkRoots
Nodes currently used as roots for remote computation.
Definition DataManager.h:164
CkVec< TreePieceDescriptor > registeredTreePieces
A list of roots of the TreePieces in this node.
Definition DataManager.h:80
int oldNumChunks
Number of chunks in which the tree was splitted during last combine operation.
Definition DataManager.h:162
static Tree::GenericTreeNode * pickNodeFromMergeList(int n, GenericTreeNode **gtn, int &nUnresolved, int &pickedIndex)
Pick a node out of equivalent nodes on different TreePieces. If one of the nodes is internal to a Tre...
Definition DataManager.cpp:268
void combineLocalTrees(CkReductionMsg *msg)
Build a local tree inside the node.
Definition DataManager.cpp:178
void notifyPresence(Tree::GenericTreeNode *root, TreePiece *treePiece)
Collect roots of treepieces on this node.
Definition DataManager.cpp:151
Tree::NodeLookupType chunkRootTable
Lookup table for the chunkRoots.
Definition DataManager.h:166
CmiNodeLock lockHMStarLog
Lock for accessing hmstarlog from TreePieces.
Definition DataManager.h:187
CmiNodeLock lockStarLog
Lock for accessing starlog from TreePieces.
Definition DataManager.h:185
void getChunks(int &num, Tree::NodeKey *&roots)
return the number of chunks and the roots of the remote walk subtrees.
Definition DataManager.cpp:420
std::vector< int > particleCounts
An array with how many particles are held by each TreePiece when sorted.
Definition DataManager.h:76
std::vector< SFC::Key > boundaryKeys
The array of splitter keys for the sort.
Definition DataManager.h:70
void initCooling(double dGmPerCcUnit, double dComovingGmPerCcUnit, double dErgPerGmUnit, double dSecUnit, double dKpcUnit, COOLPARAM inParam, const CkCallback &cb)
Definition Sph.cpp:136
void SetStarCM(double dCenterOfMass[4], const CkCallback &cb)
DataManager::SetStarCM saves the total mass and center of mass of the star(s) to the COOL struct Cool...
Definition Sph.cpp:281
CkVec< GenericTreeNode * > nodeTable
Definition DataManager.h:159
StarLog * starLog
log of star formation events.
Definition DataManager.h:182
void clearRegisteredPieces(const CkCallback &cb)
Clear registeredTreePieces on this node.
Definition DataManager.cpp:165
void acceptFinalKeys(const SFC::Key *keys, const int *responsible, uint64_t *bins, const int n, const CkCallback &cb)
Definition DataManager.cpp:76
Log of high mass stars in star formation events to be written out to a file.
Definition starform.h:215
Log of star formation events to be written out to a file.
Definition starform.h:193
Fundamental structure that holds particle and tree data.
Definition ParallelGravity.h:755
Base class for tree nodes.
Definition GenericTreeNode.h:59
Particle data needed on the GPU to calculate gravity.
Definition cuda_typedef.h:240
Version of MultipoleMoments using cudatype.
Definition cuda_typedef.h:104
Particle data that gets calculated by the GPU.
Definition cuda_typedef.h:268