Skip to content

Commit

Permalink
Windows compilation working again
Browse files Browse the repository at this point in the history
Note that this just is to get things working. Correctness is not
guarenteed at this point, although most changes are in the IC
generators. Still have to fix all the warnings at some point...
  • Loading branch information
jbedorf committed Jun 3, 2013
1 parent f471586 commit 9325a67
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
8 changes: 4 additions & 4 deletions runtime/CUDAkernels/build_tree.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,8 @@ KERNEL_DECLARE(gpu_build_parallel_grps)(
{
//Set the key to invalid and in item w a value that marks it invalid
//the .w item is redundant, and not used. Could be used for validation
parGrpBlockInfo[offset+bid] = (uint2){0, 0};
parGrpBlockKey [offset+bid] = (uint4){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0};
parGrpBlockInfo[offset+bid] = make_uint2(0, 0);
parGrpBlockKey [offset+bid] = make_uint4(0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0);
}
return;
}
Expand All @@ -1120,7 +1120,7 @@ KERNEL_DECLARE(gpu_build_parallel_grps)(
uint4 key = bodies_key[bi];
key.w = bj-bi;

uint2 blockInfo = (uint2){bi, bj};
uint2 blockInfo = make_uint2(bi, bj);

parGrpBlockInfo[offset+bid] = blockInfo;
parGrpBlockKey [offset+bid] = key;
Expand All @@ -1138,7 +1138,7 @@ KERNEL_DECLARE(gpu_build_parallel_grps)(
if(i + tid < nparticles)
{
//sets the key to FF to indicate the body is used
bodies_key[bi+i+tid] = (uint4){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
bodies_key[bi+i+tid] = make_uint4(0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
}
} //for nparticles

Expand Down
4 changes: 3 additions & 1 deletion runtime/include/octree.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
#include <iostream>
#include <fstream>
#include <sys/types.h>
#include <unistd.h>

#ifndef WIN32
#include <unistd.h>
#endif


#include "log.h"
Expand Down
9 changes: 8 additions & 1 deletion runtime/include/plummer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ struct Plummer{
continue;
}
const double R = 1.0/sqrt( c );
#ifdef WIN32
if(R != R) //nan compared with nan is false
{
fprintf(stderr, "%d : Nan detected R [c=%e] NaN, continue\n", (int)i, c);
continue;
}
#else
if(std::isnan(R))
{
fprintf(stderr, "%d : Nan detected R [c=%e] NaN, continue\n", (int)i, c);
continue;
}

#endif

if(R < 100.0) {
double Z = (1.0 - 2.0*X2)*R;
Expand Down
20 changes: 10 additions & 10 deletions runtime/src/hostConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ void inline mergeBoxesForGrpTree(float4 cntA, float4 sizeA, float4 cntB, float4
maxyA = cntA.y + sizeA.y; maxyB = cntB.y + sizeB.y;
maxzA = cntA.z + sizeA.z; maxzB = cntB.z + sizeB.z;

float newMinx = fmin(minxA, minxB);
float newMiny = fmin(minyA, minyB);
float newMinz = fmin(minzA, minzB);
float newMinx = std::min(minxA, minxB);
float newMiny = std::min(minyA, minyB);
float newMinz = std::min(minzA, minzB);

float newMaxx = fmax(maxxA, maxxB);
float newMaxy = fmax(maxyA, maxyB);
float newMaxz = fmax(maxzA, maxzB);
float newMaxx = std::max(maxxA, maxxB);
float newMaxy = std::max(maxyA, maxyB);
float newMaxz = std::max(maxzA, maxzB);

tempCnt.x = 0.5*(newMinx + newMaxx);
tempCnt.y = 0.5*(newMiny + newMaxy);
tempCnt.z = 0.5*(newMinz + newMaxz);

tempSize.x = fmax(fabs(tempCnt.x-newMinx), fabs(tempCnt.x-newMaxx));
tempSize.y = fmax(fabs(tempCnt.y-newMiny), fabs(tempCnt.y-newMaxy));
tempSize.z = fmax(fabs(tempCnt.z-newMinz), fabs(tempCnt.z-newMaxz));
tempSize.x = std::max(fabs(tempCnt.x-newMinx), fabs(tempCnt.x-newMaxx));
tempSize.y = std::max(fabs(tempCnt.y-newMiny), fabs(tempCnt.y-newMaxy));
tempSize.z = std::max(fabs(tempCnt.z-newMinz), fabs(tempCnt.z-newMaxz));

// tempSize.x *= 1.10;
// tempSize.y *= 1.10;
Expand Down Expand Up @@ -668,7 +668,7 @@ void octree::computeProps_TopLevelTree(
if(fabs(mon.w) < 1e-10) s = 0;

//Length of the box, note times 2 since we only computed half the distance before
double l = 2*fmax(boxSizeD.x, fmax(boxSizeD.y, boxSizeD.z));
double l = 2*std::max(boxSizeD.x, std::max(boxSizeD.y, boxSizeD.z));

//Extra check, shouldn't be necessary, probably it is otherwise the test for leaf can fail
//This actually IS important Otherwise 0.0 < 0 can fail, now it will be: -1e-12 < 0
Expand Down
19 changes: 17 additions & 2 deletions runtime/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ Leiden Observatory, Leiden University
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <process.h>
#define M_PI 3.14159265358979323846264338328

#include <stdlib.h>
#include <time.h>
void srand48(const long seed)
{
srand(seed);
}
//JB This is not a proper work around but just to get things compiled...
double drand48()
{
return double(rand())/RAND_MAX;
}


#endif


Expand Down Expand Up @@ -399,7 +414,7 @@ void read_generate_cube(vector<real4> &bodyPositions, vector<real4> &bodyVelocit


//Read tipsy header
NTotal = pow(2, 22);
NTotal = (int)std::pow(2.0, 22);
NFirst = NTotal;
NSecond = 0;
NThird = 0;
Expand Down Expand Up @@ -934,7 +949,7 @@ int main(int argc, char** argv)

int pid = -1;
#ifdef WIN32
pid = _getpid(void);
pid = _getpid();
#else
pid = (int)getpid();
#endif
Expand Down
12 changes: 9 additions & 3 deletions runtime/src/renderloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ class BonsaiDemo
m_simTime = GetTimer() - startTime;

if (!iterationsRemaining)
printf("No iterations Remaining!\n");
{
//printf("No iterations Remaining!\n");
}
}

void drawStats(double fps)
Expand Down Expand Up @@ -1101,6 +1103,8 @@ class BonsaiDemo

m_cameraTrans = center + make_float3(0, 0, -distanceToCenter*0.2f);

#if 0
/* JB This came with stereo, seems to break rotation */
//ignore above and read what we have in the cameras.txt file - dirty SV TODO
m_cameraTrans = m_camera[0].translate;
m_cameraRot = m_camera[0].rotate;
Expand All @@ -1125,7 +1129,9 @@ class BonsaiDemo
// printf("stereo params screenZ %f IOD %f %f \n",m_screenZ, m_IOD);


/* JB this was here, do we need it for screenshots? TODO

#else
/* JB this was original */
m_cameraTransLag = m_cameraTrans;

glMatrixMode(GL_PROJECTION);
Expand All @@ -1134,7 +1140,7 @@ class BonsaiDemo
(float) m_windowDims.x / (float) m_windowDims.y,
0.0001 * distanceToCenter,
4 * (radius + distanceToCenter));
*/
#endif
}

//float frand() { return rand() / (float) RAND_MAX; }
Expand Down

0 comments on commit 9325a67

Please sign in to comment.