[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/source

Michael Meeks michael.meeks at suse.com
Wed Jun 26 05:07:05 PDT 2013


 sc/source/core/opencl/openclwrapper.cxx |   22 +++++++++++++--------
 sc/source/core/tool/formulagroup.cxx    |   33 ++++++++++++++++----------------
 2 files changed, 31 insertions(+), 24 deletions(-)

New commits:
commit c3a85f52e4100199680b59eb6d092de43431991a
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Wed Jun 26 13:07:47 2013 +0100

    cleanup conditionals.

diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index b06af59..4790510 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -10,10 +10,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "sal/config.h"
 #include "random.hxx"
 #include "openclwrapper.hxx"
 #include "oclkernels.hxx"
-#ifdef WIN32
+#ifdef SAL_WIN32
 #include <Windows.h>
 #endif
 //#define USE_KERNEL_FILE
@@ -21,7 +22,7 @@ using namespace std;
 GPUEnv OpenclDevice::gpuEnv;
 int OpenclDevice::isInited =0;
 
-#ifdef WIN32
+#ifdef SAL_WIN32
 
 #define OPENCL_DLL_NAME "opencllo.dll"
 #define OCLERR -1
@@ -54,8 +55,9 @@ void OpenclDevice::FreeOpenclDll()
 
 int OpenclDevice::InitEnv()
 {
-#ifdef WIN32
-	while(1){
+#ifdef SAL_WIN32
+	while(1)
+    {
 	    if(1==LoadOpencl())
 			break;
 	}
@@ -66,7 +68,7 @@ int OpenclDevice::InitEnv()
 
 int OpenclDevice::ReleaseOpenclRunEnv() {
 	ReleaseOpenclEnv(&gpuEnv);
-#ifdef WIN32
+#ifdef SAL_WIN32
 	FreeOpenclDll();
 #endif
     return 1;
@@ -738,16 +740,18 @@ int OpenclDevice::RegisterKernelWrapper(const char *kernelName,cl_kernel_functio
 			return (1);
 		}
 	}
-		return (0);
+    return (0);
 }
 
 
-void OpenclDevice::SetOpenclState(int state) {
+void OpenclDevice::SetOpenclState(int state)
+{
      //printf("OpenclDevice::setOpenclState...\n");
      isInited = state;
 }
 
-int OpenclDevice::GetOpenclState() {
+int OpenclDevice::GetOpenclState()
+{
     return isInited;
 }
 //ocldbg
@@ -886,6 +890,7 @@ int OclFormulaxDll(void ** usrdata, KernelEnv *env) {
 
     return 0;
 }
+
 double OclCalc::OclProcess(cl_kernel_function function, double *data, formulax type)
 {
 	fprintf(stderr, "\n OpenclDevice, proc...begin\n");
@@ -930,6 +935,7 @@ OclCalc::~OclCalc()
     OpenclDevice::SetOpenclState(0);
     fprintf(stderr,"OclCalc:: opencl end ok.\n");
 }
+
 /////////////////////////////////////////////////////////////////////////////
 int OclCalc::OclHostFormulaMax(double *srcData,int *start,int *end,double *output,int size) {
 	KernelEnv env;
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 88c33cf..43977ed 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -173,7 +173,8 @@ bool FormulaGroupInterpreter::interpret()
 //            }
         }
 #endif
-        if(getenv("SC_FORMULAGROUP")&&(!getenv("SC_GPU"))){
+        if(!getenv("SC_GPU"))
+        {
             fprintf(stderr,"ccCPU flow...\n\n");
             ScCompiler aComp(&mrDoc, aTmpPos, aCode2);
             aComp.SetGrammar(mrDoc.GetGrammar());
@@ -186,11 +187,12 @@ bool FormulaGroupInterpreter::interpret()
         }
     } // for loop end (mxGroup->mnLength)
     // For GPU calculation
-#ifdef ENABLE_OPENCL //dbg: Using "export SC_FORMULAGROUP=1;export SC_GPU=1" to open if{} in terminal
-    if(getenv("SC_FORMULAGROUP")&&(getenv("SC_GPU"))){
+#ifdef ENABLE_OPENCL //dbg: Using "export SC_GPU=1" to open if{} in terminal
+    if(getenv("SC_GPU"))
+    {
             fprintf(stderr,"ggGPU flow...\n\n");
             printf(" oclOp is... %d\n",oclOp);
-osl_getSystemTime(&aTimeBefore);//timer
+            osl_getSystemTime(&aTimeBefore); //timer
             static OclCalc ocl_calc;
             switch(oclOp)
             {
@@ -219,14 +221,13 @@ osl_getSystemTime(&aTimeBefore);//timer
                     fprintf(stderr,"No OpenCL function for this calculation.\n");
                     break;
             }
-/////////////////////////////////////////////////////
-osl_getSystemTime(&aTimeAfter);
-double diff = getTimeDiff(aTimeAfter, aTimeBefore);
-//if (diff >= 1.0)
-{
-    fprintf(stderr,"OpenCL,diff...%f.\n",diff);
-
-}
+            /////////////////////////////////////////////////////
+            osl_getSystemTime(&aTimeAfter);
+            double diff = getTimeDiff(aTimeAfter, aTimeBefore);
+            //if (diff >= 1.0)
+            {
+                fprintf(stderr,"OpenCL,diff...%f.\n",diff);
+            }
 /////////////////////////////////////////////////////
 
 //rResult[i];
@@ -261,10 +262,10 @@ double diff = getTimeDiff(aTimeAfter, aTimeBefore);
         if(srcData)
             free(srcData);
 
-if(getenv("SC_GPUSAMPLE")){
-    //fprintf(stderr,"FormulaGroupInterpreter::interpret(),iniflag...%d\n",ocl_calc.GetOpenclState());
-    //ocl_calc.OclTest();//opencl test sample for debug
-}
+        if(getenv("SC_GPUSAMPLE")){
+            //fprintf(stderr,"FormulaGroupInterpreter::interpret(),iniflag...%d\n",ocl_calc.GetOpenclState());
+            //ocl_calc.OclTest();//opencl test sample for debug
+        }
 #endif
 
     return true;


More information about the Libreoffice-commits mailing list