[Libreoffice-commits] core.git: Branch 'feature/fixes27' - sc/source

Tor Lillqvist tml at collabora.com
Tue Jul 26 07:52:25 UTC 2016


 sc/source/core/opencl/op_statistical.cxx          |   17 --
 sc/source/core/opencl/op_statistical.hxx          |    1 
 sc/source/core/opencl/opinlinefun_statistical.cxx |  175 ----------------------
 3 files changed, 1 insertion(+), 192 deletions(-)

New commits:
commit 87d459659829947fd242e0572fd4f3bd719d94e0
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Jul 25 19:09:32 2016 +0300

    No need for own implementation of erfc() in OpenCL
    
    The own code was copied from the C++ one we used to have in
    sal/rtl/math.cxx but which was removed in
    a62bc6a65abb47adb0e4caff7e38823c15b302fc. However, it did not work
    correctly on some machines at least, like my AMD A10-7800 running
    Windows 10. I was unable to figure out why not. This lead to OpenCL
    being disabled by the Desktop::CheckOpenCLCompute() code we now run
    early on startup.
    
    Anyway, as OpenCL has erfc(), just use that.
    
    Change-Id: I7ba6104fc4975cd570358760fa97a19390a54cce

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index d9a16f7..7ec558b 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4098,21 +4098,6 @@ void OpNormdist::GenSlidingWindowFunction(
     ss << "return tmp;\n";
     ss << "}\n";
 }
-void OpNormsdist::BinInlineFun(std::set<std::string>& decls,
-    std::set<std::string>& funs)
-{
-    decls.insert(lcl_Erfc0600Decl);
-    funs.insert(lcl_Erfc0600);
-    decls.insert(lcl_Erfc2654Decl);
-    funs.insert(lcl_Erfc2654);
-    decls.insert(lcl_Erf0065Decl);
-    funs.insert(lcl_Erf0065);
-    decls.insert(rtl_math_erf_rdDecl);
-    funs.insert(rtl_math_erf_rd);
-    decls.insert(rtl_math_erfc_rdDecl);
-    funs.insert(rtl_math_erfc_rd);
-}
-
 void OpNormsdist::GenSlidingWindowFunction(
     std::stringstream &ss,const std::string &sSymName,
     SubArguments &vSubArguments)
@@ -4166,7 +4151,7 @@ void OpNormsdist::GenSlidingWindowFunction(
         }
     }
     ss << "    x = tmp0;\n";
-    ss << "    double tmp = 0.5 * rtl_math_erfc_rd((-1)*x * 0.7071067811865475);\n";
+    ss << "    double tmp = 0.5 * erfc((-1)*x * 0.7071067811865475);\n";
     ss << "    return tmp;\n";
     ss << "}\n";
 }
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 00deb73..970112d 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -241,7 +241,6 @@ class OpNormsdist:public Normal{
     public:
     virtual void GenSlidingWindowFunction(std::stringstream &ss,
             const std::string &sSymName, SubArguments &vSubArguments) override;
-    virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&) override;
     virtual std::string BinFuncName() const override { return "OpNormsdist"; }
 };
 class OpNorminv:public Normal{
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx
index d16d938..dfed055 100644
--- a/sc/source/core/opencl/opinlinefun_statistical.cxx
+++ b/sc/source/core/opencl/opinlinefun_statistical.cxx
@@ -1361,181 +1361,6 @@ std::string gauss =
 "    else\n"
 "        return nVal;\n"
 "}\n";
-std::string lcl_Erfc0600Decl=
-"void lcl_Erfc0600( double x, double *fVal );\n";
-std::string lcl_Erfc0600 =
-"void lcl_Erfc0600( double  x, double *fVal )\n"
-"{\n"
-"    double fPSum = 0.0;\n"
-"    double fQSum = 0.0;\n"
-"    double fXPow = 1.0;\n"
-"    double *pn;\n"
-"    double *qn;\n"
-"    if ( x < 2.2 )\n"
-"    {\n"
-"        double pn22[] = {         \n"
-"        9.99999992049799098E-1,   \n"
-"        1.33154163936765307,      \n"
-"        8.78115804155881782E-1,   \n"
-"        3.31899559578213215E-1,   \n"
-"        7.14193832506776067E-2,   \n"
-"        7.06940843763253131E-3    \n"
-"      };                          \n"
-"        double qn22[] = {         \n"
-"        1.00000000000000000,      \n"
-"        2.45992070144245533,      \n"
-"        2.65383972869775752,      \n"
-"        1.61876655543871376,      \n"
-"        5.94651311286481502E-1,   \n"
-"        1.26579413030177940E-1,   \n"
-"        1.25304936549413393E-2    \n"
-"       };                         \n"
-"        pn = pn22;                \n"
-"        qn = qn22;                \n"
-"      }                           \n"
-"      else                        \n"
-"                                  \n"
-"       {                          \n"
-"            double pn60[] = {\n"
-"            9.99921140009714409E-1,\n"
-"            1.62356584489366647,\n"
-"            1.26739901455873222,\n"
-"            5.81528574177741135E-1,\n"
-"            1.57289620742838702E-1,\n"
-"            2.25716982919217555E-2\n"
-"            };\n"
-"            double qn60[] = {\n"
-"            1.00000000000000000,\n"
-"            2.75143870676376208,\n"
-"            3.37367334657284535,\n"
-"            2.38574194785344389,\n"
-"            1.05074004614827206,\n"
-"            2.78788439273628983E-1,\n"
-"            4.00072964526861362E-2\n"
-"            };\n"
-"            pn = pn60;\n"
-"            qn = qn60;\n"
-"       }\n"
-"    for ( unsigned int i = 0; i < 6; ++i )  \n"
-"    {\n"
-"        fPSum += pn[i]*fXPow;\n"
-"        fQSum += qn[i]*fXPow;\n"
-"        fXPow *= x;\n"
-"    }\n"
-"    fQSum += qn[6]*fXPow;\n"
-"    *fVal = exp((-1.0)*x*x)*fPSum*pow(fQSum, -1.0);\n"
-"   }\n";
-std::string lcl_Erfc2654Decl=
-"void lcl_Erfc2654( double x, double *fVal );\n";
-std::string lcl_Erfc2654 =
-"void lcl_Erfc2654( double x, double *fVal )\n"
-"{\n"
-"    double pn[] = {\n"
-"        5.64189583547756078E-1,\n"
-"        8.80253746105525775,\n"
-"        3.84683103716117320E1,\n"
-"        4.77209965874436377E1,\n"
-"        8.08040729052301677\n"
-"    };\n"
-"    double qn[] = {\n"
-"        1.00000000000000000,\n"
-"        1.61020914205869003E1,\n"
-"        7.54843505665954743E1,\n"
-"        1.12123870801026015E2,\n"
-"        3.73997570145040850E1\n"
-"    };\n"
-"\n"
-"    double fPSum = 0.0;\n"
-"    double fQSum = 0.0;\n"
-"    double fXPow = 1.0;\n"
-"\n"
-"    for ( unsigned int i = 0; i <= 4; ++i )\n"
-"    {\n"
-"        fPSum += pn[i]*fXPow;       \n"
-"        fQSum += qn[i]*fXPow;\n"
-"        fXPow *= pow(x*x, -1.0);\n"
-"    }\n"
-"    *fVal = exp((-1.0)*x*x)*fPSum*pow(x*fQSum, -1.0);\n"
-"}\n";
-std::string lcl_Erf0065Decl=
-"void lcl_Erf0065( double x, double *fVal );\n";
-std::string lcl_Erf0065 =
-"void lcl_Erf0065( double x, double *fVal )\n"
-"   {\n"
-"        double pn[] = {\n"
-"            1.12837916709551256,\n"
-"            1.35894887627277916E-1,\n"
-"            4.03259488531795274E-2,\n"
-"            1.20339380863079457E-3,\n"
-"            6.49254556481904354E-5\n"
-"            };\n"
-"        double qn[] = {\n"
-"            1.00000000000000000,\n"
-"            4.53767041780002545E-1,\n"
-"            8.69936222615385890E-2,\n"
-"            8.49717371168693357E-3,\n"
-"            3.64915280629351082E-4\n"
-"            };\n"
-"        double fPSum = 0.0;\n"
-"        double fQSum = 0.0;\n"
-"        double fXPow = 1.0;\n"
-"        for ( unsigned int i = 0; i <= 4; ++i )\n"
-"        {\n"
-"            fPSum += pn[i]*fXPow;\n"
-"            fQSum += qn[i]*fXPow;\n"
-"            fXPow *= x*x;\n"
-"        }\n"
-"        *fVal = x * fPSum * pow(fQSum, -1.0);\n"
-"   }\n";
-std::string rtl_math_erf_rdDecl=
-"double rtl_math_erf_rd( double x );\n";
-std::string rtl_math_erf_rd =
-" double rtl_math_erf_rd( double x )\n"
-" {\n"
-"     if( x == 0.0 )\n"
-"         return 0.0;\n"
-"     bool bNegative = false;\n"
-"     if ( x < 0.0 )\n"
-"     {\n"
-"         x = fabs( x );\n"
-"         bNegative = true;\n"
-"     }\n"
-"     double fErf = 1.0;\n"
-"     if ( x < 1.0e-10 )\n"
-"         fErf = (double) (x*1.1283791670955125738961589031215452);\n"
-"     else if ( x < 0.65 )\n"
-"         lcl_Erf0065( x, &fErf );\n"
-"     if ( bNegative )\n"
-"         fErf *= (-1.0);\n"
-"     return fErf;\n"
-" }\n";
-std::string rtl_math_erfc_rdDecl=
-"double rtl_math_erfc_rd( double x );\n";
-std::string rtl_math_erfc_rd =
-" double rtl_math_erfc_rd( double x )\n"
-" {\n"
-"     if ( x == 0.0 )\n"
-"        return 1.0;\n"
-"     bool bNegative = false;\n"
-"     if ( x < 0.0 )\n"
-"     {\n"
-"         x = fabs( x );\n"
-"         bNegative = true;\n"
-"     }\n"
-"     double fErfc = 0.0;\n"
-"     if ( x >= 0.65 )\n"
-"     {\n"
-"         if ( x < 6.0 )\n"
-"             lcl_Erfc0600( x, &fErfc );\n"
-"         else\n"
-"             lcl_Erfc2654( x, &fErfc );\n"
-"     }\n"
-"     else\n"
-"         fErfc = 1.0 - rtl_math_erf_rd( x );\n"
-"     if ( bNegative )\n"
-"         fErfc = 2.0 - fErfc;\n"
-"     return fErfc;\n"
-" }\n";
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list