From 774b8342ac15cdb06e9069cfac19c982ec6ca79e Mon Sep 17 00:00:00 2001 From: yangzhang Date: Tue, 17 Dec 2013 14:19:48 +0800 Subject: GPU Calc: Fixed accuracy bug of CEILING AMLOEXT-375 FIX Change-Id: Ie41c66570db2c9b752d987de421bb7310b244611 Signed-off-by: haochen Signed-off-by: Wei Wei Signed-off-by: I-Jui (Ray) Sung --- sc/source/core/opencl/op_math.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index 4fc7b3c10e1a..9e676a4f7447 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -2386,24 +2386,17 @@ void OpCeil::GenSlidingWindowFunction(std::stringstream &ss, ss << " double bAbs = 0;\n"; #ifdef ISNAN FormulaToken *iNum = vSubArguments[0]->GetFormulaToken(); - const formula::SingleVectorRefToken* tmpCurDVRNum= - dynamic_cast(iNum); FormulaToken *iSignificance = vSubArguments[1]->GetFormulaToken(); - const formula::SingleVectorRefToken* tmpCurDVRSignificance= - dynamic_cast(iSignificance); - ss << " int buffer_num_len = "<GetArrayLength() << ";\n"; - ss << " int buffer_significance_len = "; - ss << tmpCurDVRSignificance->GetArrayLength() << ";\n"; - ss << " if((gid0)>=buffer_num_len || isNan("; + ss << " if(isNan("; ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n"; ss << " num = " << GetBottom() << ";\n"; ss << " else\n "; #endif ss << " num = " << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n"; #ifdef ISNAN - ss << " if((gid0)>=buffer_significance_len || isNan("; + ss << " if(isNan("; ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n"; - ss << " significance = " << GetBottom() << ";\n"; + ss << " return 0.0;\n"; ss << " else\n "; #endif ss << " significance = "; @@ -2435,6 +2428,8 @@ void OpCeil::GenSlidingWindowFunction(std::stringstream &ss, #endif ss << " bAbs = "<GenSlidingWindowDeclRef()<<";\n"; } + ss << " if(significance == 0.0)\n"; + ss << " return 0.0;\n"; ss << " return "; ss << "( !(int)bAbs && num < 0.0 ? floor( num / significance ) : "; ss << "ceil( num / significance ) )"; -- cgit