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

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


 sc/source/core/opencl/formulagroupcl.cxx        |   13 ++++++++++---
 sc/source/core/opencl/formulagroupcl_public.hxx |    1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit d7e4e5d35e66dbfcc30576d198e393661d84f616
Author: I-Jui (Ray) Sung <ray at multicorewareinc.com>
Date:   Tue Nov 19 00:22:23 2013 -0600

    GPU Calc: add an inline function to legalize inputs for reduction.
    
    Change-Id: Ibcede4a33d7b8b1073d6ecfb49abbc78b31a2f35

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 037760e..abd3230 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -470,11 +470,18 @@ public:
             ss << "    int loopOffset = l*512;\n";
             ss << "    if((loopOffset + lidx + offset + 256) < min( offset + windowSize, arrayLength))\n";
             ss << "        tmp = ";
-            ss << mpCodeGen->Gen2("fsum(A[loopOffset + lidx + offset], 0)",
-                "fsum(A[loopOffset + lidx + offset + 256], 0)");
+            ss << mpCodeGen->Gen2(
+                    std::string(
+                        "legalize(A[loopOffset + lidx + offset], ")+
+                    mpCodeGen->GetBottom() +")",
+                    std::string(
+                        "legalize(A[loopOffset + lidx + offset + 256], ")+
+                    mpCodeGen->GetBottom() +")"
+                    );
             ss << ";";
             ss << "    else if ((loopOffset + lidx + offset) < min(offset + windowSize, arrayLength))\n";
-            ss << "        tmp = fsum(A[loopOffset + lidx + offset], 0);\n";
+            ss << "        tmp = legalize(A[loopOffset + lidx + offset],";
+            ss << mpCodeGen->GetBottom() << ");\n";
             ss << "    shm_buf[lidx] = tmp;\n";
             ss << "    barrier(CLK_LOCAL_MEM_FENCE);\n";
             ss << "    for (int i = 128; i >0; i/=2) {\n";
diff --git a/sc/source/core/opencl/formulagroupcl_public.hxx b/sc/source/core/opencl/formulagroupcl_public.hxx
index e50de37..ccee5e1 100644
--- a/sc/source/core/opencl/formulagroupcl_public.hxx
+++ b/sc/source/core/opencl/formulagroupcl_public.hxx
@@ -12,6 +12,7 @@
 
 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(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