Fix parenthesization bugs in cost estimates.

Also added the debugging print that helped find these issues.
Revert inlining some functions in examples
This commit is contained in:
Matt Pharr
2011-09-16 17:40:05 -07:00
parent cdc850f98c
commit a501ab1aa6
5 changed files with 22 additions and 19 deletions

View File

@@ -70,7 +70,7 @@ static inline float Dot(const float3 a, const float3 b) {
} }
static inline void generateRay(uniform const float raster2camera[4][4], static void generateRay(uniform const float raster2camera[4][4],
uniform const float camera2world[4][4], uniform const float camera2world[4][4],
float x, float y, reference Ray ray) { float x, float y, reference Ray ray) {
ray.mint = 0.f; ray.mint = 0.f;
@@ -177,7 +177,7 @@ static inline bool TriIntersect(const reference Triangle tri, reference Ray ray)
} }
static inline bool BVHIntersect(const LinearBVHNode nodes[], const Triangle tris[], bool BVHIntersect(const LinearBVHNode nodes[], const Triangle tris[],
reference Ray r) { reference Ray r) {
Ray ray = r; Ray ray = r;
bool hit = false; bool hit = false;
@@ -226,7 +226,7 @@ static inline bool BVHIntersect(const LinearBVHNode nodes[], const Triangle tris
} }
static inline void raytrace_tile(uniform int x0, uniform int x1, static void raytrace_tile(uniform int x0, uniform int x1,
uniform int y0, uniform int y1, uniform int y0, uniform int y1,
uniform int width, uniform int height, uniform int width, uniform int height,
uniform int baseWidth, uniform int baseHeight, uniform int baseWidth, uniform int baseHeight,

View File

@@ -32,7 +32,7 @@
*/ */
static inline void static void
stencil_step(uniform int x0, uniform int x1, stencil_step(uniform int x0, uniform int x1,
uniform int y0, uniform int y1, uniform int y0, uniform int y1,
uniform int z0, uniform int z1, uniform int z0, uniform int z1,

View File

@@ -1455,8 +1455,8 @@ int
BinaryExpr::EstimateCost() const { BinaryExpr::EstimateCost() const {
return ((arg0 ? arg0->EstimateCost() : 0) + return ((arg0 ? arg0->EstimateCost() : 0) +
(arg1 ? arg1->EstimateCost() : 0) + (arg1 ? arg1->EstimateCost() : 0) +
(op == Div || op == Mod) ? COST_COMPLEX_ARITH_OP : ((op == Div || op == Mod) ? COST_COMPLEX_ARITH_OP :
COST_SIMPLE_ARITH_LOGIC_OP); COST_SIMPLE_ARITH_LOGIC_OP));
} }

View File

@@ -707,9 +707,12 @@ lEmitFunctionCode(FunctionEmitContext *ctx, llvm::Function *function,
// Finally, we can generate code for the function // Finally, we can generate code for the function
if (code != NULL) { if (code != NULL) {
int costEstimate = code->EstimateCost();
bool checkMask = (ft->isTask == true) || bool checkMask = (ft->isTask == true) ||
((function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) && ((function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) &&
code->EstimateCost() > 16); costEstimate > 16);
Debug(code->pos, "Estimated cost for function \"%s\" = %d\n",
funSym->name.c_str(), costEstimate);
// If the body of the function is non-trivial, then we wrap the // If the body of the function is non-trivial, then we wrap the
// entire thing around a varying "cif (true)" test in order to reap // entire thing around a varying "cif (true)" test in order to reap
// the side-effect benefit of checking to see if the execution mask // the side-effect benefit of checking to see if the execution mask

View File

@@ -1177,7 +1177,7 @@ ForStmt::EstimateCost() const {
(test ? test->EstimateCost() : 0) + (test ? test->EstimateCost() : 0) +
(step ? step->EstimateCost() : 0) + (step ? step->EstimateCost() : 0) +
(stmts ? stmts->EstimateCost() : 0) + (stmts ? stmts->EstimateCost() : 0) +
uniformTest ? COST_UNIFORM_LOOP : COST_VARYING_LOOP); (uniformTest ? COST_UNIFORM_LOOP : COST_VARYING_LOOP));
} }