sc/source/core/opencl/formulagroupcl.cxx | 40 +++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-)
New commits: commit fd72a87868708569d19cccaab158116107698db5 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Aug 30 16:30:12 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Aug 31 09:14:14 2022 +0200 fix opencl implementations of comparison operators The normal core implementations use approximate comparison. Also add the two missing operators. Change-Id: I98f65b4fed70dd40f9087b6d98696b3bb10ea194 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139053 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 9ab5b83057e9..5800ef08c89d 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1786,12 +1786,25 @@ public: virtual std::string Gen2( const std::string& lhs, const std::string& rhs ) const override { std::stringstream ss; - ss << "(" << lhs << " == " << rhs << ")"; + ss << "approx_equal(" << lhs << "," << rhs << ")"; return ss.str(); } virtual std::string BinFuncName() const override { return "eq"; } }; +class OpNotEqual : public Binary +{ +public: + virtual std::string GetBottom() override { return "0"; } + virtual std::string Gen2( const std::string& lhs, const std::string& rhs ) const override + { + std::stringstream ss; + ss << "!approx_equal(" << lhs << "," << rhs << ")"; + return ss.str(); + } + virtual std::string BinFuncName() const override { return "neq"; } +}; + class OpLessEqual : public Binary { public: @@ -1799,10 +1812,10 @@ public: virtual std::string Gen2( const std::string& lhs, const std::string& rhs ) const override { std::stringstream ss; - ss << "(" << lhs << "<=" << rhs << ")"; + ss << "(approx_equal(" << lhs << "," << rhs << ") || " << lhs << "<=" << rhs << ")"; return ss.str(); } - virtual std::string BinFuncName() const override { return "leq"; } + virtual std::string BinFuncName() const override { return "le"; } }; class OpLess : public Binary @@ -1815,7 +1828,7 @@ public: ss << "(" << lhs << "<" << rhs << ")"; return ss.str(); } - virtual std::string BinFuncName() const override { return "less"; } + virtual std::string BinFuncName() const override { return "lt"; } }; class OpGreater : public Binary @@ -1831,6 +1844,19 @@ public: virtual std::string BinFuncName() const override { return "gt"; } }; +class OpGreaterEqual : public Binary +{ +public: + virtual std::string GetBottom() override { return "0"; } + virtual std::string Gen2( const std::string& lhs, const std::string& rhs ) const override + { + std::stringstream ss; + ss << "(approx_equal(" << lhs << "," << rhs << ") || " << lhs << ">=" << rhs << ")"; + return ss.str(); + } + virtual std::string BinFuncName() const override { return "ge"; } +}; + class OpSum : public Reduction { public: @@ -3004,9 +3030,15 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, case ocEqual: mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], std::make_shared<OpEqual>(), nResultSize)); break; + case ocNotEqual: + mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], std::make_shared<OpNotEqual>(), nResultSize)); + break; case ocGreater: mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], std::make_shared<OpGreater>(), nResultSize)); break; + case ocGreaterEqual: + mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], std::make_shared<OpGreaterEqual>(), nResultSize)); + break; case ocSYD: mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], std::make_shared<OpSYD>(), nResultSize)); break;