Kaydet (Commit) d7e4e5d3 authored tarafından I-Jui (Ray) Sung's avatar I-Jui (Ray) Sung

GPU Calc: add an inline function to legalize inputs for reduction.

Change-Id: Ibcede4a33d7b8b1073d6ecfb49abbc78b31a2f35
üst 4eebd658
......@@ -470,11 +470,18 @@ public:
ss << " int loopOffset = l*512;\n";
ss << " if((loopOffset + lidx + offset + 256) < min( offset + windowSize, arrayLength))\n";
ss << " tmp = ";
ss << mpCodeGen->Gen2("fsum(A[loopOffset + lidx + offset], 0)",
"fsum(A[loopOffset + lidx + offset + 256], 0)");
ss << mpCodeGen->Gen2(
std::string(
"legalize(A[loopOffset + lidx + offset], ")+
mpCodeGen->GetBottom() +")",
std::string(
"legalize(A[loopOffset + lidx + offset + 256], ")+
mpCodeGen->GetBottom() +")"
);
ss << ";";
ss << " else if ((loopOffset + lidx + offset) < min(offset + windowSize, arrayLength))\n";
ss << " tmp = fsum(A[loopOffset + lidx + offset], 0);\n";
ss << " tmp = legalize(A[loopOffset + lidx + offset],";
ss << mpCodeGen->GetBottom() << ");\n";
ss << " shm_buf[lidx] = tmp;\n";
ss << " barrier(CLK_LOCAL_MEM_FENCE);\n";
ss << " for (int i = 128; i >0; i/=2) {\n";
......
......@@ -12,6 +12,7 @@
const char* publicFunc =
"int isNan(double a) { return a != a; }\n"
"double legalize(double a, double b) { return isNan(a)?b:a; }\n"
"double fsum(double a, double b) { return isNan(a)?b:a+b; }\n"
"double fsub(double a, double b) { return a-b; }\n"
"double fdiv(double a, double b) { return a/b; }\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment