[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - 2 commits - sc/source
Michael Meeks
michael.meeks at suse.com
Wed Jun 26 14:14:41 PDT 2013
sc/source/core/opencl/openclwrapper.cxx | 64 ++++++++++++++++----------------
sc/source/core/tool/formulagroup.cxx | 21 ++--------
2 files changed, 36 insertions(+), 49 deletions(-)
New commits:
commit e88d6a4c6a86ce5940d101676ba41c2765d30518
Author: Michael Meeks <michael.meeks at suse.com>
Date: Wed Jun 26 22:15:19 2013 +0100
return is a statement not a function.
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 4790510..20d60e2 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -152,20 +152,20 @@ int OpenclDevice::ConvertToString(const char *filename, char **source) {
rewind(file);
*source = (char*) malloc(sizeof(char) * file_size + 1);
if (*source == (char*) NULL) {
- return (0);
+ return 0;
}
result = fread(*source, 1, file_size, file);
if (result != (size_t) file_size) {
free(*source);
- return (0);
+ return 0;
}
(*source)[file_size] = '\0';
fclose(file);
- return (1);
+ return 1;
}
printf("open kernel file failed.\n");
- return (0);
+ return 0;
}
int OpenclDevice::BinaryGenerated(const char * clFileName, FILE ** fhandle) {
@@ -388,12 +388,12 @@ int OpenclDevice::CachedOfKernerPrg(const GPUEnv *gpuEnvCached,
for (i = 0; i < gpuEnvCached->fileCount; i++) {
if (strcasecmp(gpuEnvCached->kernelSrcFile[i], clFileName) == 0) {
if (gpuEnvCached->programs[i] != NULL) {
- return (1);
+ return 1;
}
}
}
- return (0);
+ return 0;
}
int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
@@ -409,7 +409,7 @@ int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
const char* filename = "kernel.cl";
fprintf(stderr, "CompileKernelFile ... \n");
if (CachedOfKernerPrg(gpuInfo, filename) == 1) {
- return (1);
+ return 1;
}
idx = gpuInfo->fileCount;
@@ -471,7 +471,7 @@ int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
}
if (gpuInfo->programs[idx] == (cl_program) NULL) {
- return (0);
+ return 0;
}
//char options[512];
@@ -498,11 +498,11 @@ int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
}
if (status != CL_SUCCESS) {
printf("opencl create build log fail\n");
- return (0);
+ return 0;
}
buildLog = (char*) malloc(length);
if (buildLog == (char*) NULL) {
- return (0);
+ return 0;
}
if (!gpuInfo->isUserCreated) {
status = clGetProgramBuildInfo(gpuInfo->programs[idx],
@@ -521,7 +521,7 @@ int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
}
free(buildLog);
- return (0);
+ return 0;
}
strcpy(gpuEnv.kernelSrcFile[idx], filename);
@@ -531,7 +531,7 @@ int OpenclDevice::CompileKernelFile(GPUEnv *gpuInfo, const char *buildOption) {
gpuInfo->fileCount += 1;
- return (1);
+ return 1;
}
@@ -546,10 +546,10 @@ int OpenclDevice::GetKernelEnvAndFunc(const char *kernelName,
env->program = gpuEnv.programs[0];
env->kernel = gpuEnv.kernels[i];
*function = gpuEnv.kernelFunctions[i];
- return (1);
+ return 1;
}
}
- return (0);
+ return 0;
}
int OpenclDevice::RunKernel(const char *kernelName, void **userdata) {
@@ -565,11 +565,11 @@ int OpenclDevice::RunKernel(const char *kernelName, void **userdata) {
if (status == 1) {
if (&env == (KernelEnv *) NULL
|| &function == (cl_kernel_function *) NULL) {
- return (0);
+ return 0;
}
return (function(userdata, &env));
}
- return (0);
+ return 0;
}
int OpenclDevice::InitOpenclRunEnv(int argc, const char *buildOptionKernelfiles)
{
@@ -587,19 +587,19 @@ int OpenclDevice::InitOpenclRunEnv(int argc, const char *buildOptionKernelfiles)
status = InitOpenclRunEnv(&gpuEnv);
if (status) {
printf("init_opencl_env failed.\n");
- return (1);
+ return 1;
}
printf("init_opencl_env successed.\n");
//initialize program, kernelName, kernelCount
status = CompileKernelFile( &gpuEnv, buildOptionKernelfiles);
if (status == 0 || gpuEnv.kernelCount == 0) {
printf("CompileKernelFile failed.\n");
- return (1);
+ return 1;
}
printf("CompileKernelFile successed.\n");
isInited = 1;
}
- return (0);
+ return 0;
}
int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
@@ -617,7 +617,7 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
if (!gpuInfo->isUserCreated) {
status = clGetPlatformIDs(0, NULL, &numPlatforms);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
gpuInfo->platform = NULL;
@@ -625,12 +625,12 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
platforms = (cl_platform_id*) malloc(
numPlatforms * sizeof(cl_platform_id));
if (platforms == (cl_platform_id*) NULL) {
- return (1);
+ return 1;
}
status = clGetPlatformIDs(numPlatforms, platforms, NULL);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
for (i = 0; i < numPlatforms; i++) {
@@ -638,7 +638,7 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
sizeof(platformName), platformName, NULL);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
gpuInfo->platform = platforms[i];
@@ -654,7 +654,7 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
&numDevices);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
if (numDevices) {
@@ -665,7 +665,7 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
free(platforms);
}
if (NULL == gpuInfo->platform) {
- return (1);
+ return 1;
}
// Use available platform.
@@ -692,25 +692,25 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
}
if ((gpuInfo->context == (cl_context) NULL)
|| (status != CL_SUCCESS)) {
- return (1);
+ return 1;
}
// Detect OpenCL devices.
// First, get the size of device list data
status = clGetContextInfo(gpuInfo->context, CL_CONTEXT_DEVICES, 0,
NULL, &length);
if ((status != CL_SUCCESS) || (length == 0)) {
- return (1);
+ return 1;
}
// Now allocate memory for device list based on the size we got earlier
gpuInfo->devices = (cl_device_id*) malloc(length);
if (gpuInfo->devices == (cl_device_id*) NULL) {
- return (1);
+ return 1;
}
// Now, get the device list data
status = clGetContextInfo(gpuInfo->context, CL_CONTEXT_DEVICES, length,
gpuInfo->devices, NULL);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
// Create OpenCL command queue.
@@ -718,7 +718,7 @@ int OpenclDevice::InitOpenclRunEnv(GPUEnv *gpuInfo)
gpuInfo->devices[0], 0, &status);
if (status != CL_SUCCESS) {
- return (1);
+ return 1;
}
}
@@ -737,10 +737,10 @@ int OpenclDevice::RegisterKernelWrapper(const char *kernelName,cl_kernel_functio
if (strcasecmp(kernelName, gpuEnv.kernelNames[i]) == 0)
{
gpuEnv.kernelFunctions[i] = function;
- return (1);
+ return 1;
}
}
- return (0);
+ return 0;
}
commit 1a20c07ab3a952e6fd8d55259ffd5f19c17110ff
Author: Michael Meeks <michael.meeks at suse.com>
Date: Wed Jun 26 22:08:09 2013 +0100
Use new method for returning values.
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 2262cc5..9d9b504 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -42,8 +42,8 @@ TimeValue aTimeBefore, aTimeAfter;
bool FormulaGroupInterpreter::interpret()
{
#if HAVE_FEATURE_OPENCL
- size_t rowSize = mxGroup->mnLength, srcSize = 0;
- fprintf(stderr,"rowSize at begin is ...%ld.\n",rowSize);
+ size_t rowSize = mxGroup->mnLength; //, srcSize = 0;
+ fprintf(stderr,"rowSize at begin is ...%ld.\n",(long)rowSize);
int *rangeStart =NULL; // The first position for calculation,for example,the A1 in (=MAX(A1:A100))
int *rangeEnd = NULL; // The last position for calculation,for example, the A100 in (=MAX(A1:A100))
// The row quantity can be gotten from p2->GetArrayLength()
@@ -236,21 +236,8 @@ bool FormulaGroupInterpreter::interpret()
// fprintf(stderr,"After GPU,rRsults[%d] is ...%f\n",i,rResult[i]);
// }
-// We want to stuff the double data, which in rResult[i] from GPU calculated well, to UI view for users
- ScAddress aInsertPos = maTopPos;
- for (sal_Int32 i = 0; i < mxGroup->mnLength; ++i)
- {
- aInsertPos.SetRow(mxGroup->mnStart + i);
- ScFormulaCell* pDestx = mrDoc.GetFormulaCell(aInsertPos);
-
- SAL_DEBUG(" put value " << rResult[i] << " into formula at " << aInsertPos.Col() << " , " << aInsertPos.Row() );
- assert(pDestx);
-
- formula::FormulaTokenRef xResult = new formula::FormulaDoubleToken(rResult[i]);
- pDestx->SetResultToken(xResult.get());
- pDestx->ResetDirty();
- pDestx->SetChanged(true);
- }
+ // Insert the double data, in rResult[i] back into the document
+ mrDoc.SetFormulaResults(maTopPos, rResult, mxGroup->mnLength);
}
if(leftData)
More information about the Libreoffice-commits
mailing list