Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make boundingBox of type cosmoType. #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ParallelGravity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ class TreePiece : public CBase_TreePiece {

std::string basefilename;
// Bounding box of the entire simulation
OrientedBox<float> boundingBox;
OrientedBox<cosmoType> boundingBox;
unsigned iterationNo;
/// The root of the global tree, always local to any chare
GenericTreeNode* root;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ class TreePiece : public CBase_TreePiece {

///Keeps track of the bounding boxes and dimensions along which they are splitted, starting from
///root to chunkRootLevel
OrientedBox<float>* boxes;
OrientedBox<cosmoType>* boxes;
char* splitDims;

///Phase of ORB decomposition: the number of boxes double in each phase till they are equal to the number
Expand Down Expand Up @@ -1813,7 +1813,7 @@ class TreePiece : public CBase_TreePiece {
/********ORB Tree**********/
//void receiveBoundingBoxes(BoundingBoxes *msg);
void startORBTreeBuild(CkReductionMsg* m);
OrientedBox<float> constructBoundingBox(GenericTreeNode *node,int level, int numChild);
OrientedBox<cosmoType> constructBoundingBox(GenericTreeNode *node,int level, int numChild);
void buildORBTree(GenericTreeNode * node, int level);
/**************************/

Expand Down
4 changes: 3 additions & 1 deletion Reductions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

CkReduction::reducerType growOrientedBox_float;
CkReduction::reducerType growOrientedBox_double;
CkReduction::reducerType growOrientedBox_cosmoType;

CkReduction::reducerType minmax_int;
CkReduction::reducerType minmax_long;
Expand Down Expand Up @@ -114,14 +115,15 @@ CkReductionMsg* dfImageReducer(int nMsg, CkReductionMsg** msgs) {
void registerReductions() {
growOrientedBox_float = CkReduction::addReducer(boxGrowth<float>);
growOrientedBox_double = CkReduction::addReducer(boxGrowth<double>);
growOrientedBox_cosmoType = CkReduction::addReducer(boxGrowth<cosmoType>);

minmax_int = CkReduction::addReducer(minmax<int>);
minmax_long = CkReduction::addReducer(minmax<int64_t>);
minmax_float = CkReduction::addReducer(minmax<float>);
minmax_double = CkReduction::addReducer(minmax<double>);
max_count = CkReduction::addReducer(max_count_reduce);
callbackReduction = CkReduction::addReducer(same<CkCallback>);
boxReduction = CkReduction::addReducer(same<OrientedBox<float> >);
boxReduction = CkReduction::addReducer(same<OrientedBox<cosmoType> >);
dfImageReduction = CkReduction::addReducer(dfImageReducer);

}
Expand Down
1 change: 1 addition & 0 deletions Reductions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

extern CkReduction::reducerType growOrientedBox_float;
extern CkReduction::reducerType growOrientedBox_double;
extern CkReduction::reducerType growOrientedBox_cosmoType;

extern CkReduction::reducerType minmax_int;
extern CkReduction::reducerType minmax_long;
Expand Down
6 changes: 3 additions & 3 deletions Sorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void Sorter::doORBDecomposition(CkReductionMsg* m){
char dim;
double pos;

OrientedBox<float> box = *static_cast<OrientedBox<float> *>(m->getData());
OrientedBox<cosmoType> box = *static_cast<OrientedBox<cosmoType> *>(m->getData());
delete m;

if(numChares == 1) { // No decomposition to do
Expand Down Expand Up @@ -101,8 +101,8 @@ void Sorter::finishPhase(CkReductionMsg *m){
second.boundingBox.greater_corner = (*iter).boundingBox.greater_corner;

//Find which is the longest dimension
OrientedBox<float> box1 = first.boundingBox;
OrientedBox<float> box2 = second.boundingBox;
OrientedBox<cosmoType> box1 = first.boundingBox;
OrientedBox<cosmoType> box2 = second.boundingBox;

len=box1.greater_corner.x-box1.lesser_corner.x;
dim=0;
Expand Down
2 changes: 1 addition & 1 deletion Sorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Sorter : public CBase_Sorter {

///Variables added for ORB decomposition
typedef struct DivData{
OrientedBox<float> boundingBox;
OrientedBox<cosmoType> boundingBox;
double curLow;
double curHigh;
double curDivision;
Expand Down
30 changes: 15 additions & 15 deletions TreePiece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ void TreePiece::velScale(double dScale, const CkCallback& cb)

/// After the bounding box has been found, we can assign keys to the particles
void TreePiece::assignKeys(CkReductionMsg* m) {
if(m->getSize() != sizeof(OrientedBox<float>)) {
if(m->getSize() != sizeof(OrientedBox<cosmoType>)) {
ckerr << thisIndex << ": TreePiece: Fatal: Wrong size reduction message received!" << endl;
CkAssert(0);
callback.send(0);
delete m;
return;
}

boundingBox = *static_cast<OrientedBox<float> *>(m->getData());
boundingBox = *static_cast<OrientedBox<cosmoType> *>(m->getData());
delete m;
if(thisIndex == 0 && verbosity > 1)
ckout << "TreePiece: Bounding box originally: "
Expand All @@ -148,17 +148,17 @@ void TreePiece::assignKeys(CkReductionMsg* m) {
if((domainDecomposition!=ORB_dec)
&& (domainDecomposition!=ORB_space_dec)){
// get longest axis
Vector3D<float> bsize = boundingBox.size();
Vector3D<cosmoType> bsize = boundingBox.size();
float max = (bsize.x > bsize.y) ? bsize.x : bsize.y;
max = (max > bsize.z) ? max : bsize.z;
//
// Make the bounding box cubical.
//
Vector3D<float> bcenter = boundingBox.center();
Vector3D<cosmoType> bcenter = boundingBox.center();
const float fEps = 1.0 + 9.5e-7; // slop to ensure keys fall
// between 0 and 1.
bsize = Vector3D<float>(fEps*0.5*max);
boundingBox = OrientedBox<float>(bcenter-bsize, bcenter+bsize);
bsize = Vector3D<cosmoType>(fEps*0.5*max);
boundingBox = OrientedBox<cosmoType>(bcenter-bsize, bcenter+bsize);
if(thisIndex == 0 && verbosity > 1)
ckout << "TreePiece: Bounding box now: "
<< boundingBox << endl;
Expand Down Expand Up @@ -210,7 +210,7 @@ bool comp_dim2(GravityParticle p1, GravityParticle p2) {
///Initialize stuff before doing ORB decomposition
void TreePiece::initORBPieces(const CkCallback& cb){

OrientedBox<float> box = boundingBox;
OrientedBox<cosmoType> box = boundingBox;
orbBoundaries.clear();
orbBoundaries.push_back(myParticles+1);
orbBoundaries.push_back(myParticles+myNumParticles+1);
Expand All @@ -236,12 +236,12 @@ void TreePiece::initORBPieces(const CkCallback& cb){
}
chunkRootLevel--;

boxes = new OrientedBox<float>[chunkRootLevel+1];
boxes = new OrientedBox<cosmoType>[chunkRootLevel+1];
splitDims = new char[chunkRootLevel+1];

boxes[0] = boundingBox;

contribute(sizeof(OrientedBox<float>), &box, boxReduction, cb);
contribute(sizeof(OrientedBox<cosmoType>), &box, boxReduction, cb);
}

/// Allocate memory for sorted particles.
Expand Down Expand Up @@ -1912,8 +1912,8 @@ void TreePiece::drift(double dDelta, // time step in x containing
CkAbort("binbox2 failed\n");
}
if(buildTree)
contribute(sizeof(OrientedBox<float>), &boundingBox,
growOrientedBox_float,
contribute(sizeof(OrientedBox<cosmoType>), &boundingBox,
growOrientedBox_cosmoType,
CkCallback(CkIndex_TreePiece::assignKeys(0), pieces));
else
contribute(cb);
Expand Down Expand Up @@ -2107,8 +2107,8 @@ void TreePiece::newOrder(const NewMaxOrder *nStarts, const int n,
iSeTab.clear();
callback = cb; // called by assignKeys()
// get the new particles into key order
contribute(sizeof(OrientedBox<float>), &boundingBox,
growOrientedBox_float,
contribute(sizeof(OrientedBox<cosmoType>), &boundingBox,
growOrientedBox_cosmoType,
CkCallback(CkIndex_TreePiece::assignKeys(0), pieces));
}

Expand Down Expand Up @@ -2638,9 +2638,9 @@ void TreePiece::startORBTreeBuild(CkReductionMsg* m){

}

OrientedBox<float> TreePiece::constructBoundingBox(GenericTreeNode* node,int level, int numChild){
OrientedBox<cosmoType> TreePiece::constructBoundingBox(GenericTreeNode* node,int level, int numChild){

OrientedBox<float> tmpBox;
OrientedBox<cosmoType> tmpBox;
if(node->getType()==NonLocal){
if(numChild==0){
tmpBox = boxes[level];
Expand Down