Kaydet (Commit) fbbf5c08 authored tarafından haochen's avatar haochen Kaydeden (comit) Markus Mohrhard

GPU Calc: Fixed style&error problem in formulagroupcl and op_addin

Change-Id: Id7c6e341eb88f6c8ffdaa7f83b787bb19649afec
üst dd0f8447
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/// CONFIGURATIONS /// CONFIGURATIONS
// Comment out this to turn off FMIN and FMAX intrinsics // Comment out this to turn off FMIN and FMAX intrinsics
#define USE_FMIN_FMAX 1 #define USE_FMIN_FMAX 1
#define REDUCE_THRESHOLD 4 // set to 4 for correctness testing. priority 1 #define REDUCE_THRESHOLD 201 // set to 4 for correctness testing. priority 1
#define UNROLLING_FACTOR 16 // set to 4 for correctness testing (if no reduce) #define UNROLLING_FACTOR 16 // set to 4 for correctness testing (if no reduce)
#include "formulagroupcl_public.hxx" #include "formulagroupcl_public.hxx"
#ifdef WIN32 #ifdef WIN32
...@@ -1218,30 +1218,25 @@ public: ...@@ -1218,30 +1218,25 @@ public:
ss << "int nCount = 0;\n\t"; ss << "int nCount = 0;\n\t";
ss << "double tmpBottom;\n\t"; ss << "double tmpBottom;\n\t";
unsigned i = vSubArguments.size(); unsigned i = vSubArguments.size();
size_t nItems = 0;
while (i--) while (i--)
{ {
if (NumericRange *NR = if (NumericRange *NR =
dynamic_cast<NumericRange *> (vSubArguments[i].get())) dynamic_cast<NumericRange *> (vSubArguments[i].get()))
{ {
bool needBody; bool needBody;NR->GenReductionLoopHeader(ss, needBody);if (needBody == false) continue;
nItems += NR->GenReductionLoopHeader(ss, needBody);
if (needBody == false) continue;
} }
else if (ParallelNumericRange *PNR = else if (ParallelNumericRange *PNR =
dynamic_cast<ParallelNumericRange *> (vSubArguments[i].get())) dynamic_cast<ParallelNumericRange *> (vSubArguments[i].get()))
{ {
//did not handle yet //did not handle yet
bool needBody; bool needBody;PNR->GenReductionLoopHeader(ss, needBody);if (needBody == false) continue;
nItems += PNR->GenReductionLoopHeader(ss, needBody);
if (needBody == false) continue;
} }
else if (StringRange *SR = else if (StringRange *SR =
dynamic_cast<StringRange *> (vSubArguments[i].get())) dynamic_cast<StringRange *> (vSubArguments[i].get()))
{ {
//did not handle yet //did not handle yet
bool needBody; bool needBody;
nItems += SR->GenReductionLoopHeader(ss, needBody); SR->GenReductionLoopHeader(ss, needBody);
if (needBody == false) continue; if (needBody == false) continue;
} }
else else
...@@ -1257,7 +1252,6 @@ public: ...@@ -1257,7 +1252,6 @@ public:
static_cast< const formula::SingleVectorRefToken* >(pCur); static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n\t\t"; ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n\t\t";
#else #else
nItems += 1;
#endif #endif
} }
else if (pCur->GetType() == formula::svDouble) else if (pCur->GetType() == formula::svDouble)
...@@ -1265,11 +1259,9 @@ public: ...@@ -1265,11 +1259,9 @@ public:
#ifdef ISNAN #ifdef ISNAN
ss << "{\n\t\t"; ss << "{\n\t\t";
#endif #endif
nItems += 1;
} }
else else
{ {
nItems += 1;
} }
} }
#ifdef ISNAN #ifdef ISNAN
...@@ -1304,7 +1296,7 @@ public: ...@@ -1304,7 +1296,7 @@ public:
ss << "return tmp"; ss << "return tmp";
#ifdef ISNAN #ifdef ISNAN
if (isAverage()) if (isAverage())
ss << "/(double)nCount"; ss << "*pow((double)nCount,-1.0)";
#else #else
if (isAverage()) if (isAverage())
ss << "/(double)"<<nItems; ss << "/(double)"<<nItems;
...@@ -2827,10 +2819,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -2827,10 +2819,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpSumIf)); ft->Children[i], new OpSumIf));
break; break;
/*case ocNegSub: case ocNegSub:
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpNegSub)); ft->Children[i], new OpNegSub));
break;*/ break;
case ocAveDev: case ocAveDev:
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpAveDev)); ft->Children[i], new OpAveDev));
...@@ -3071,6 +3063,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -3071,6 +3063,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpBesselj)); new OpBesselj));
} }
else if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getGestep"))))
{
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpGestep));
}
else else
throw UnhandledToken(pChild, "unhandled opcode"); throw UnhandledToken(pChild, "unhandled opcode");
break; break;
...@@ -3175,6 +3173,9 @@ public: ...@@ -3175,6 +3173,9 @@ public:
global_work_size, NULL, 0, NULL, NULL); global_work_size, NULL, 0, NULL, NULL);
if (CL_SUCCESS != err) if (CL_SUCCESS != err)
throw OpenCLError(err, __FILE__, __LINE__); throw OpenCLError(err, __FILE__, __LINE__);
err = clFinish(kEnv.mpkCmdQueue);
if (CL_SUCCESS != err)
throw OpenCLError(err, __FILE__, __LINE__);
} }
virtual ~DynamicKernel(); virtual ~DynamicKernel();
cl_mem GetResultBuffer(void) const { return mpResClmem; } cl_mem GetResultBuffer(void) const { return mpResClmem; }
......
...@@ -196,6 +196,71 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, ...@@ -196,6 +196,71 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return DBL_MAX;\n"; ss << " return DBL_MAX;\n";
ss << "}"; ss << "}";
} }
void OpGestep::GenSlidingWindowFunction(
std::stringstream &ss,const std::string &sSymName,
SubArguments &vSubArguments)
{
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
if (i)
ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ")\n";
ss << "{\n";
ss << " double tmp=0,tmp0 =0,tmp1 = 0;\n";
ss << " int gid0=get_global_id(0);\n";
size_t i = vSubArguments.size();
ss <<"\n";
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
assert(pCur);
if (pCur->GetType() == formula::svSingleVectorRef)
{
#ifdef ISNAN
const formula::SingleVectorRefToken* pSVR =
dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
ss << " {\n";
#endif
}
else if (pCur->GetType() == formula::svDouble)
{
#ifdef ISNAN
ss << " {\n";
#endif
}
else
{
#ifdef ISNAN
#endif
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
{
ss << " if (isNan(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << "))\n";
ss << " tmp"<<i<<" = 0;\n";
ss << " else\n";
ss << " tmp"<<i<<" = ";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n }\n";
}
else
{
ss << "tmp"<<i<<" ="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
}
#endif
}
ss << " tmp =tmp0 >= tmp1 ? 1 : 0;\n";
ss << " return tmp;\n";
ss << "}\n";
}
}} }}
......
...@@ -21,6 +21,13 @@ public: ...@@ -21,6 +21,13 @@ public:
const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE; const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE;
virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "Besselj"; } virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "Besselj"; }
}; };
class OpGestep: public Normal
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE;;
virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "Gestep"; }
};
}} }}
......
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