Kaydet (Commit) ef256113 authored tarafından hongyu zhong's avatar hongyu zhong Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: Optimized NORMDIST

AMLOEXT-284

Change-Id: I5028ebbee91d6c7a64e9993b97b5f942f039d92c
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarWei Wei <weiwei@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst d5dac048
...@@ -4600,70 +4600,56 @@ void OpNormdist::GenSlidingWindowFunction( ...@@ -4600,70 +4600,56 @@ void OpNormdist::GenSlidingWindowFunction(
ss << "{\n"; ss << "{\n";
ss << " double x,mue,sigma,c;\n"; ss << " double x,mue,sigma,c;\n";
ss << " int gid0=get_global_id(0);\n"; ss << " int gid0=get_global_id(0);\n";
#ifdef ISNAN ss << " double tmp0,tmp1,tmp2,tmp3;\n";
FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken(); size_t i = vSubArguments.size();
const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const ss <<"\n ";
formula::SingleVectorRefToken *>(tmpCur0); for (i = 0; i < vSubArguments.size(); i++)
FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken(); {
const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
formula::SingleVectorRefToken *>(tmpCur1); assert(pCur);
FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken(); if (pCur->GetType() == formula::svSingleVectorRef)
const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const {
formula::SingleVectorRefToken *>(tmpCur2); #ifdef ISNAN
FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken(); const formula::SingleVectorRefToken* pSVR =
const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
formula::SingleVectorRefToken *>(tmpCur3); ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
ss << " int buffer_x_len = ";
ss << tmpCurDVR0->GetArrayLength();
ss << ";\n";
ss << " int buffer_mue_len = ";
ss << tmpCurDVR1->GetArrayLength();
ss << ";\n";
ss << " int buffer_sigma_len = ";
ss << tmpCurDVR2->GetArrayLength();
ss << ";\n";
ss << " int buffer_c_len = ";
ss << tmpCurDVR3->GetArrayLength();
ss << ";\n";
#endif
#ifdef ISNAN
ss <<"if((gid0)>=buffer_c_len || isNan(";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" c = 0;\nelse \n";
#endif
ss << " c = "<<vSubArguments[3]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
ss <<"if((gid0)>=buffer_sigma_len || isNan(";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" sigma = 0;\nelse \n";
#endif #endif
ss <<" sigma = "<<vSubArguments[2]->GenSlidingWindowDeclRef(); }
ss <<";\n"; else if (pCur->GetType() == formula::svDouble)
#ifdef ISNAN {
ss <<" if((gid0)>=buffer_mue_len || isNan("; #ifdef ISNAN
ss << vSubArguments[1]->GenSlidingWindowDeclRef(); ss << "{\n";
ss <<"))\n";
ss <<" mue = 0;\nelse \n";
#endif #endif
ss <<" mue = "<<vSubArguments[1]->GenSlidingWindowDeclRef(); }
ss <<";\n"; #ifdef ISNAN
#ifdef ISNAN if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
ss<<" if((gid0)>=buffer_x_len || isNan("; {
ss << vSubArguments[0]->GenSlidingWindowDeclRef(); ss << " if (isNan(";
ss<<"))\n"; ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss<<" x = 0;\nelse \n"; ss << "))\n";
ss << " tmp"<<i<<"= 0;\n";
ss << " else\n";
ss << " tmp"<<i<<"=\n";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n}\n";
}
else
{
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
}
#endif #endif
ss <<" x = "<<vSubArguments[0]->GenSlidingWindowDeclRef(); }
ss << ";\n"; ss << "x = tmp0;\n";
ss << "mue = tmp1;\n";
ss << "sigma = tmp2;\n";
ss << "c = tmp3;\n";
ss << "double mid,tmp;\n"; ss << "double mid,tmp;\n";
ss << "mid = (x - mue)/sigma;\n"; ss << "mid = (x - mue)/sigma;\n";
ss << "if(c)\n"; ss << "if(c)\n";
ss << " tmp = 0.5 *erfc(-mid * 0.7071067811865475);\n"; ss << " tmp = 0.5 *erfc(-mid * 0.7071067811865475);\n";
ss << "else \n"; ss << "else \n";
ss <<" tmp=(0.39894228040143268*exp(-(mid * mid)/2.0))/sigma;\n"; ss <<" tmp=(0.39894228040143268*exp(-pow(mid,2)/2.0))/sigma;\n";
ss << "return tmp;\n"; ss << "return tmp;\n";
ss << "}\n"; ss << "}\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