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:
@@ -70,9 +70,9 @@ 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;
|
||||||
ray.maxt = 1e30f;
|
ray.maxt = 1e30f;
|
||||||
|
|
||||||
@@ -177,8 +177,8 @@ 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;
|
||||||
// Follow ray through BVH nodes to find primitive intersections
|
// Follow ray through BVH nodes to find primitive intersections
|
||||||
@@ -226,15 +226,15 @@ 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,
|
||||||
const uniform float raster2camera[4][4],
|
const uniform float raster2camera[4][4],
|
||||||
const uniform float camera2world[4][4],
|
const uniform float camera2world[4][4],
|
||||||
uniform float image[], uniform int id[],
|
uniform float image[], uniform int id[],
|
||||||
const LinearBVHNode nodes[],
|
const LinearBVHNode nodes[],
|
||||||
const Triangle triangles[]) {
|
const Triangle triangles[]) {
|
||||||
uniform float widthScale = (float)(baseWidth) / (float)(width);
|
uniform float widthScale = (float)(baseWidth) / (float)(width);
|
||||||
uniform float heightScale = (float)(baseHeight) / (float)(height);
|
uniform float heightScale = (float)(baseHeight) / (float)(height);
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
4
expr.cpp
4
expr.cpp
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
2
stmt.cpp
2
stmt.cpp
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user