sc/source/core/opencl/formulagroupcl.cxx | 1 + sc/source/core/opencl/op_addin.cxx | 18 ++++++------------ 2 files changed, 7 insertions(+), 12 deletions(-)
New commits: commit 9881ac6874d0001795e5c8892e2d5ac80eeacdc8 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Dec 4 12:36:46 2018 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Dec 5 10:59:30 2018 +0100 better/sane error checking in OpenCL BESSELJ() Change-Id: I1f1945e7fd2721a320ab11196385e22a70d3da70 Reviewed-on: https://gerrit.libreoffice.org/64542 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index ccc6fbbe4f7e..8676a300ca16 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -43,6 +43,7 @@ static const char* const publicFunc = "#define IllegalArgument 502\n" "#define IllegalFPOperation 503 // #NUM!\n" "#define NoValue 519 // #VALUE!\n" + "#define NoConvergence 523\n" "#define DivisionByZero 532 // #DIV/0!\n" "#define NOTAVAILABLE 0x7fff // #N/A\n" "\n" diff --git a/sc/source/core/opencl/op_addin.cxx b/sc/source/core/opencl/op_addin.cxx index 5feabef7076b..4dcfc9f8a59e 100644 --- a/sc/source/core/opencl/op_addin.cxx +++ b/sc/source/core/opencl/op_addin.cxx @@ -19,6 +19,7 @@ namespace sc { namespace opencl { void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) { + CHECK_PARAMETER_COUNT( 2, 2 ); ss << "\ndouble " << sSymName; ss << "_" << BinFuncName() << "("; for (size_t i = 0; i < vSubArguments.size(); i++) @@ -31,11 +32,6 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, ss << " int gid0 = get_global_id(0);\n"; ss << " double x = 0.0;\n"; ss << " double N = 0.0;\n"; - if(vSubArguments.size() != 2) - { - ss << " return DBL_MAX;\n}\n"; - return ; - } FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken(); assert(tmpCur0); if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode()) @@ -58,8 +54,7 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, } else { - ss << " return DBL_MAX;\n}\n"; - return ; + throw Unhandled(__FILE__, __LINE__); } } else @@ -90,8 +85,7 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, } else { - ss << " return DBL_MAX;\n}\n"; - return ; + throw Unhandled(__FILE__, __LINE__); } } else @@ -104,7 +98,7 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, ss << " double f_PI_DIV_2 = f_PI / 2.0;\n"; ss << " double f_PI_DIV_4 = f_PI / 4.0;\n"; ss << " if( N < 0.0 )\n"; - ss << " return DBL_MAX;\n"; + ss << " return CreateDoubleError(IllegalArgument);\n"; ss << " if (x == 0.0)\n"; ss << " return (N == 0.0) ? 1.0 : 0.0;\n"; ss << " double fSign = ((int)N % 2 == 1 && x < 0.0) ? -1.0 : 1.0;\n"; @@ -118,7 +112,7 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, ss << " return fSign * sqrt(f_2_DIV_PI/fX)"; ss << "* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);\n"; ss << " else\n"; - ss << " return DBL_MAX;\n"; + ss << " return CreateDoubleError(NoConvergence);\n"; ss << " }\n"; ss << " double epsilon = 1.0e-15;\n"; ss << " bool bHasfound = false;\n"; @@ -179,7 +173,7 @@ void OpBesselj::GenSlidingWindowFunction(std::stringstream &ss, ss << " if (bHasfound)\n"; ss << " return u * fSign;\n"; ss << " else\n"; - ss << " return DBL_MAX;\n"; + ss << " return CreateDoubleError(NoConvergence);\n"; ss << "}"; } void OpGestep::GenSlidingWindowFunction( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits