Text archives Help
- From: thiago@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1914 - trunk/Model/Groups
- Date: Sat, 8 Dec 2007 18:41:57 -0700 (MST)
Author: thiago
Date: Sat Dec 8 18:41:56 2007
New Revision: 1914
Modified:
trunk/Model/Groups/KDTree.cc
trunk/Model/Groups/KDTree.h
Log:
KDTree now uses Real instead of float almost everywhere. The kdtree
node is still float because changing that is messy.
Modified: trunk/Model/Groups/KDTree.cc
==============================================================================
--- trunk/Model/Groups/KDTree.cc (original)
+++ trunk/Model/Groups/KDTree.cc Sat Dec 8 18:41:56 2007
@@ -2,6 +2,7 @@
#include <Core/Exceptions/InternalError.h>
#include <Core/Geometry/Vector.h>
#include <Core/Math/MinMax.h>
+#include <Core/Util/Preprocessor.h>
#include <Interface/Context.h>
#include <Core/Thread/Time.h>
#include <Interface/MantaInterface.h>
@@ -96,7 +97,7 @@
build(0, primitives, bounds);
cout << "done building" << endl << flush;
- float buildTime = Time::currentSeconds() - startTime;
+ double buildTime = Time::currentSeconds() - startTime;
printf("KDTree tree built in %f seconds\n", buildTime);
printStats();
}
@@ -104,11 +105,11 @@
struct Event
{
enum Type { tri_end, tri_planar, tri_begin };
- float pos;
+ Real pos;
Type type;
int tri;
- Event(Type t, float p, int i) : pos(p), type(t), tri(i) {};
+ Event(Type t, Real p, int i) : pos(p), type(t), tri(i) {};
};
bool operator<(const Event &a, const Event &b)
@@ -140,8 +141,8 @@
{
DBG(cout << "build " << nodeID << " #=" << primitiveID.size() << " bb="
<< bounds[0] << ":" << bounds[1] << endl);
int bestDim = -1;
- float bestSplit = -1;
- float bestCost = primitiveID.size() * ISEC_COST;
+ Real bestSplit = -1;
+ Real bestCost = primitiveID.size() * ISEC_COST;
bool bestCommonToTheLeft = false;
vector<Event> event[3];
@@ -175,7 +176,7 @@
cerr << endl;
cerr << bounds.getMin() << " " << bounds.getMax() << endl;
cerr << box.getMin() << " " << box.getMax() << endl;
- exit(0);
+ continue;
}
else {
for (int k=0;k<3;k++) {
@@ -189,13 +190,13 @@
}
}
// cout << __PRETTY_FUNCTION__ << endl;
- const float boundsArea = bounds.computeArea();
+ const Real boundsArea = bounds.computeArea();
for (int k=0;k<3;k++) {
BBox lBounds = bounds;
BBox rBounds = bounds;
DBG(cout << "sorting " << k << " " << event[k].size() << endl);
- std::sort(event[k].begin(),event[k].end());
+ std::sort(event[k].begin(),event[k].end());
int Nl = 0;
int Nr = primitiveID.size();
@@ -228,8 +229,8 @@
lBounds[1][k] = event[k][seqStart].pos;
rBounds[0][k] = event[k][seqStart].pos;
- float lProb = lBounds.computeArea() / boundsArea;
- float rProb = rBounds.computeArea() / boundsArea;
+ Real lProb = lBounds.computeArea() / boundsArea;
+ Real rProb = rBounds.computeArea() / boundsArea;
Nr -= numEnding;
Nr -= numPlanar;
@@ -241,7 +242,7 @@
{
// try putting common on the left
- float cost = TRAV_COST + ISEC_COST * (lProb * (Nl+Np) + rProb * Nr);
+ Real cost = TRAV_COST + ISEC_COST * (lProb * (Nl+Np) + rProb * Nr);
DBG(cout << cost << endl);
if (cost < bestCost) {
@@ -254,7 +255,7 @@
}
{
// try putting common on the right
- float cost = TRAV_COST + ISEC_COST * (lProb * Nl + rProb * (Nr+Np));
+ Real cost = TRAV_COST + ISEC_COST * (lProb * Nl + rProb * (Nr+Np));
DBG(cout << cost << endl);
if (cost < bestCost) {
bestCost = cost;
@@ -365,8 +366,8 @@
nTotalRays += rays.end() - rays.begin();
#endif
- MANTA_ALIGN(16) float t_in[RayPacketData::MaxSize+1]; //last element is
min of all t_in
- MANTA_ALIGN(16) float t_out[RayPacketData::MaxSize+1];//last element is
max of all t_out
+ MANTA_ALIGN(16) Real t_in[RayPacketData::MaxSize+1]; //last element is min
of all t_in
+ MANTA_ALIGN(16) Real t_out[RayPacketData::MaxSize+1];//last element is max
of all t_out
MANTA_ALIGN(16) int valid[RayPacketData::MaxSize];
#ifdef SSE
@@ -413,8 +414,8 @@
for (int k=0;k<3;k++) {
//TODO: Check to see if using rays.getOrigin(0,k) and
//getInverseDirection(ray,k) are faster.
- float t0 = (bounds.getMin()[k] - origin[k]) * inverse_direction[k];
- float t1 = (bounds.getMax()[k] - origin[k]) * inverse_direction[k];
+ Real t0 = (bounds.getMin()[k] - origin[k]) * inverse_direction[k];
+ Real t1 = (bounds.getMax()[k] - origin[k]) * inverse_direction[k];
if (t0 > t1) {
if (t1 > t_in[ray]) t_in[ray] = t1;
@@ -436,9 +437,7 @@
sse_t org_y = load44(&rays.getOrigin(sse_begin,1));
sse_t org_z = load44(&rays.getOrigin(sse_begin,2));
-#ifdef __INTEL_COMPILER
-#pragma unroll(4)
-#endif
+MANTA_UNROLL(4)
for (int ray = sse_begin; ray < sse_end; ray+=4) {
if (!COMMON_ORIGIN) {
org_x = load44(&rays.getOrigin(ray,0));
@@ -498,8 +497,8 @@
t_out[ray] = rays.getMinT(ray);
for (int k=0;k<3;k++) {
- float t0 = (bounds.getMin()[k] - origin[k]) * inverse_direction[k];
- float t1 = (bounds.getMax()[k] - origin[k]) * inverse_direction[k];
+ Real t0 = (bounds.getMin()[k] - origin[k]) * inverse_direction[k];
+ Real t1 = (bounds.getMax()[k] - origin[k]) * inverse_direction[k];
// cout << " k=" << k << " : " << t0 << " " << t1 << endl;
// hopefully everything all right with nan's etc....
@@ -542,8 +541,8 @@
template<bool COMMON_ORIGIN>
void KDTree::intersectNode(int nodeID, const RenderContext& context,
RayPacket& rays,
- const float *const t_in,
- const float *const t_out,
+ const Real *const t_in,
+ const Real *const t_out,
const int *const valid
, Mailbox &mailbox
) const
@@ -551,8 +550,8 @@
template<bool COMMON_ORIGIN>
void KDTree::intersectNode(int nodeID, const RenderContext& context,
RayPacket& rays,
- const float *const t_in,
- const float *const t_out,
+ const Real *const t_in,
+ const Real *const t_out,
const int *const valid
) const
#endif
@@ -593,7 +592,7 @@
#ifdef SSE
- MANTA_ALIGN(16) float t_plane[RayPacketData::MaxSize];
+ MANTA_ALIGN(16) Real t_plane[RayPacketData::MaxSize];
sse_t frontMask = false4();
sse_t backMask = frontMask;
@@ -630,9 +629,7 @@
sse_t org_k = load44(&rays.getOrigin(sse_begin,node.planeDim));
sse_t plane_org = sub4(planePos4, org_k);
-#ifdef __INTEL_COMPILER
-#pragma unroll(4)
-#endif
+MANTA_UNROLL(4)
for (int ray = sse_begin; ray < sse_end; ray+=4) {
if (!COMMON_ORIGIN) {
org_k = load44(&rays.getOrigin(ray,node.planeDim));
@@ -654,7 +651,7 @@
front += getmask4(frontMask);
back += getmask4(backMask);
#else
- float t_plane[RayPacketData::MaxSize];
+ Real t_plane[RayPacketData::MaxSize];
int front=0;
int back=0;
for(int ray=ray_begin; ray<ray_end; ray++) {
@@ -691,7 +688,7 @@
#endif
} else {
- MANTA_ALIGN(16) float new_t_out[RayPacketData::MaxSize+1];
+ MANTA_ALIGN(16) Real new_t_out[RayPacketData::MaxSize+1];
MANTA_ALIGN(16) int new_valid[RayPacketData::MaxSize];
#ifdef SSE
@@ -718,9 +715,7 @@
}
}
}
-#ifdef __INTEL_COMPILER
-#pragma unroll(4)
-#endif
+MANTA_UNROLL(4)
for (int ray = sse_begin; ray < sse_end; ray+=4) {
//no need to do t_in here
const sse_t nto = min4(load44(&t_out[ray]),load44(&t_plane[ray]));
@@ -761,7 +756,7 @@
);
#endif //SSE
- MANTA_ALIGN(16) float new_t_in[RayPacketData::MaxSize+1];
+ MANTA_ALIGN(16) Real new_t_in[RayPacketData::MaxSize+1];
back = 0;
#ifdef SSE
@@ -797,9 +792,7 @@
backMask = false4();
-#ifdef __INTEL_COMPILER
-#pragma unroll(4)
-#endif
+MANTA_UNROLL(4)
for (int ray = sse_begin; ray < sse_end; ray+=4) {
const sse_t nti = max4(load44(&t_in[ray]),load44(&t_plane[ray]));
store44(&new_t_in[ray], nti);
@@ -824,13 +817,13 @@
if (t_in[ray] > t_plane[ray]) {
new_t_in[ray] = t_in[ray];
// might may have changed in prev isec step:
- new_t_out[ray] =
Min(t_out[ray],static_cast<float>(rays.getMinT(ray)));
+ new_t_out[ray] = Min(t_out[ray],rays.getMinT(ray));
new_valid[ray] = (new_t_in[ray]<=new_t_out[ray]);
} else if (t_out[ray] < t_plane[ray]) {
new_valid[ray] = false;
} else {
new_t_in[ray] = t_plane[ray]; //t_in[ray];
- new_t_out[ray] =
Min(t_out[ray],static_cast<float>(rays.getMinT(ray)));
+ new_t_out[ray] = Min(t_out[ray],rays.getMinT(ray));
new_valid[ray] = (new_t_in[ray]<=new_t_out[ray]);
}
back += new_valid[ray];
@@ -936,7 +929,7 @@
in.close();
cout << "done building" << endl << flush;
- float buildTime = Time::currentSeconds() - startTime;
+ double buildTime = Time::currentSeconds() - startTime;
printf("KDTree tree built in %f seconds\n", buildTime);
printStats();
Modified: trunk/Model/Groups/KDTree.h
==============================================================================
--- trunk/Model/Groups/KDTree.h (original)
+++ trunk/Model/Groups/KDTree.h Sat Dec 8 18:41:56 2007
@@ -129,8 +129,8 @@
void intersectNode(int nodeID,
const RenderContext& context,
RayPacket& rays,
- const float *const t_in,
- const float *const t_out,
+ const Real *const t_in,
+ const Real *const t_out,
const int *const valid
#ifdef MAILBOX
, Mailbox &mailbox
- [Manta] r1914 - trunk/Model/Groups, thiago, 12/08/2007
Archive powered by MHonArc 2.6.16.