[Libreoffice-commits] core.git: sc/source

I-Jui Sung (Ray) ray at multicorewareinc.com
Tue Nov 19 21:04:10 PST 2013


 sc/source/core/opencl/formulagroupcl.cxx        |   22 ++++++++++++----------
 sc/source/core/opencl/formulagroupcl_public.hxx |    6 +++++-
 2 files changed, 17 insertions(+), 11 deletions(-)

New commits:
commit 5b1480e33d71ee49bcfb73b3a0144ca6fc2c5e6b
Author: I-Jui (Ray) Sung <ray at multicorewareinc.com>
Date:   Tue Nov 19 22:53:42 2013 -0600

    GPU Calc: optimize average() handling
    
    Change-Id: I2f9a813e15068867f218631e9ebadd3ea2c38c95

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index f480e54..40df1ae 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -528,7 +528,6 @@ return nCurWindowSize;
                             temp1 << "){\n\t\t";
                             temp1 <<  mpCodeGen->Gen2(GenSlidingWindowDeclRef(), "tmp");
                             temp1 << ";\n\t\t\t";
-                            temp1 << "nCount += 1;\n\t\t";
                             temp1 << "}\n\t";
                         }
                         ss << temp1.str();
@@ -544,7 +543,6 @@ return nCurWindowSize;
                         temp2 << "tmp = ";
                         temp2 << mpCodeGen->Gen2(GenSlidingWindowDeclRef(), "tmp");
                         temp2 << ";\n\t\t\t";
-                        temp2 << "nCount += 1;\n\t\t";
                         temp2 << "}\n\t";
                     }
                     ss << temp2.str();
@@ -568,7 +566,6 @@ return nCurWindowSize;
                             temp1 << "tmp = ";
                             temp1 << mpCodeGen->Gen2(GenSlidingWindowDeclRef(), "tmp");
                             temp1 << ";\n\t\t\t";
-                            temp1 << "nCount += 1;\n\t\t";
                         }
                         ss << temp1.str();
                     }
@@ -581,7 +578,6 @@ return nCurWindowSize;
                         temp2 << "tmp = ";
                         temp2 << mpCodeGen->Gen2(GenSlidingWindowDeclRef(), "tmp");
                         temp2 << ";\n\t\t\t";
-                        temp2 << "nCount += 1;\n\t\t";
                     }
                     ss << temp2.str();
                 }
@@ -847,7 +843,8 @@ public:
         ss << ") {\n\t";
         ss << "double tmp = " << GetBottom() <<";\n\t";
         ss << "int gid0 = get_global_id(0);\n\t";
-        ss << "int nCount = 0;\n\t";
+        if (isAverage())
+            ss << "int nCount = 0;\n\t";
         ss << "double tmpBottom;\n\t";
         unsigned i = vSubArguments.size();
         size_t nItems = 0;
@@ -901,9 +898,6 @@ public:
                 }
                 else
                 {
-#ifdef  ISNAN
-                    ss << "nCount += 1;\n\t\t";
-#endif
                     nItems += 1;
                 }
             }
@@ -920,7 +914,6 @@ public:
                 ss << "tmp = ";
                 ss << Gen2(vSubArguments[i]->GenSlidingWindowDeclRef(), "tmp");
                 ss << ";\n\t\t\t";
-                ss << "nCount += 1;\n\t\t";
                 ss << "}\n\t";
                 ss << "}\n\t";
             }
@@ -1266,7 +1259,16 @@ public:
     virtual std::string BinFuncName(void) const { return "fsum"; }
 };
 
-class OpAverage: public OpSum {
+class OpAverage: public Reduction {
+public:
+    virtual std::string GetBottom(void) { return "0"; }
+    virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
+    {
+        std::stringstream ss;
+        ss << "fsum_count(" << lhs <<","<< rhs<<", &nCount)";
+        return ss.str();
+    }
+    virtual std::string BinFuncName(void) const { return "fsum"; }
     virtual bool isAverage() const { return true; }
 };
 
diff --git a/sc/source/core/opencl/formulagroupcl_public.hxx b/sc/source/core/opencl/formulagroupcl_public.hxx
index ccee5e1..d001a06 100644
--- a/sc/source/core/opencl/formulagroupcl_public.hxx
+++ b/sc/source/core/opencl/formulagroupcl_public.hxx
@@ -12,7 +12,11 @@
 
 const char* publicFunc =
  "int isNan(double a) { return a != a; }\n"
- "double legalize(double a, double b) { return isNan(a)?b:a; }\n"
+ "double fsum_count(double a, double b, __private int *p) {\n"
+ "    bool t = isNan(a);\n"
+ "    (*p) += t?0:1;\n"
+ "    return t?b:a+b;\n"
+ "}\n"
  "double fsum(double a, double b) { return isNan(a)?b:a+b; }\n"
  "double fsub(double a, double b) { return a-b; }\n"
  "double fdiv(double a, double b) { return a/b; }\n"


More information about the Libreoffice-commits mailing list