[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |9 - 1 file changed, 8 insertions(+), 1 deletion(-) New commits: commit 4b4c1660684bb495aa05185a4b9e0c3eb0ea2770 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Wed Nov 20 08:49:27 2013 -0600 GPU Calc: re-enable parallel SUMIFS Change-Id: I70797f089ead267d223772b73c4d093813716029 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 6e4df20..ad28bd2 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -434,7 +434,14 @@ public: bIsStartFixed = mpDVR-IsStartFixed(); bIsEndFixed = mpDVR-IsEndFixed(); } - +// Should only be called by SumIfs. Yikes! +virtual bool NeedParallelReduction(void) const +{ +assert(dynamic_castOpSumIfs*(mpCodeGen.get())); +return GetWindowSize() 100 +( (GetStartFixed() GetEndFixed()) || + (!GetStartFixed() !GetEndFixed()) ) ; +} virtual void GenSlidingWindowFunction(std::stringstream ) {} virtual std::string GenSlidingWindowDeclRef(bool=false) const ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |1 + 1 file changed, 1 insertion(+) New commits: commit 4a37d4a33a6d56f6d1c7a9cb3d92a06e98ef49a3 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Wed Nov 20 16:24:16 2013 -0600 GPU Calc: fixed missing assigment operator in unrolling Change-Id: Ie7060900f4f90b789a16b1341ec1c2c905410ee1 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index ad28bd2..44584b8 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -533,6 +533,7 @@ return nCurWindowSize; if(count==0){ temp1 if(i + gid0 mpDVR-GetArrayLength(); temp1 ){\n\t\t; +temp1 tmp = ; temp1 mpCodeGen-Gen2(GenSlidingWindowDeclRef(), tmp); temp1 ;\n\t\t\t; temp1 }\n\t; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 290 +++ 1 file changed, 186 insertions(+), 104 deletions(-) New commits: commit cd67d819b45054ee8cbbb6a0cb261f3ef9b5b659 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Tue Nov 19 16:42:56 2013 -0600 GPU Calc: separate out parallel reduction from DynamicKernelSlidingArgument Create a new class ParallelReductionVectorRef to straighten out code generation and marshaling logic between sequential and parallel code generation alternatives. Change-Id: Id029ad441f80712f8e7396dcd985e3363ce08ff8 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 2d806aa..87f4d89 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -409,6 +409,7 @@ protected: /// Handling a Double Vector that is used as a sliding window input /// to either a sliding window average or sum-of-products +/// Generate a sequential loop for reductions class OpSum; // Forward Declaration class OpAverage; // Forward Declaration class OpMin; // Forward Declaration @@ -430,79 +431,8 @@ public: bIsStartFixed = mpDVR-IsStartFixed(); bIsEndFixed = mpDVR-IsEndFixed(); } -virtual bool NeedParallelReduction(void) const -{ -if ((dynamic_castOpSum*(mpCodeGen.get()) - !dynamic_castOpAverage*(mpCodeGen.get())) || -dynamic_castOpMin*(mpCodeGen.get()) || -dynamic_castOpMax*(mpCodeGen.get()) || -dynamic_castOpSumIfs*(mpCodeGen.get())) -return GetWindowSize() 100 -( (GetStartFixed() GetEndFixed()) || - (!GetStartFixed() !GetEndFixed()) ) ; -else -return false; -} -virtual void GenSlidingWindowFunction(std::stringstream ss) { -if (!dynamic_castOpSumIfs*(mpCodeGen.get()) - NeedParallelReduction()) -{ -std::string name = Base::GetName(); -ss __kernel void name; -ss _reduction(__global double* A, -__global double *result,int arrayLength,int windowSize){\n; -ss double tmp, current_result = -mpCodeGen-GetBottom(); -ss ;\n; -ss int writePos = get_group_id(1);\n; -ss int lidx = get_local_id(0);\n; -ss __local double shm_buf[256];\n; -if (mpDVR-IsStartFixed() mpDVR-IsEndFixed()) -ss int offset = 0;\n; -else if (!mpDVR-IsStartFixed() !mpDVR-IsEndFixed()) -ss int offset = get_group_id(1);\n; -else -throw Unhandled(); -ss barrier(CLK_LOCAL_MEM_FENCE);\n; -ss int loop = arrayLength/512 + 1;\n; -ss for (int l=0; lloop; l++){\n; -ss tmp = mpCodeGen-GetBottom() ;\n; -ss int loopOffset = l*512;\n; -ss if((loopOffset + lidx + offset + 256) min( offset + windowSize, arrayLength))\n; -ss tmp = ; -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 = 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; -ss if (lidx i)\n; -ss shm_buf[lidx] = ; -ss mpCodeGen-Gen2(shm_buf[lidx], shm_buf[lidx + i]); -ss ;; -ss barrier(CLK_LOCAL_MEM_FENCE);\n; -ss }\n; -ss if (lidx == 0)\n; -ss current_result =; -ss mpCodeGen-Gen2(current_result, shm_buf[0]); -ss ;\n; -ss barrier(CLK_LOCAL_MEM_FENCE);\n; -ss }\n; -ss if (lidx == 0)\n; -ss result[writePos] = current_result;\n; -ss }\n; -} - } +virtual void GenSlidingWindowFunction(std::stringstream ) {} virtual std::string GenSlidingWindowDeclRef(bool=false) const { @@ -519,26 +449,7 @@ public: { assert(mpDVR); size_t nCurWindowSize = mpDVR-GetRefRowSize(); -if (!dynamic_castOpSumIfs*(mpCodeGen.get()) - NeedParallelReduction()) -{ -if ((!bIsStartFixed !bIsEndFixed) || -
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) New commits: commit 06c8a7a20517441e3f001a993cbeaa4e3fa69a54 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Tue Nov 19 19:24:06 2013 -0600 GPU Calc: parallel reduction version of COUNT Change-Id: Ia90b5aaf044379b5bfc55ec525f9be2f6fda6028 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 87f4d89..d283174 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -687,19 +687,13 @@ public: ss tmp = mpCodeGen-GetBottom() ;\n; ss int loopOffset = l*512;\n; ss if((loopOffset + lidx + offset + 256) min( offset + windowSize, arrayLength))\n; -ss tmp = ; -ss mpCodeGen-Gen2( -std::string( -legalize(A[loopOffset + lidx + offset], )+ -mpCodeGen-GetBottom() +), -std::string( -legalize(A[loopOffset + lidx + offset + 256], )+ -mpCodeGen-GetBottom() +) -); -ss ;\n; +ss tmp = mpCodeGen-Gen2( +A[loopOffset + lidx + offset], tmp) ;\n; +ss tmp = mpCodeGen-Gen2( +A[loopOffset + lidx + offset + 256], tmp) ;\n; ss else if ((loopOffset + lidx + offset) min(offset + windowSize, arrayLength))\n; -ss tmp = legalize(A[loopOffset + lidx + offset],; -ss mpCodeGen-GetBottom() );\n; +ss tmp = mpCodeGen-Gen2( +A[loopOffset + lidx + offset], tmp) ;\n; ss shm_buf[lidx] = tmp;\n; ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss for (int i = 128; i 0; i/=2) {\n; @@ -1226,11 +1220,7 @@ public: virtual std::string Gen2(const std::string lhs, const std::string rhs) const { std::stringstream ss; -#ifdef ISNAN -ss (0 == lhs )? tmp : ( rhs+1.0); -#else ss (isNan( lhs )?rhs:rhs+1.0); -#endif return ss.str(); } virtual std::string BinFuncName(void) const { return fcount; } @@ -1556,8 +1546,8 @@ DynamicKernelArgument *VectorRefFactory(const std::string s, { return new DynamicKernelSlidingArgumentBase(s, ft, pCodeGen, index); } -// COUNT is not supported yet -else if (dynamic_castOpCount*(pCodeGen.get())) +// Sub is not a reduction per se +else if (dynamic_castOpSub*(pCodeGen.get())) { return new DynamicKernelSlidingArgumentBase(s, ft, pCodeGen, index); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
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 1f3c1592da05740e695ef3502ca8f3cb4cdaa62b Author: I-Jui (Ray) Sung r...@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 dbefbf8..6e4df20 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 ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) New commits: commit 9a28c1537c8687b72a4e89b80ed18ea46d77757e Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 03:09:24 2013 -0600 GPU Calc: re-enable parallel sum reduction after fixing regressions Change-Id: Id274575e731c413e8e9b808ae5e651efe10f7b03 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 1594075..f6e6baf 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -405,6 +405,7 @@ protected: /// Handling a Double Vector that is used as a sliding window input /// to either a sliding window average or sum-of-products class OpSum; // Forward Declaration +class OpAverage; // Forward Declaration templateclass Base class DynamicKernelSlidingArgument: public Base { @@ -423,9 +424,13 @@ public: } virtual bool NeedParallelReduction(void) const { -return GetWindowSize() 100 -( (GetStartFixed() GetEndFixed()) || - (!GetStartFixed() !GetEndFixed()) ) ; +if (dynamic_castOpSum*(mpCodeGen.get()) + !dynamic_castOpAverage*(mpCodeGen.get())) +return GetWindowSize() 100 +( (GetStartFixed() GetEndFixed()) || + (!GetStartFixed() !GetEndFixed()) ) ; +else +return false; } virtual void GenSlidingWindowFunction(std::stringstream ss) { if (dynamic_castOpSum*(mpCodeGen.get()) NeedParallelReduction()) @@ -496,7 +501,7 @@ public: { // set 100 as a temporary threshold for invoking reduction // kernel in NeedParalleLReduction function -if (/*NeedParallelReduction()*/false) +if (NeedParallelReduction()) { std::string temp = Base::GetName() + [gid0]; ss tmp = ; @@ -511,7 +516,7 @@ public: { // set 100 as a temporary threshold for invoking reduction // kernel in NeedParalleLReduction function -if (NeedParallelReduction()false) +if (NeedParallelReduction()) { std::string temp = Base::GetName() + [0]; ss tmp = ; @@ -563,7 +568,7 @@ public: virtual size_t Marshal(cl_kernel k, int argno, int w, cl_program mpProgram) { -if (!NeedParallelReduction() || true) +if (!NeedParallelReduction()) return Base::Marshal(k, argno, w, mpProgram); assert(Base::mpClmem == NULL); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 35 --- 1 file changed, 23 insertions(+), 12 deletions(-) New commits: commit 6a31821484464565a11e579c619c80598532be82 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 18:28:34 2013 -0600 GPU Calc: enables parallel min/max reduction Change-Id: I86e0b40d284a1bfe7414f02333c616556d6d568c diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 17f4afb..46c8224 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -407,6 +407,8 @@ protected: /// to either a sliding window average or sum-of-products class OpSum; // Forward Declaration class OpAverage; // Forward Declaration +class OpMin; // Forward Declaration +class OpMax; // Forward Declaration templateclass Base class DynamicKernelSlidingArgument: public Base { @@ -428,6 +430,8 @@ public: { if ((dynamic_castOpSum*(mpCodeGen.get()) !dynamic_castOpAverage*(mpCodeGen.get())) || +dynamic_castOpMin*(mpCodeGen.get()) || +dynamic_castOpMax*(mpCodeGen.get()) || dynamic_castOpSumIfs*(mpCodeGen.get())) return GetWindowSize() 4 ( (GetStartFixed() GetEndFixed()) || @@ -436,13 +440,16 @@ public: return false; } virtual void GenSlidingWindowFunction(std::stringstream ss) { -if (dynamic_castOpSum*(mpCodeGen.get()) NeedParallelReduction()) +if (!dynamic_castOpSumIfs*(mpCodeGen.get()) + NeedParallelReduction()) { std::string name = Base::GetName(); ss __kernel void name; ss _reduction(__global double* A, __global double *result,int arrayLength,int windowSize){\n; -ss double tmp, current_result = 0.0;\n; +ss double tmp, current_result = +mpCodeGen-GetBottom(); +ss ;\n; ss int writePos = get_group_id(1);\n; ss int lidx = get_local_id(0);\n; ss __local double shm_buf[256];\n; @@ -455,22 +462,28 @@ public: ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss int loop = arrayLength/512 + 1;\n; ss for (int l=0; lloop; l++){\n; -ss tmp = 0.0;\n; +ss tmp = mpCodeGen-GetBottom() ;\n; ss int loopOffset = l*512;\n; ss if((loopOffset + lidx + offset + 256) min( offset + windowSize, arrayLength))\n; -ss tmp = fsum(A[loopOffset + lidx + offset], 0) + -fsum(A[loopOffset + lidx + offset + 256], 0);\n; +ss tmp = ; +ss mpCodeGen-Gen2(fsum(A[loopOffset + lidx + offset], 0), +fsum(A[loopOffset + lidx + offset + 256], 0)); +ss ;; ss else if ((loopOffset + lidx + offset) min(offset + windowSize, arrayLength))\n; ss tmp = fsum(A[loopOffset + lidx + offset], 0);\n; ss shm_buf[lidx] = tmp;\n; ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss for (int i = 128; i 0; i/=2) {\n; ss if (lidx i)\n; -ss shm_buf[lidx] += shm_buf[lidx + i];\n; +ss shm_buf[lidx] = ; +ss mpCodeGen-Gen2(shm_buf[lidx], shm_buf[lidx + i]); +ss ;; ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss }\n; ss if (lidx == 0)\n; -ss current_result += shm_buf[0];\n; +ss current_result =; +ss mpCodeGen-Gen2(current_result, shm_buf[0]); +ss ;\n; ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss }\n; ss if (lidx == 0)\n; @@ -495,7 +508,8 @@ public: { assert(mpDVR); size_t nCurWindowSize = mpDVR-GetRefRowSize(); -if (dynamic_castOpSum*(mpCodeGen.get())) +if (!dynamic_castOpSumIfs*(mpCodeGen.get()) + NeedParallelReduction()) { if ((!bIsStartFixed !bIsEndFixed) || (bIsStartFixed bIsEndFixed)) @@ -589,10 +603,7 @@ public: if (CL_SUCCESS != err) throw OpenCLError(err); // reproduce the reduction function name -std::string kernelName; -if (dynamic_castOpSum*(mpCodeGen.get())) -kernelName = Base::GetName() + _reduction; -else throw Unhandled(); +std::string kernelName = Base::GetName() + _reduction; cl_kernel redKernel = clCreateKernel(mpProgram, kernelName.c_str(), err); if (err != CL_SUCCESS) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx|6 -- sc/source/core/opencl/formulagroupcl_public.hxx |8 2 files changed, 12 insertions(+), 2 deletions(-) New commits: commit 4b02e8daed896714962bd8fcbe592bebd94a76bd Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 19:26:48 2013 -0600 GPU Calc: add compile time option for using fmin/fmax intrinsics Change-Id: I791d6c8f4335ab2c2618529f2e3d22d59c4f0b5a diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 46c8224..c518cf4 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -24,6 +24,8 @@ #include op_logical.hxx #include op_statistical.hxx #include op_array.hxx +// Comment out this to turn off FMIN and FMAX intrinsics +#define USE_FMIN_FMAX 1 #include formulagroupcl_public.hxx #include list @@ -1038,7 +1040,7 @@ public: virtual std::string GetBottom(void) { return MAXFLOAT; } virtual std::string Gen2(const std::string lhs, const std::string rhs) const { -return fmin(+lhs + , + rhs +); +return mcw_fmin(+lhs + , + rhs +); } virtual std::string BinFuncName(void) const { return min; } }; @@ -1048,7 +1050,7 @@ public: virtual std::string GetBottom(void) { return -MAXFLOAT; } virtual std::string Gen2(const std::string lhs, const std::string rhs) const { -return fmax(+lhs + , + rhs +); +return mcw_fmax(+lhs + , + rhs +); } virtual std::string BinFuncName(void) const { return max; } }; diff --git a/sc/source/core/opencl/formulagroupcl_public.hxx b/sc/source/core/opencl/formulagroupcl_public.hxx index 996c898..e50de37 100644 --- a/sc/source/core/opencl/formulagroupcl_public.hxx +++ b/sc/source/core/opencl/formulagroupcl_public.hxx @@ -16,6 +16,14 @@ const char* publicFunc = double fsub(double a, double b) { return a-b; }\n double fdiv(double a, double b) { return a/b; }\n double strequal(unsigned a, unsigned b) { return (a==b)?1.0:0; }\n +#ifdef USE_FMIN_FMAX + double mcw_fmin(double a, double b) { return fmin(a, b); }\n + double mcw_fmax(double a, double b) { return fmax(a, b); }\n +#else + double mcw_fmin(double a, double b) { return ab?b:a; }\n + double mcw_fmax(double a, double b) { return ab?a:b; }\n +#endif + ; #endif ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 246 ++- 1 file changed, 240 insertions(+), 6 deletions(-) New commits: commit d8b52aa7bc79bb2663841d040629aae97710c87a Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 23:19:15 2013 -0600 GPU Calc: unrolling of sequential reduction loops for DoubleVectorRefs Change-Id: I749da2d08a09ead56f0b151a317052b8960926ca diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index c518cf4..7e61822 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -41,6 +41,8 @@ #include boost/scoped_ptr.hpp +#define UNROLLING + using namespace formula; namespace sc { namespace opencl { @@ -435,7 +437,7 @@ public: dynamic_castOpMin*(mpCodeGen.get()) || dynamic_castOpMax*(mpCodeGen.get()) || dynamic_castOpSumIfs*(mpCodeGen.get())) -return GetWindowSize() 4 +return GetWindowSize() 100 ( (GetStartFixed() GetEndFixed()) || (!GetStartFixed() !GetEndFixed()) ) ; else @@ -529,8 +531,9 @@ public: } } } +// original for loop +#ifndef UNROLLING needBody = true; - // No need to generate a for-loop for degenerated cases if (nCurWindowSize == 1) { @@ -573,9 +576,132 @@ public: std::min(mpDVR-GetArrayLength(), nCurWindowSize); ss 0; i limit ; i++){\n\t\t; } +return nCurWindowSize; +#endif -return nCurWindowSize; -} + + +#ifdef UNROLLING +{ +if (!mpDVR-IsStartFixed() mpDVR-IsEndFixed()) { +ss for (int i = ; +ss gid0; impDVR-GetArrayLength(); +ssinCurWindowSize ; i++){\n\t\t; +needBody = true; +return nCurWindowSize; +} else if (mpDVR-IsStartFixed() !mpDVR-IsEndFixed()) { +ss for (int i = ; +ss 0; impDVR-GetArrayLength(); +ssi gid0+ nCurWindowSize ; i++){\n\t\t; +needBody = true; +return nCurWindowSize; +} else if (!mpDVR-IsStartFixed() !mpDVR-IsEndFixed()){ +ss tmpBottom = mpCodeGen-GetBottom() ;\n\t; +ss {int i;\n\t; +std::stringstream temp1,temp2; +int outLoopSize = 16; +if ( nCurWindowSize/outLoopSize != 0){ +ss for(int outLoop=0; outLoop nCurWindowSize/outLoopSize ; outLoop++){\n\t; +for(int count=0; count outLoopSize; count++){ +ss i = outLoop*outLoopSize+count;\n\t; +if(count==0){ +temp1 if(i + gid0 mpDVR-GetArrayLength(); +temp1 ){\n\t\t; +temp1 if (isNan(; +temp1 GenSlidingWindowDeclRef(); +temp1 )){\n\t\t\t; +temp1 tmp = ; +temp1 mpCodeGen-Gen2(tmpBottom, tmp) ;\n\t\t; +temp1 }else{\n\t\t\t; +temp1 tmp = ; +temp1 mpCodeGen-Gen2(GenSlidingWindowDeclRef(), tmp); +temp1 ;\n\t\t\t; +temp1 nCount += 1;\n\t\t; +temp1 }\n\t; +temp1 }\n\t; +} +ss temp1.str(); +} +ss }\n\t; +} +// The residual of mod outLoopSize +for(unsigned int count=nCurWindowSize/outLoopSize*outLoopSize; count nCurWindowSize; count++){ +ss i = count;\n\t; +if(count==nCurWindowSize/outLoopSize*outLoopSize){ +temp2 if(i + gid0mpDVR-GetArrayLength(); +temp2 ){\n\t\t; +temp2 if (isNan(; +temp2 GenSlidingWindowDeclRef(); +temp2 )){\n\t\t\t; +temp2 tmp = ; +temp2 mpCodeGen-Gen2(tmpBottom, tmp) ;\n\t\t; +temp2 }else{\n\t\t\t; +temp2 tmp = ; +temp2 mpCodeGen-Gen2(GenSlidingWindowDeclRef(), tmp); +temp2 ;\n\t\t\t; +temp2 nCount += 1;\n\t\t; +temp2 }\n\t; +temp2 }\n\t; +} +ss temp2.str(); +} +ss } // to scope the int i declaration\n; +needBody = false; +return nCurWindowSize; +}
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
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 77cb1767f723e2a3a07c6cb75ff46bef26eb82db Author: I-Jui (Ray) Sung r...@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 7e61822..2d806aa 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 ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 37 +++ sc/source/core/opencl/op_math.cxx|4 ++- 2 files changed, 21 insertions(+), 20 deletions(-) New commits: commit 12172c73b45e453c72e3afdc4459a6642711d23e Author: Wei Wei wei...@multicorewareinc.com Date: Sun Nov 17 20:43:18 2013 -0600 GPU calc: refactor code for sum reduction and sumifs naming rule Change-Id: I685d263337bebe236befa5e5f45356336936c998 Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index dfb2037..eb9a28f 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -411,7 +411,7 @@ class DynamicKernelSlidingArgument: public Base public: DynamicKernelSlidingArgument(const std::string s, FormulaTreeNodeRef ft, boost::shared_ptrSlidingFunctionBase CodeGen): -Base(s, ft), mpCodeGen(CodeGen), needReductionKernel(true), mpClmem2(NULL) +Base(s, ft), mpCodeGen(CodeGen), mpClmem2(NULL) { FormulaToken *t = ft-GetFormulaToken(); if (t-GetType() != formula::svDoubleVectorRef) @@ -428,7 +428,7 @@ public: (!GetStartFixed() !GetEndFixed()) ) ; } virtual void GenSlidingWindowFunction(std::stringstream ss) { -if (dynamic_castOpSum*(mpCodeGen.get())) +if (dynamic_castOpSum*(mpCodeGen.get()) NeedParallelReduction()) { std::string name = Base::GetName(); ss __kernel void name; @@ -436,20 +436,23 @@ public: __global double *result,int arrayLength,int windowSize){\n; ss double tmp, current_result = 0.0;\n; ss int writePos = get_group_id(1);\n; -ss int offset = get_group_id(1);\n; ss int lidx = get_local_id(0);\n; ss __local double shm_buf[256];\n; -ss if (arrayLength == windowSize)\n; -ss offset = 0;\n; +if (mpDVR-IsStartFixed() mpDVR-IsEndFixed()) +ss int offset = 0;\n; +else if (!mpDVR-IsStartFixed() !mpDVR-IsEndFixed()) +ss int offset = get_group_id(1);\n; +else +throw Unhandled(); ss barrier(CLK_LOCAL_MEM_FENCE);\n; ss int loop = arrayLength/512 + 1;\n; ss for (int l=0; lloop; l++){\n; ss tmp = 0.0;\n; ss int loopOffset = l*512;\n; -ss if((loopOffset + lidx + offset + 256) ( offset + windowSize))\n; +ss if((loopOffset + lidx + offset + 256) min( offset + windowSize, arrayLength))\n; ss tmp = A[loopOffset + lidx + offset] + A[loopOffset + lidx + offset + 256];\n; -ss else if ((loopOffset + lidx + offset) ( offset + windowSize))\n; +ss else if ((loopOffset + lidx + offset) min(offset + windowSize, arrayLength))\n; ss tmp = A[loopOffset + lidx + offset];\n; ss shm_buf[lidx] = tmp;\n; ss barrier(CLK_LOCAL_MEM_FENCE);\n; @@ -487,38 +490,35 @@ public: { if (!bIsStartFixed !bIsEndFixed) { -// set 100 as a threshold for invoking reduction kernel -// Ray: temporarily turn off parallel sum reduction -if (false /*nCurWindowSize 100*/) +// set 100 as a temporary threshold for invoking reduction +// kernel in NeedParalleLReduction function +if (NeedParallelReduction()) { std::string temp = Base::GetName() + [gid0]; ss tmp = ; ss mpCodeGen-Gen2(temp, tmp); ss ;\n\t; needBody = false; -needReductionKernel = false; return nCurWindowSize; } } if (bIsStartFixed bIsEndFixed) { -// set 100 as a threshold for invoking reduction kernel -// Ray: temporarily turn off parallel sum reduction -if (false /* nCurWindowSize 100 */) +// set 100 as a temporary threshold for invoking reduction +// kernel in NeedParalleLReduction function +if (NeedParallelReduction()) { std::string temp = Base::GetName() + [0]; ss tmp = ; ss mpCodeGen-Gen2(temp, tmp); ss ;\n\t; needBody = false; -needReductionKernel = false; return nCurWindowSize; } } } needBody = true; -needReductionKernel =
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 48 +++- sc/source/core/opencl/opbase.cxx | 53 +++ sc/source/core/opencl/opbase.hxx | 53 +-- 3 files changed, 96 insertions(+), 58 deletions(-) New commits: commit c58a2bd6447de7467c65e1964484e2b5811c6cee Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Sun Nov 17 22:33:50 2013 -0600 GPU Calc: refactor: separate VectorRef out of DynamicKernelArgument Now DynamicKernelArgument is more an abstract base. Change-Id: Icc70fa9fe4ed2db3c5483099d99584ba30ac38f6 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index eb9a28f..fd4be3f 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -45,7 +45,7 @@ namespace sc { namespace opencl { /// Map the buffer used by an argument and do necessary argument setting -size_t DynamicKernelArgument::Marshal(cl_kernel k, int argno, int, cl_program) +size_t VectorRef::Marshal(cl_kernel k, int argno, int, cl_program) { FormulaToken *ref = mFormulaTree-GetFormulaToken(); assert(mpClmem == NULL); @@ -129,7 +129,6 @@ public: virtual size_t Marshal(cl_kernel k, int argno, int, cl_program) { FormulaToken *ref = mFormulaTree-GetFormulaToken(); -assert(mpClmem == NULL); cl_uint hashCode = 0; if (ref-GetType() == formula::svString) { @@ -277,12 +276,13 @@ public: } }; -class DynamicKernelStringArgument: public DynamicKernelArgument +/// A vector of strings +class DynamicKernelStringArgument: public VectorRef { public: DynamicKernelStringArgument(const std::string s, FormulaTreeNodeRef ft): -DynamicKernelArgument(s, ft) {} +VectorRef(s, ft) {} virtual void GenSlidingWindowFunction(std::stringstream ) {} /// Generate declaration @@ -357,15 +357,15 @@ size_t DynamicKernelStringArgument::Marshal(cl_kernel k, int argno, int, cl_prog } /// A mixed string/numberic vector -class DynamicKernelMixedArgument: public DynamicKernelArgument +class DynamicKernelMixedArgument: public VectorRef { public: DynamicKernelMixedArgument(const std::string s, FormulaTreeNodeRef ft): -DynamicKernelArgument(s, ft), mStringArgument(s+s, ft) {} +VectorRef(s, ft), mStringArgument(s+s, ft) {} virtual void GenSlidingWindowDecl(std::stringstream ss) const { -DynamicKernelArgument::GenSlidingWindowDecl(ss); +VectorRef::GenSlidingWindowDecl(ss); ss , ; mStringArgument.GenSlidingWindowDecl(ss); } @@ -373,28 +373,28 @@ public: /// Generate declaration virtual void GenDecl(std::stringstream ss) const { -DynamicKernelArgument::GenDecl(ss); +VectorRef::GenDecl(ss); ss , ; mStringArgument.GenDecl(ss); } virtual void GenDeclRef(std::stringstream ss) const { -DynamicKernelArgument::GenDeclRef(ss); +VectorRef::GenDeclRef(ss); ss ,; mStringArgument.GenDeclRef(ss); } virtual std::string GenSlidingWindowDeclRef(bool) const { std::stringstream ss; -ss (!isNan( DynamicKernelArgument::GenSlidingWindowDeclRef(); -ss )? DynamicKernelArgument::GenSlidingWindowDeclRef(); +ss (!isNan( VectorRef::GenSlidingWindowDeclRef(); +ss )? VectorRef::GenSlidingWindowDeclRef(); ss : mStringArgument.GenSlidingWindowDeclRef(); ss ); return ss.str(); } virtual size_t Marshal(cl_kernel k, int argno, int vw, cl_program p) { -int i = DynamicKernelArgument::Marshal(k, argno, vw, p); +int i = VectorRef::Marshal(k, argno, vw, p); i += mStringArgument.Marshal(k, argno+i, vw, p); return i; } @@ -482,7 +482,8 @@ public: return ss.str(); } /// Controls how the elements in the DoubleVectorRef are traversed -virtual size_t GenLoop(std::stringstream ss, bool needBody) +virtual size_t GenReductionLoopHeader( +std::stringstream ss, bool needBody) { assert(mpDVR); size_t nCurWindowSize = mpDVR-GetRefRowSize(); @@ -662,7 +663,7 @@ protected: class Reduction: public SlidingFunctionBase { public: -typedef DynamicKernelSlidingArgumentDynamicKernelArgument NumericRange; +typedef DynamicKernelSlidingArgumentVectorRef NumericRange; typedef DynamicKernelSlidingArgumentDynamicKernelStringArgument StringRange; virtual void GenSlidingWindowFunction(std::stringstream ss, @@ -688,13 +689,14 @@ public: if (NumericRange *NR = dynamic_castNumericRange * (vSubArguments[i].get())) { bool needBody; -nItems += NR-GenLoop(ss, needBody); +nItems += NR-GenReductionLoopHeader(ss, needBody); if
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) New commits: commit 12026388fab146e3384f1ed00d1d9018795e18b0 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Sun Nov 17 23:23:42 2013 -0600 GPU Calc: fix building error on Windows Change-Id: I4a7e02c24f8bdf9fc4fb66504ed3b6b09f34 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index fd4be3f..9a51af6 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -493,7 +493,7 @@ public: { // set 100 as a temporary threshold for invoking reduction // kernel in NeedParalleLReduction function -if (NeedParallelReduction()) +if (/*NeedParallelReduction()*/false) { std::string temp = Base::GetName() + [gid0]; ss tmp = ; @@ -508,7 +508,7 @@ public: { // set 100 as a temporary threshold for invoking reduction // kernel in NeedParalleLReduction function -if (NeedParallelReduction()) +if (NeedParallelReduction()false) { std::string temp = Base::GetName() + [0]; ss tmp = ; @@ -550,11 +550,9 @@ public: } else { -#ifdef ISNAN -ss 0; i nCurWindowSize ; i++){\n\t\t; -#else -ss 0; i nCurWindowSize ; i++)\n\t\t; -#endif +unsigned limit = +std::min(mpDVR-GetArrayLength(), nCurWindowSize); +ss 0; i limit ; i++){\n\t\t; } return nCurWindowSize; @@ -1074,8 +1072,8 @@ public: KernelEnv kEnv; OpenclDevice::setKernelEnv(kEnv); cl_int err; -DynamicKernelSlidingArgumentDynamicKernelArgument *slidingArgPtr = -dynamic_cast DynamicKernelSlidingArgumentDynamicKernelArgument * +DynamicKernelSlidingArgumentVectorRef *slidingArgPtr = +dynamic_cast DynamicKernelSlidingArgumentVectorRef * (mvSubArguments[0].get()); cl_mem mpClmem2; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 216b61c16acc8c5366af4e7dd8118e2140d37371 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 00:13:13 2013 -0600 GPU Calc: fix regression caused by reduction Change-Id: I077d400f9cc83a60edd3374cce0f69f27872298f diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 9a51af6..9a97234 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -560,7 +560,7 @@ public: virtual size_t Marshal(cl_kernel k, int argno, int w, cl_program mpProgram) { -if (!NeedParallelReduction()) +if (!NeedParallelReduction() || true) return Base::Marshal(k, argno, w, mpProgram); assert(Base::mpClmem == NULL); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |3 +++ 1 file changed, 3 insertions(+) New commits: commit 47eea0af3e93eeced7280f97545188d92fe94480 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Mon Nov 18 00:24:31 2013 -0600 GPU Calc: fall back to SW interp for unsupported double vector variants For cases like DoubleVectorRef::GetArrays() containing more than one array. Change-Id: I5111a731301bb43b8dbcd1156d964dca231fe840 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 9a97234..1594075 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -486,6 +486,9 @@ public: std::stringstream ss, bool needBody) { assert(mpDVR); +// Do not handle horizontal double vectors yet +if (mpDVR-GetArrays().size() 1) +throw Unhandled(); size_t nCurWindowSize = mpDVR-GetRefRowSize(); if (dynamic_castOpSum*(mpCodeGen.get())) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 004dbafbd700b6074f20b3061d0e25e169132b3e Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Sat Nov 16 02:09:18 2013 -0600 GPU Calc: pass the right argument size for reduction kernels in SumIfs Change-Id: Ib8fab8eacddbeb37795ad45f026559bdde0d43f7 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 64fe95e..36517c7 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -192,6 +192,7 @@ public: throw OpenCLError(err); return 1; } +virtual cl_mem GetCLBuffer(void) const { return NULL; } }; class DynamicKernelPiArgument: public DynamicKernelArgument @@ -1060,7 +1061,8 @@ public: // set kernel arg of reduction kernel for (size_t j=0; j vclmem.size(); j++){ -err = clSetKernelArg(redKernel, j, sizeof(cl_mem), +err = clSetKernelArg(redKernel, j, +vclmem[j]?sizeof(cl_mem):sizeof(double), (void *)vclmem[j]); if (CL_SUCCESS != err) throw OpenCLError(err); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit d6fb706bc695bcf2a98a6983686a45fe8bc720d8 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Fri Nov 15 19:47:42 2013 -0600 GPU Calc: an attempt to fix compilation error on Darwin Change-Id: I282ef4732f72d76baf647bb039847e8d7b3fd562 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 427dd9e..64fe95e 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -592,8 +592,9 @@ public: throw OpenCLError(err); // set kernel arg of reduction kernel // TODO(Wei Wei): use unique name for kernel +cl_mem buf = Base::GetCLBuffer(); err = clSetKernelArg(redKernel, 0, sizeof(cl_mem), -(void *)(Base::mpClmem)); +(void *)buf); if (CL_SUCCESS != err) throw OpenCLError(err); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/opinlinefun_finacial.cxx | 941 + 1 file changed, 490 insertions(+), 451 deletions(-) New commits: commit 63798515b249dabd4af0ca4fd913536398f739ff Author: yiming ju yim...@multicorewareinc.com Date: Fri Nov 1 17:48:31 2013 +0800 GPU Calc: refactor string formatting in some GPU inline functions Change-Id: I4ceb86ca84854a4e14c0720d6216d4c658a97859 Signed-off-by: haochen haoc...@multicorewareinc.com Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx index 05e6a5f..27a1625 100644 --- a/sc/source/core/opencl/opinlinefun_finacial.cxx +++ b/sc/source/core/opencl/opinlinefun_finacial.cxx @@ -14,10 +14,10 @@ std::string approxEqual = bool approxEqual(double a, double b)\n {\n if (a == b)\n -\t\treturn true;\n -\tdouble x = a - b;\n -\treturn (x 0.0 ? -x : x) ((a 0.0 ? -a : a) * (1.0 / (16777216.0 * -16777216.0)));\n +return true;\n + double x = a - b;\n + return (x 0.0 ? -x : x) ((a 0.0 ? -a : a) * (1.0 / (16777216.0 * +16777216.0)));\n }\n; std::string nKorrValDecl =double constant nKorrVal[] @@ -32,21 +32,22 @@ std::string RoundDecl = double Round(double fValue);\n; std::string Round = double Round(double fValue)\n {\n -\tif (fValue == 0.0)\n -\t\treturn fValue;\n -\tdouble fFac = 0;\n -\tint nExp;\n -\tif (fValue 0.0)\n -\t\tnExp = (floor(log10(fValue)));\n -\telse\n -\t\tnExp = 0;\n -\tint nIndex = 15 - nExp;\n -\tif (nIndex 15)\n -\t\tnIndex = 15;\n -\telse if (nIndex = 1)\n -\t\tnIndex = 0;\n -\tfValue = floor(fValue + 0.5 + nKorrVal[nIndex]);\n -\treturn fValue;\n +if ( fValue == 0.0 )\n +return fValue;\n +\n +double fFac = 0;\n +int nExp;\n +if ( fValue 0.0 )\n +nExp = ( floor( log10( fValue ) ) );\n +else\n +nExp = 0;\n +int nIndex = 15 - nExp;\n +if ( nIndex 15 )\n +nIndex = 15;\n +else if ( nIndex = 1 )\n +nIndex = 0;\n +fValue = floor( fValue + 0.5 + nKorrVal[nIndex] );\n +return fValue;\n }\n; std::string GetRmzDecl = @@ -55,27 +56,29 @@ std::string GetRmzDecl = std::string GetRmz= double GetRmz( double fZins, double fZzr, double fBw, double fZw, int nF )\n {\n -\tdouble fRmz;\n -\tif( fZins == 0.0 )\n -\t\tfRmz = ( fBw + fZw ) / fZzr;\n -\telse\n -\t\t{\n -\t\t\tdouble fTerm = pow( 1.0 + fZins, fZzr );\n -\t\t\tif( nF 0 )\n - \t\t\t\tfRmz = ( fZw * fZins / ( fTerm - 1.0 ) + fBw - * fZins / ( 1.0 - 1.0 / fTerm ) ) / ( 1.0 + fZins );\n -\t\t\telse\n -\t\t\t\tfRmz = fZw * fZins / ( fTerm - 1.0 ) + fBw * fZins / -( 1.0 - 1.0 / fTerm );\n -\t\t}\n -\treturn -fRmz;\n -}\n\n; +double fRmz;\n +if( fZins == 0.0 )\n +fRmz = ( fBw + fZw ) / fZzr;\n +else\n +{\n +double fTerm = pow( 1.0 + fZins, fZzr );\n +if( nF 0 )\n +fRmz = ( fZw * fZins / ( fTerm - 1.0 ) + fBw * fZins / ( 1.0 - 1. +0 / fTerm ) ) / ( 1.0 + fZins );\n +else\n +fRmz = fZw * fZins / ( fTerm - 1.0 ) + fBw * fZins /( 1.0 - 1.0 +/ fTerm );\n +}\n +return -fRmz;\n +}\n; std::string GetZwDecl = -double GetZw( double fZins, double fZzr, double fRmz, double fBw, int nF );\n; +double GetZw( double fZins, double fZzr, double fRmz, +double fBw, int nF );\n; std::string GetZw = -double GetZw( double fZins, double fZzr, double fRmz, double fBw, int nF )\n +double GetZw( double fZins, double fZzr, double fRmz, +double fBw, int nF )\n {\n double fZw;\n if( fZins == 0.0 )\n @@ -84,13 +87,13 @@ std::string GetZw = {\n double fTerm = pow( 1.0 + fZins, fZzr );\n if( nF 0 )\n -fZw = fBw * fTerm + fRmz * ( 1.0 + fZins ) * -( fTerm - 1.0 ) / fZins;\n +fZw = fBw * fTerm + fRmz * ( 1.0 + fZins ) *( fTerm - 1.0 ) +/ fZins;\n else\n -fZw = fBw * fTerm + fRmz * ( fTerm - 1.0 ) / fZins;\n +fZw = fBw * fTerm + fRmz * ( fTerm - 1.0 ) / fZins;\n }\n return -fZw;\n -}\n\n; +}\n; std::string IsLeapYearDecl = bool IsLeapYear( int n );\n; @@ -98,7 +101,8 @@ std::string IsLeapYearDecl = std::string IsLeapYear = bool IsLeapYear( int n )\n {\n -return ( (( ( n % 4 ) == 0 ) ( ( n % 100 ) != 0)) || ( ( n % 400 ) == 0 ) );\n +return ( (( ( n % 4 ) == 0 ) ( ( n % 100 ) != 0)) || ( ( n % 400 ) == +0 ) );\n }\n; std::string DaysInMonthDecl= @@ -107,8 +111,8 @@ std::string DaysInMonthDecl= std::string DaysInMonth = int DaysInMonth( int nMonth, int nYear )\n {\n -int aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,\n -31, 31, 30, 31, 30, 31 };\n +int
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 93f2bee483b23c426966c5232ca4bd75044b7ada Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Thu Oct 31 13:02:49 2013 -0500 Fixed a typo in the GPU Calc compiler. Change-Id: I40994de5e445dbd6f3c5e6597a90e63b7dc3cbcf diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index c44a200..d1ece4c 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -303,9 +303,9 @@ public: virtual std::string GenSlidingWindowDeclRef(bool) const { std::stringstream ss; -ss (!isNan( DynamicKernelArgument::GenSlidingWindowDeclRef(ss); -ss )? DynamicKernelArgument::GenSlidingWindowDeclRef(ss); -ss : mStringArgument.GenSlidingWindowDeclRef(ss); +ss (!isNan( DynamicKernelArgument::GenSlidingWindowDeclRef(); +ss )? DynamicKernelArgument::GenSlidingWindowDeclRef(); +ss : mStringArgument.GenSlidingWindowDeclRef(); ss ); return ss.str(); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 21 sc/source/core/opencl/formulagroupcl_finacial.hxx | 31 sc/source/core/opencl/op_financial.cxx|9 +++ sc/source/core/opencl/op_financial.hxx|1 sc/source/core/opencl/opbase.hxx |6 ++ sc/source/core/opencl/opinlinefun_finacial.cxx| 53 ++ 6 files changed, 89 insertions(+), 32 deletions(-) New commits: commit d3f16e81ffb66d89d3954fd624c1a2e764d62415 Author: Xukai Liu xu...@multicorewareinc.com Date: Thu Oct 31 20:20:37 2013 -0500 GPU Calc: refactor code generation for inlined library routines Refactored two library functions: Round and approxEqual. Generate them only when corresponding Calc spreadsheet functions are used. Change-Id: Ibf532d551ba0d99a117cedd4a0f3397acb5e017d Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index d1ece4c..ed186b3 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -823,6 +823,13 @@ public: t = t + mvSubArguments[i]-DumpOpName(); return t; } +virtual void DumpInlineFun(std::setstd::string decls, +std::setstd::string funs) const +{ +mpCodeGen-BinInlineFun(decls,funs); +for (unsigned i = 0; i mvSubArguments.size(); i++) +mvSubArguments[i]-DumpInlineFun(decls,funs); +} private: SubArgumentsType mvSubArguments; boost::scoped_ptrSlidingFunctionBase mpCodeGen; @@ -1181,6 +1188,18 @@ public: // preambles decl publicFunc; decl finacialFunc; +DK-DumpInlineFun(inlineDecl,inlineFun); +for(std::setstd::string::iterator set_iter=inlineDecl.begin(); + set_iter!=inlineDecl.end();set_iter++) +{ +decl*set_iter; +} + +for(std::setstd::string::iterator set_iter=inlineFun.begin(); + set_iter!=inlineFun.end();set_iter++) +{ +decl*set_iter; +} mSyms.DumpSlidingWindowFunctions(decl); mKernelSignature = DK-DumpOpName(); decl __kernel void DynamicKernel mKernelSignature; @@ -1256,6 +1275,8 @@ private: cl_program mpProgram; cl_kernel mpKernel; cl_mem mpResClmem; // Results +std::setstd::string inlineDecl; +std::setstd::string inlineFun; }; DynamicKernel::~DynamicKernel() diff --git a/sc/source/core/opencl/formulagroupcl_finacial.hxx b/sc/source/core/opencl/formulagroupcl_finacial.hxx index a8db8e9..da09168 100644 --- a/sc/source/core/opencl/formulagroupcl_finacial.hxx +++ b/sc/source/core/opencl/formulagroupcl_finacial.hxx @@ -9,38 +9,7 @@ #ifndef SC_OPENCL_FORMULAGROUPCL_FINACIAL_HXX #define SC_OPENCL_FORMULAGROUPCL_FINACIAL_HXX - const char* finacialFunc = -bool approxEqual(double a, double b)\n -{\n -\tif (a == b)\n -\t\treturn true;\n -\tdouble x = a - b;\n -\treturn (x 0.0 ? -x : x) ((a 0.0 ? -a : a) * (1.0 / (16777216.0 * -16777216.0)));\n -}\n -double constant nKorrVal[] = {0, 9e-1, 9e-2, 9e-3, 9e-4, 9e-5, 9e-6, 9e-7, -9e-8,9e-9, 9e-10, 9e-11, 9e-12, 9e-13, 9e-14, 9e-15};\n -constant double SCdEpsilon = 1.0E-7;\n -double Round(double fValue)\n -{\n -\tif (fValue == 0.0)\n -\t\treturn fValue;\n -\tdouble fFac = 0;\n -\tint nExp;\n -\tif (fValue 0.0)\n -\t\tnExp = (floor(log10(fValue)));\n -\telse\n -\t\tnExp = 0;\n -\tint nIndex = 15 - nExp;\n -\tif (nIndex 15)\n -\t\tnIndex = 15;\n -\telse if (nIndex = 1)\n -\t\tnIndex = 0;\n -\tfValue = floor(fValue + 0.5 + nKorrVal[nIndex]);\n -\treturn fValue;\n -}\n -void RateIteration(){\n\tdouble tmp = Round(3.0);\n\treturn;\n}\n double GetRmz( double fZins, double fZzr, double fBw, double fZw, int nF )\n {\n \tdouble fRmz;\n diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index 5ae04ff..da4845c 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -21,6 +21,8 @@ using namespace formula; namespace sc { namespace opencl { +// Definitions of inline functions +#include opinlinefun_finacial.cxx void RRI::GenSlidingWindowFunction( std::stringstream ss, const std::string sSymName, SubArguments vSubArguments) @@ -2513,6 +2515,13 @@ void OpTbillprice::GenSlidingWindowFunction( ss return tmp;\n; ss }\n; } + void RATE::BinInlineFun(std::setstd::string decls, +std::setstd::string funs) +{ +decls.insert(approxEqualDecl);decls.insert(nKorrValDecl); +decls.insert(SCdEpsilonDecl);decls.insert(RoundDecl); +funs.insert(approxEqual);funs.insert(Round); +} void RATE::GenSlidingWindowFunction( std::stringstream ss,
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 37 +++ sc/source/core/opencl/opbase.cxx |2 - sc/source/core/opencl/opbase.hxx | 11 ++--- 3 files changed, 27 insertions(+), 23 deletions(-) New commits: commit 4a72c7e47639688875761eb633cdf2bd60825353 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Oct 30 09:29:24 2013 -0400 Let's use typedef for this. Change-Id: If2523ee085285dc47d18fce425f784caa664d73e diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index a3b21a9..b583e7c 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -93,7 +93,7 @@ class ConstStringArgument: public DynamicKernelArgument { public: ConstStringArgument(const std::string s, -boost::shared_ptrFormulaTreeNode ft): +FormulaTreeNodeRef ft): DynamicKernelArgument(s, ft) {} /// Generate declaration virtual void GenDecl(std::stringstream ss) const @@ -151,7 +151,7 @@ class DynamicKernelConstantArgument: public DynamicKernelArgument { public: DynamicKernelConstantArgument(const std::string s, -boost::shared_ptrFormulaTreeNode ft): +FormulaTreeNodeRef ft): DynamicKernelArgument(s, ft) {} /// Generate declaration virtual void GenDecl(std::stringstream ss) const @@ -195,7 +195,7 @@ class DynamicKernelStringArgument: public DynamicKernelArgument { public: DynamicKernelStringArgument(const std::string s, -boost::shared_ptrFormulaTreeNode ft): +FormulaTreeNodeRef ft): DynamicKernelArgument(s, ft) {} virtual void GenSlidingWindowFunction(std::stringstream ) {} @@ -268,7 +268,7 @@ class DynamicKernelSlidingArgument: public Base { public: DynamicKernelSlidingArgument(const std::string s, -boost::shared_ptrFormulaTreeNode ft): +FormulaTreeNodeRef ft): Base(s, ft) { FormulaToken *t = ft-GetFormulaToken(); @@ -665,7 +665,7 @@ public: typedef std::vectorSubArgument SubArgumentsType; DynamicKernelSoPArguments(const std::string s, -boost::shared_ptrFormulaTreeNode ft); +FormulaTreeNodeRef ft); /// Create buffer and pass the buffer to a given kernel virtual size_t Marshal(cl_kernel k, int argno, int nVectorWidth) @@ -766,7 +766,7 @@ private: template class Op boost::shared_ptrDynamicKernelArgument SoPHelper(const std::string ts, -boost::shared_ptrFormulaTreeNode ft) +FormulaTreeNodeRef ft) { return boost::shared_ptrDynamicKernelArgument( new DynamicKernelSoPArgumentsOp(ts, ft)); @@ -774,7 +774,7 @@ boost::shared_ptrDynamicKernelArgument SoPHelper(const std::string ts, template class Op DynamicKernelSoPArgumentsOp::DynamicKernelSoPArguments(const std::string s, -boost::shared_ptrFormulaTreeNode ft): +FormulaTreeNodeRef ft): DynamicKernelArgument(s, ft) { size_t nChildren = ft-Children.size(); @@ -1113,7 +1113,7 @@ public: typedef std::list boost::shared_ptrDynamicKernelArgument ArgumentList; SymbolTable(void):mCurId(0) {} template class T -const DynamicKernelArgument *DeclRefArg(boost::shared_ptrFormulaTreeNode); +const DynamicKernelArgument *DeclRefArg(FormulaTreeNodeRef); /// Used to generate sliding window helpers void DumpSlidingWindowFunctions(std::stringstream ss) { @@ -1144,7 +1144,7 @@ void SymbolTable::Marshal(cl_kernel k, int nVectorWidth) /// Code generation class DynamicKernel { public: -DynamicKernel(boost::shared_ptrFormulaTreeNode r):mpRoot(r), +DynamicKernel(FormulaTreeNodeRef r):mpRoot(r), mpProgram(NULL), mpKernel(NULL), mpResClmem(NULL) {} /// Code generation in OpenCL std::string CodeGen() { @@ -1228,8 +1228,8 @@ public: ~DynamicKernel(); cl_mem GetResultBuffer(void) const { return mpResClmem; } private: -void TraverseAST(boost::shared_ptrFormulaTreeNode); -boost::shared_ptrFormulaTreeNode mpRoot; +void TraverseAST(FormulaTreeNodeRef); +FormulaTreeNodeRef mpRoot; SymbolTable mSyms; std::string mKernelSignature, mKernelHash; std::string mFullProgramSrc; @@ -1290,7 +1290,7 @@ void DynamicKernel::CreateKernel(void) // The template argument T must be a subclass of DynamicKernelArgument template typename T const DynamicKernelArgument *SymbolTable::DeclRefArg( - boost::shared_ptrFormulaTreeNode t) + FormulaTreeNodeRef t) { FormulaToken *ref = t-GetFormulaToken(); ArgumentMap::iterator it = mSymbols.find(ref); @@ -1351,15 +1351,15 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, // Constructing AST FormulaTokenIterator aCode = rCode; std::listFormulaToken * list; -std::mapFormulaToken *, boost::shared_ptrFormulaTreeNode m_hash_map; +std::mapFormulaToken *, FormulaTreeNodeRef m_hash_map;
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 224 +++ sc/source/core/opencl/op_financial.hxx |2 sc/source/core/opencl/opbase.hxx | 25 +-- 3 files changed, 99 insertions(+), 152 deletions(-) New commits: commit c555f15520e2d3c2c760b64a9791d68cbc67defc Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Oct 30 11:51:08 2013 -0400 Un-templatize code for speedier compilation. This changes brings the compile and link time from several minutes to a few seconds. Change-Id: I486b7bfd56913b17ec9ea2e9446372f3e9da38f1 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index b583e7c..1c113f6 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -25,7 +25,7 @@ #include formulagroupcl_public.hxx #include formulagroupcl_finacial.hxx -#includelist +#include list #include map #include iostream #include sstream @@ -35,6 +35,9 @@ #include rtl/digest.h #endif #include memory + +#include boost/scoped_ptr.hpp + using namespace formula; namespace sc { namespace opencl { @@ -297,7 +300,7 @@ protected: /// Abstract class for code generation -class Reduction: public SlidingFunctionBase, public OpBase +class Reduction: public SlidingFunctionBase { public: virtual void GenSlidingWindowFunction(std::stringstream ss, @@ -427,7 +430,7 @@ public: }; // Strictly binary operators -class Binary: public SlidingFunctionBase, public OpBase +class Binary: public SlidingFunctionBase { public: virtual void GenSlidingWindowFunction(std::stringstream ss, @@ -451,7 +454,7 @@ public: } }; -class SumOfProduct: public SlidingFunctionBase, public OpBase +class SumOfProduct: public SlidingFunctionBase { public: virtual void GenSlidingWindowFunction(std::stringstream ss, @@ -656,16 +659,16 @@ public: } virtual std::string BinFuncName(void) const { return fsop; } }; + /// Helper functions that have multiple buffers -templateclass Op class DynamicKernelSoPArguments: public DynamicKernelArgument { public: typedef boost::shared_ptrDynamicKernelArgument SubArgument; typedef std::vectorSubArgument SubArgumentsType; -DynamicKernelSoPArguments(const std::string s, -FormulaTreeNodeRef ft); +DynamicKernelSoPArguments( +const std::string s, const FormulaTreeNodeRef ft, SlidingFunctionBase* pCodeGen); /// Create buffer and pass the buffer to a given kernel virtual size_t Marshal(cl_kernel k, int argno, int nVectorWidth) @@ -682,7 +685,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream ss) { for (unsigned i = 0; i mvSubArguments.size(); i++) mvSubArguments[i]-GenSlidingWindowFunction(ss); -CodeGen.GenSlidingWindowFunction(ss, mSymName, mvSubArguments); +mpCodeGen-GenSlidingWindowFunction(ss, mSymName, mvSubArguments); } virtual void GenDeclRef(std::stringstream ss) const { @@ -733,7 +736,7 @@ public: std::stringstream ss; if (!nested) { -ss mSymName _ CodeGen.BinFuncName() (; +ss mSymName _ mpCodeGen-BinFuncName() (; for (unsigned i = 0; i mvSubArguments.size(); i++) { if (i) @@ -747,35 +750,33 @@ public: } else { if (mvSubArguments.size() != 2) throw Unhandled(); -ss ( CodeGen.Gen2(mvSubArguments[0]-GenSlidingWindowDeclRef(true), +ss ( mpCodeGen-Gen2(mvSubArguments[0]-GenSlidingWindowDeclRef(true), mvSubArguments[1]-GenSlidingWindowDeclRef(true)) ); } return ss.str(); } virtual std::string DumpOpName(void) const { -std::string t = _ + CodeGen.BinFuncName(); +std::string t = _ + mpCodeGen-BinFuncName(); for (unsigned i = 0; i mvSubArguments.size(); i++) t = t + mvSubArguments[i]-DumpOpName(); return t; } private: SubArgumentsType mvSubArguments; -Op CodeGen; +boost::scoped_ptrSlidingFunctionBase mpCodeGen; }; -template class Op -boost::shared_ptrDynamicKernelArgument SoPHelper(const std::string ts, -FormulaTreeNodeRef ft) +boost::shared_ptrDynamicKernelArgument SoPHelper( +const std::string ts, const FormulaTreeNodeRef ft, SlidingFunctionBase* pCodeGen) { -return boost::shared_ptrDynamicKernelArgument( -new DynamicKernelSoPArgumentsOp(ts, ft)); +return boost::shared_ptrDynamicKernelArgument(new DynamicKernelSoPArguments(ts, ft, pCodeGen)); } -template class Op -DynamicKernelSoPArgumentsOp::DynamicKernelSoPArguments(const std::string s, -FormulaTreeNodeRef ft): -DynamicKernelArgument(s, ft) { +DynamicKernelSoPArguments::DynamicKernelSoPArguments( +const std::string s, const FormulaTreeNodeRef ft, SlidingFunctionBase* pCodeGen) : +DynamicKernelArgument(s,
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/openclwrapper.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 8b997c8cfba34aea35efbaa0237beaf9d9c3653d Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Oct 30 14:02:12 2013 -0400 Return false when no OpenCL device is detected. Change-Id: Ib4e3e432cb69c17cf1830bfd540d4f5335056879 diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index b629e53..046297f 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -2766,7 +2766,7 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect) { // we don't need to change anything // still the same device -return true; +return pDeviceId != NULL; } cl_platform_id platformId; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/opbase.hxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 0783ed47e223b7216766286c2c553970a1fd82d9 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 17:17:48 2013 -0400 std::unique_ptr is C++11 specific. Let's use boost::shared_ptr for now. Change-Id: I549dd62bfb5c14993a3f600a388cd716b3ff7401 diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx index a982533..93f6820 100644 --- a/sc/source/core/opencl/opbase.hxx +++ b/sc/source/core/opencl/opbase.hxx @@ -106,7 +106,7 @@ protected: class SlidingFunctionBase { public: -typedef std::unique_ptrDynamicKernelArgument SubArgument; +typedef boost::shared_ptrDynamicKernelArgument SubArgument; typedef std::vectorSubArgument SubArguments; virtual void GenSlidingWindowFunction(std::stringstream , const std::string, SubArguments ) = 0; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 15 +-- sc/source/core/opencl/opbase.cxx | 11 +++ 2 files changed, 16 insertions(+), 10 deletions(-) New commits: commit bb1a1054fae950f7cc164251b5ca61b63b5817f5 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 19:09:46 2013 -0400 More C++11 specific features we aren't supposed to be using... * No 'auto'. * No std::unique_ptr. Change-Id: Iaceab28b9ad0b515bf77db2767018573c8de61de diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 1dd7c89..fb37ed6 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -661,7 +661,8 @@ templateclass Op class DynamicKernelSoPArguments: public DynamicKernelArgument { public: -typedef std::unique_ptrDynamicKernelArgument SubArgument; +typedef boost::shared_ptrDynamicKernelArgument SubArgument; +typedef std::vectorSubArgument SubArgumentsType; DynamicKernelSoPArguments(const std::string s, boost::shared_ptrFormulaTreeNode ft); @@ -670,8 +671,9 @@ public: virtual size_t Marshal(cl_kernel k, int argno, int nVectorWidth) { unsigned i = 0; -for(auto it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; -++it) { +for (SubArgumentsType::iterator it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; +++it) +{ i += (*it)-Marshal(k, argno + i, nVectorWidth); } return i; @@ -716,8 +718,9 @@ public: /// When declared as input to a sliding window function virtual void GenSlidingWindowDecl(std::stringstream ss) const { -for(auto it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; -++it) { +for (SubArgumentsType::const_iterator it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; +++it) +{ if (it != mvSubArguments.begin()) ss , ; (*it)-GenSlidingWindowDecl(ss); @@ -757,7 +760,7 @@ public: return t; } private: -std::vectorSubArgument mvSubArguments; +SubArgumentsType mvSubArguments; Op CodeGen; }; diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx index e7eae13..ec59e7a 100644 --- a/sc/source/core/opencl/opbase.cxx +++ b/sc/source/core/opencl/opbase.cxx @@ -65,15 +65,18 @@ size_t DynamicKernelArgument::GetWindowSize(void) const { FormulaToken *pCur = mFormulaTree-GetFormulaToken(); assert(pCur); -if (auto *pCurDVR = -dynamic_castconst formula::DoubleVectorRefToken *(pCur)) +if (const formula::DoubleVectorRefToken* pCurDVR = +dynamic_castconst formula::DoubleVectorRefToken *(pCur)) { return pCurDVR-GetRefRowSize(); -} else if (dynamic_castconst formula::SingleVectorRefToken *(pCur)) +} +else if (dynamic_castconst formula::SingleVectorRefToken *(pCur)) { // Prepare intermediate results (on CPU for now) return 1; -} else { +} +else +{ throw Unhandled(); } return 0; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 2bf7232a981ec009335562a799183055d2933f67 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 19:16:21 2013 -0400 Catch exception always as const reference. Change-Id: I7526a8724b66bbf23c5b38b76dcd6497ec409979 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index fb37ed6..875a259 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1414,7 +1414,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, return true; } #undef NO_FALLBACK_TO_SWINTERP /* undef this for non-TDD runs */ -catch (UnhandledToken ut) { +catch (const UnhandledToken) { std::cerr Dynamic formual compiler: unhandled token\n; #ifdef NO_FALLBACK_TO_SWINTERP assert(false); @@ -1422,7 +1422,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, return false; #endif } -catch (OpenCLError oce) { +catch (const OpenCLError oce) { std::cerr Dynamic formula compiler: OpenCL error: ; std::cerr oce.mError \n; #ifdef NO_FALLBACK_TO_SWINTERP ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 6cfc9e0dc68abf2a35b9958d80d1ca27df6239da Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 19:26:15 2013 -0400 DIE auto DIE!!! Change-Id: Ia4df8ac18a4b213a6c82a8faff0a4c08d53b6d08 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 875a259..8dc5779 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -695,7 +695,7 @@ public: } virtual void GenDecl(std::stringstream ss) const { -for(auto it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; +for (SubArgumentsType::const_iterator it = mvSubArguments.begin(), e= mvSubArguments.end(); it!=e; ++it) { if (it != mvSubArguments.begin()) ss , ; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 4ade490f992c84d5f2335528f1f286fa93180329 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 19:44:16 2013 -0400 Hopefull this is the last of std::unique_ptr. Again, this is C++11 specific which we can't use. Change-Id: I766cdf56cd49ba1611cf0172a52a5c0d950d33a0 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 8dc5779..229b639 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -765,10 +765,10 @@ private: }; template class Op -std::unique_ptrDynamicKernelArgument SoPHelper(const std::string ts, +boost::shared_ptrDynamicKernelArgument SoPHelper(const std::string ts, boost::shared_ptrFormulaTreeNode ft) { -return std::unique_ptrDynamicKernelArgument( +return boost::shared_ptrDynamicKernelArgument( new DynamicKernelSoPArgumentsOp(ts, ft)); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 18 -- sc/source/core/opencl/opbase.hxx |4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) New commits: commit 5ebecfc110f2c31e7bcef1c6e0a8fb2f6f1d56d5 Author: I-Jui (Ray) Sung r...@multicorewareinc.com Date: Tue Oct 29 17:06:53 2013 -0500 Include a message for unhandled-token in OCL group interpreter. Also added sanity checks for unhandled cases; i.e. mixed string/numeric in SingleVectorRefs Change-Id: I448536f45ec6cf9bc870671646c5ed4ee83ac9f8 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 229b639..c83715e 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -807,14 +807,19 @@ DynamicKernelSoPArgumentsOp::DynamicKernelSoPArguments(const std::string s, const formula::SingleVectorRefToken* pSVR = dynamic_cast const formula::SingleVectorRefToken* (pChild); assert(pSVR); -if (pSVR-GetArray().mpNumericArray) +if (pSVR-GetArray().mpNumericArray +!pSVR-GetArray().mpStringArray) mvSubArguments.push_back( SubArgument(new DynamicKernelArgument(ts, ft-Children[i]))); -else +else if (!pSVR-GetArray().mpNumericArray +pSVR-GetArray().mpStringArray) mvSubArguments.push_back( SubArgument(new DynamicKernelStringArgument( ts, ft-Children[i]))); +else +throw UnhandledToken(pChild, +Got both numeric and string vector); } else if (pChild-GetType() == formula::svDouble) { mvSubArguments.push_back( SubArgument(new DynamicKernelConstantArgument(ts, @@ -824,7 +829,7 @@ DynamicKernelSoPArgumentsOp::DynamicKernelSoPArguments(const std::string s, SubArgument(new ConstStringArgument(ts, ft-Children[i]))); } else { -throw UnhandledToken(pChild); +throw UnhandledToken(pChild, unknown operand for ocPush); } break; case ocDiv: @@ -1095,7 +1100,7 @@ DynamicKernelSoPArgumentsOp::DynamicKernelSoPArguments(const std::string s, } break; default: -throw UnhandledToken(pChild); +throw UnhandledToken(pChild, unhandled opcode); }; } } @@ -1414,8 +1419,9 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, return true; } #undef NO_FALLBACK_TO_SWINTERP /* undef this for non-TDD runs */ -catch (const UnhandledToken) { -std::cerr Dynamic formual compiler: unhandled token\n; +catch (const UnhandledToken ut) { +std::cerr \nDynamic formual compiler: unhandled token: ; +std::cerr ut.mMessage \n; #ifdef NO_FALLBACK_TO_SWINTERP assert(false); #else diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx index 93f6820..a858ede 100644 --- a/sc/source/core/opencl/opbase.hxx +++ b/sc/source/core/opencl/opbase.hxx @@ -25,8 +25,10 @@ namespace sc { namespace opencl { class UnhandledToken { public: -UnhandledToken(formula::FormulaToken *t): mToken(t) {} +UnhandledToken(formula::FormulaToken *t, +const char *const m): mToken(t), mMessage(m) {} formula::FormulaToken *mToken; +std::string mMessage; }; /// Failed in marshaling ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit c88576e424d7e6827edf2d9894b16fe22675b333 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Oct 29 20:31:51 2013 -0400 Believe or not, '' in this context is also C++11 specific. For those compilers that don't support C++11, we need to put a space in between. Change-Id: I2b67225047de3cc97f8bcec8d75d360cbbefd988 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index c83715e..a3b21a9 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1351,7 +1351,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, // Constructing AST FormulaTokenIterator aCode = rCode; std::listFormulaToken * list; -std::mapFormulaToken *, boost::shared_ptrFormulaTreeNode m_hash_map; +std::mapFormulaToken *, boost::shared_ptrFormulaTreeNode m_hash_map; FormulaToken* pCur; while( (pCur = (FormulaToken*)(aCode.Next()) ) != NULL) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits