Files
loongoffice/sc/source/core/opencl/op_array.cxx
Luboš Luňák 33f2422661 rework handling of empty cells in opencl code
Some of the code handling ranges of cells wants empty cells to be zero,
some wants to skip them, and few want special handling. So just make
three generic cases that handle these, which somewhat simplifies this
while still allowing flexibility where needed. Also handle better
Test::testFuncSUMXMY2, which works on a pair of ranges, sets a cell
in one to a value and another is empty, in this case it is necessary
to iterate over this pair with SkipEmpty even if for the second one
it's beyond GetArrayLength().

Change-Id: I6c8edaaadb02ffe2a6a7a9399347909008ea188e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140249
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-09-21 10:22:16 +02:00

73 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "op_array.hxx"
#include <formula/vectortoken.hxx>
#include <sstream>
using namespace formula;
namespace sc::opencl {
void OpSumX2MY2::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
CHECK_PARAMETER_COUNT( 2, 2 );
CHECK_PARAMETER_DOUBLEVECTORREF( 0 );
CHECK_PARAMETER_DOUBLEVECTORREF( 1 );
GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
ss << " double tmp =0;\n";
GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
" tmp +=pow(arg1,2) - pow(arg2,2);\n"
);
ss << " return tmp;\n";
ss << "}\n";
}
void OpSumX2PY2::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
CHECK_PARAMETER_COUNT( 2, 2 );
CHECK_PARAMETER_DOUBLEVECTORREF( 0 );
CHECK_PARAMETER_DOUBLEVECTORREF( 1 );
GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
ss << " double tmp =0;\n";
GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
" tmp +=pow(arg1,2) + pow(arg2,2);\n"
);
ss << " return tmp;\n";
ss << "}\n";
}
void OpSumXMY2::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
CHECK_PARAMETER_COUNT( 2, 2 );
CHECK_PARAMETER_DOUBLEVECTORREF( 0 );
CHECK_PARAMETER_DOUBLEVECTORREF( 1 );
GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
ss << " double tmp =0;\n";
GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
" tmp +=pow((arg1-arg2),2);\n"
);
ss << " return tmp;\n";
ss << "}\n";
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */