blob: dd455ec5cae5ff0f0c07253e60a21594f188b025 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/* -*- 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_logical.hxx"
#include "formulagroup.hxx"
#include "document.hxx"
#include "formulacell.hxx"
#include "tokenarray.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
#include "formula/vectortoken.hxx"
#include <sstream>
using namespace formula;
namespace sc { namespace opencl {
void OpAnd::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
if (i)
ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ") {\n";
ss << " int gid0 = get_global_id(0);\n";
ss << " double t = 1,tmp=0;\n";
for(unsigned int j = 0; j< vSubArguments.size(); j++)
{
ss << " double tmp"<<j<<" = 1;\n";
FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
if(tmpCur0->GetType() == formula::svSingleVectorRef)
{
#ifdef ISNAN
const formula::SingleVectorRefToken*pCurDVR= dynamic_cast<const
formula::SingleVectorRefToken *>(tmpCur0);
ss<< " int buffer_len"<<j<<" = "<<pCurDVR->GetArrayLength();
ss<< ";\n";
ss <<" if(gid0 >= buffer_len"<<j<<" || isNan(";
ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" tmp = 1;\n else\n";
#endif
ss <<" tmp = ";
ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
}
else if(tmpCur0->GetType() == formula::svDouble)
{
ss <<" tmp = ";
ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
}
else if(tmpCur0->GetType() == formula::svDoubleVectorRef)
{
const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const
formula::DoubleVectorRefToken *>(tmpCur0);
size_t nCurWindowSize = pCurDVR->GetArrayLength() <
pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
pCurDVR->GetRefRowSize() ;
ss << " for(int i = ";
if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
ss << "gid0; i < " << nCurWindowSize << "; i++) {\n";
}
else if(pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()){
ss << "0; i < gid0 + " << nCurWindowSize << "; i++) {\n";
}
else{
ss << "0; i < " << nCurWindowSize << "; i++) {\n";
}
#ifdef ISNAN
if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
{
ss <<" if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
ss <<")||i+gid0>="<<pCurDVR->GetArrayLength();
ss <<")\n";
ss <<" tmp = 1;\n else\n";
}
else
{
ss <<" if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
ss <<")||i>="<<pCurDVR->GetArrayLength();
ss <<")\n";
ss <<" tmp = 1;\n else\n";
}
#endif
ss <<" tmp = ";
ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
ss <<" }\n";
}
ss <<" t = t && tmp"<<j<<";\n";
}
ss << " return t;\n";
ss << "}\n";
}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|