LibreOffice Module sc (master) 1
op_math.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include "op_math.hxx"
11
13#include "op_math_helpers.hxx"
14#include <sstream>
15
16using namespace formula;
17
18namespace sc::opencl {
19
21 const std::string &sSymName, SubArguments &vSubArguments)
22{
24 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
25 ss << "{\n";
26 ss << " int gid0 = get_global_id(0);\n";
27 GenerateArg( 0, vSubArguments, ss );
28 GenerateCode( ss );
29 ss << "}";
30}
31
33 const std::string &sSymName, SubArguments &vSubArguments)
34{
36 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
37 ss << "{\n";
38 ss << " double tmp = 0;\n";
39 ss << " int gid0 = get_global_id(0);\n";
40 GenerateArg( 0, vSubArguments, ss );
41 GenerateArg( 1, vSubArguments, ss );
42 GenerateCode( ss );
43 ss << "}";
44}
45
47{
48 ss << " return cos(arg0);\n";
49}
50
52{
53 ss << " return 1.0 / cos(arg0);\n";
54}
55
57{
58 ss << " return 1.0 / cosh(arg0);\n";
59}
60
61void OpCosh::BinInlineFun(std::set<std::string>& decls,
62 std::set<std::string>& funs)
63{
64 decls.insert(local_coshDecl);
65 funs.insert(local_cosh);
66}
67
69{
70 ss << " return local_cosh(arg0);\n";
71}
72
74{
75 ss << " arg0 = arg0 * M_1_PI;\n";
76 ss << " return cospi(arg0) / sinpi(arg0);\n";
77}
78
79void OpCoth::BinInlineFun(std::set<std::string>& decls,
80 std::set<std::string>& funs)
81{
82 decls.insert(local_cothDecl);
83 funs.insert(local_coth);
84}
85
87{
88 ss << " return local_coth(arg0);\n";
89}
90
92{
93 ss << " double tmp = fabs(arg0 / 2);\n";
94 ss << " if ( trunc(tmp) == tmp )\n";
95 ss << " tmp = tmp * 2;\n";
96 ss << " else\n";
97 ss << " tmp = (trunc(tmp) + 1) * 2;\n";
98 ss << " if (arg0 < 0)\n";
99 ss << " tmp = tmp * -1.0;\n";
100 ss << " return tmp;\n";
101}
102
104{
105 ss << " return 1/sin(arg0);\n";
106}
107
109{
110 ss << " return 1/sinh(arg0);\n";
111}
112
114{
115 ss << " return pow(M_E, arg0);\n";
116}
117
119{
120 ss << " return log10(arg0);\n";
121}
122
124{
125 ss << " return ( exp(arg0)-exp(-arg0) )/2;\n";
126}
127
129{
130 ss << " arg0 = arg0 * M_1_PI;\n";
131 ss << " return sinpi(arg0);\n";
132}
133
135{
136 ss << " return fabs(arg0);\n";
137}
138
139void OpArcCos::BinInlineFun(std::set<std::string>& decls,
140 std::set<std::string>& funs)
141{
142 decls.insert(atan2Decl);
143 funs.insert(atan2Content);
144}
145
147{
148 ss << " return arctan2(sqrt(1.0 - pow(arg0, 2)), arg0);\n";
149}
150
152{
153 ss << " if( arg0 < 1 )\n";
154 ss << " return CreateDoubleError(IllegalArgument);\n";
155 ss << " return log( arg0 + pow( (pown(arg0, 2) - 1.0), 0.5));\n";
156}
157
159{
160 ss << " arg0 = arg0 * M_1_PI;\n";
161 ss << " return sinpi(arg0) / cospi(arg0);\n";
162}
163
165{
166 ss << " return tanh(arg0);\n";
167}
168
170{
171 ss << " if( arg0 < 0 )\n";
172 ss << " return CreateDoubleError(IllegalArgument);\n";
173 ss << " return sqrt(arg0);\n";
174}
175
177{
178 ss << " return M_PI_2 - atan(arg0);\n";
179}
180
182{
183 ss << " return 0.5 * log(1 + 2 / (arg0 - 1.0));\n";
184}
185
186void OpArcSin::BinInlineFun(std::set<std::string>& decls,
187 std::set<std::string>& funs)
188{
189 decls.insert(atan2Decl);
190 funs.insert(atan2Content);
191}
192
194{
195 ss << " return arctan2(arg0, sqrt(1.0 - pow(arg0, 2)));\n";
196}
197
199{
200 ss << " return log( arg0 + pow((pown(arg0, 2) + 1.0), 0.5));\n";
201}
202
204{
205 ss << " return atan(arg0);\n";
206}
207
209{
210 ss << " double a = 1.0 + arg0;\n";
211 ss << " double b = 1.0 - arg0;\n";
212 ss << " return log(pow(a/b, 0.5));\n";
213}
214
216{
217 ss << " return log1p(arg0-1);\n";
218}
219
220void OpInt::BinInlineFun(std::set<std::string>& decls,
221 std::set<std::string>& funs)
222{
223 decls.insert(is_representable_integerDecl);
224 funs.insert(is_representable_integer);
225 decls.insert(value_approxDecl);
226 funs.insert(value_approx);
227}
228
230{
231 ss << " return floor( value_approx( arg0 ));\n";
232}
233
235{
236 ss << " return -arg0;\n";
237}
238
240{
241 ss << " return arg0 * M_PI / 180.0;\n";
242}
243
245{
246 ss << " return (fmod(floor(fabs(arg0)), 2.0)<0.5);\n";
247}
248
250{
251 ss << " return !(fmod(floor(fabs(arg0)), 2.0)<0.5);\n";
252}
253
255{
256 ss << " return (double)sqrt(arg0 * M_PI);\n";
257}
258
260{
261 ss << " return arg0 / M_PI * 180;;\n";
262}
263
265{
266 ss << " arg0 = floor(arg0);\n";
267 ss << " if (arg0 < 0.0)\n";
268 ss << " return CreateDoubleError(IllegalArgument);\n";
269 ss << " else if (arg0 == 0.0)\n";
270 ss << " return 1.0;\n";
271 ss << " else if (arg0 <= 170.0)\n";
272 ss << " {\n";
273 ss << " double fTemp = arg0;\n";
274 ss << " while (fTemp > 2.0)\n";
275 ss << " {\n";
276 ss << " fTemp = fTemp - 1;\n";
277 ss << " arg0 = arg0 * fTemp;\n";
278 ss << " }\n";
279 ss << " }\n";
280 ss << " else\n";
281 ss << " return CreateDoubleError(NoValue);\n";
282 ss << " return arg0;\n";
283}
284
285void OpOdd::BinInlineFun(std::set<std::string>& decls,
286 std::set<std::string>& funs)
287{
288 decls.insert(Math_IntgDecl);
289 funs.insert(Math_Intg);
290}
291
293{
294 ss << " double tmp;\n";
295 ss << " if (arg0 > 0.0 ){\n";
296 ss << " tmp=Intg(arg0);\n";
297 ss << " if(tmp-trunc(tmp/2)*2 == 0)\n";
298 ss << " tmp=tmp+1;\n";
299 ss << " }else if (arg0 < 0.0 ){\n";
300 ss << " tmp=Intg(arg0);\n";
301 ss << " if(tmp-trunc(tmp/2)*2 == 0)\n";
302 ss << " tmp=tmp-1.0;\n";
303 ss << " }else\n";
304 ss << " tmp=1.0;\n";
305 ss << " return tmp;\n";
306}
307
309{
310 ss<<" if(arg1==0)\n";
311 ss<<" return arg1;\n";
312 ss<<" tmp=arg1 * round(arg0 / arg1);\n";
313 ss<<" return tmp;\n";
314}
315
316void OpCombinA::BinInlineFun(std::set<std::string>& decls,
317 std::set<std::string>& funs)
318{
319 decls.insert(bikDecl);
320 funs.insert(bik);
321}
322
324{
325 ss << " arg0 = trunc(arg0);\n";
326 ss << " arg1 = trunc(arg1);\n";
327 ss << " if (arg0 < 0.0 || arg1 < 0.0 || arg1 > arg0)\n";
328 ss << " return CreateDoubleError(IllegalArgument);\n";
329 ss << " double tem;\n";
330 ss << " if(arg0 >= arg1 && arg0 > 0 && arg1 > 0)\n";
331 ss << " tem = bik(arg0+arg1-1,arg1);\n";
332 ss << " else if(arg0 == 0 && arg1 == 0)\n";
333 ss << " tem = 0;\n";
334 ss << " else if(arg0 > 0 && arg1 == 0)\n";
335 ss << " tem = 1;\n";
336 ss << " else\n";
337 ss << " tem = -1;\n";
338 ss << " double i = tem - trunc(tem);\n";
339 ss << " if(i < 0.5)\n";
340 ss << " tem = trunc(tem);\n";
341 ss << " else\n";
342 ss << " tem = trunc(tem) + 1;\n";
343 ss << " return tem;\n";
344}
345
347{
348 ss << " double result = -1.0;\n";
349 ss << " double num = floor( arg0 );\n";
350 ss << " double num_chosen = floor( arg1 );\n";
351 ss << " if(num < 0 || num_chosen < 0 || num < num_chosen )\n";
352 ss << " return CreateDoubleError(IllegalArgument);\n";
353 ss << " result = select(result, 0.0, (ulong)(num < num_chosen));\n";
354 ss << " result = select(result, 1.0, (ulong)(num_chosen == 0.0));\n";
355 ss << " if(result == 0 || result ==1)\n";
356 ss << " return result;\n";
357 ss << " double4 db4num;\n";
358 ss << " double4 db4num_chosen;\n";
359 ss << " double4 db4result;\n";
360 ss << " double2 db2result;\n";
361 ss << " result = 1.0;\n";
362 ss << " int loop = num_chosen/4;\n";
363 ss << " for(int i=0; i<loop; i++)\n";
364 ss << " {\n";
365 ss << " db4num = (double4){num,\n";
366 ss << " num-1.0,\n";
367 ss << " num-2.0,\n";
368 ss << " num-3.0};\n";
369 ss << " db4num_chosen = (double4){num_chosen,\n";
370 ss << " num_chosen-1.0,\n";
371 ss << " num_chosen-2.0,\n";
372 ss << " num_chosen-3.0};\n";
373 ss << " db4result = db4num / db4num_chosen;\n";
374 ss << " db2result = db4result.xy * db4result.zw;\n";
375 ss << " result *= db2result.x * db2result.y;\n";
376 ss << " num = num - 4.0;\n";
377 ss << " num_chosen = num_chosen - 4.0;\n";
378 ss << " }\n";
379 ss << " while ( num_chosen > 0){\n";
380 ss << " result *= num / num_chosen;\n";
381 ss << " num = num - 1.0;\n";
382 ss << " num_chosen = num_chosen - 1.0;\n";
383 ss << " }\n";
384 ss << " return result;\n";
385}
386
387void OpMod::BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs)
388{
389 decls.insert(is_representable_integerDecl);
390 funs.insert(is_representable_integer);
391 decls.insert(approx_equalDecl);
392 funs.insert(approx_equal);
393 decls.insert(fsub_approxDecl);
394 funs.insert(fsub_approx);
395 decls.insert(value_approxDecl);
396 funs.insert(value_approx);
397}
398
400{
401 ss << " double fNum = arg0;\n";
402 ss << " double fDenom = arg1;\n";
403 ss << " if(fDenom == 0)\n";
404 ss << " return CreateDoubleError(DivisionByZero);\n";
405 ss << " double fRes = fsub_approx( fNum, floor( value_approx( fNum / fDenom )) * fDenom );\n";
406 ss << " if ( ( fDenom > 0 && fRes >= 0 && fRes < fDenom ) ||\n";
407 ss << " ( fDenom < 0 && fRes <= 0 && fRes > fDenom ) )\n";
408 ss << " return fRes;\n";
409 ss << " return CreateDoubleError(NoValue);\n";
410}
411
413{
414 ss << " return pow(arg0,arg1);\n";
415}
416
417void OpArcTan2::BinInlineFun(std::set<std::string>& decls,
418 std::set<std::string>& funs)
419{
420 decls.insert(atan2Decl);
421 funs.insert(atan2Content);
422}
423
425{
426 ss << " return arctan2(arg1, arg0);\n";
427}
428
430{
431 ss << " if( arg0 < 0 || arg1 < 0 || arg0 >= 281474976710656.0 || arg1 >= 281474976710656.0 )\n";
432 ss << " return CreateDoubleError(IllegalArgument);\n";
433 ss << " return (long)arg0 & (long)arg1;\n";
434}
435
437{
438 ss << " if( arg0 < 0 || arg1 < 0 || arg0 >= 281474976710656.0 || arg1 >= 281474976710656.0 )\n";
439 ss << " return CreateDoubleError(IllegalArgument);\n";
440 ss << " return (long)arg0 | (long)arg1;\n";
441}
442
444{
445 ss << " if( arg0 < 0 || arg1 < 0 || arg0 >= 281474976710656.0 || arg1 >= 281474976710656.0 )\n";
446 ss << " return CreateDoubleError(IllegalArgument);\n";
447 ss << " return (long)arg0 ^ (long)arg1;\n";
448}
449
451{
452 ss << " double num = floor( arg0 );\n";
453 ss << " double shift_amount = floor( arg1 );\n";
454 ss << " if( num < 0 || num >= 281474976710656.0 )\n";
455 ss << " return CreateDoubleError(IllegalArgument);\n";
456 ss << " return floor(shift_amount >= 0 ? ";
457 ss << "num * pow(2.0, shift_amount) : ";
458 ss << "num / pow(2.0, fabs(shift_amount)));\n";
459}
460
462{
463 ss << " double num = floor( arg0 );\n";
464 ss << " double shift_amount = floor( arg1 );\n";
465 ss << " if( num < 0 || num >= 281474976710656.0 )\n";
466 ss << " return CreateDoubleError(IllegalArgument);\n";
467 ss << " return floor(";
468 ss << "shift_amount >= 0 ? num / pow(2.0, shift_amount) : ";
469 ss << "num * pow(2.0, fabs(shift_amount)));\n";
470}
471
473{
474 ss << " return trunc(arg0/arg1);\n";
475}
476
477void OpEqual::BinInlineFun(std::set<std::string>& decls,
478 std::set<std::string>& funs)
479{
480 decls.insert(is_representable_integerDecl);
481 funs.insert(is_representable_integer);
482 decls.insert(approx_equalDecl);
483 funs.insert(approx_equal);
484 decls.insert(cell_equalDecl);
485 funs.insert(cell_equal);
486}
487
489 const std::string &sSymName, SubArguments &vSubArguments)
490{
491 CHECK_PARAMETER_COUNT( 2, 2 );
492 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
493 ss << "{\n";
494 ss << " double tmp = 0;\n";
495 ss << " int gid0 = get_global_id(0);\n";
496 GenerateArg( 0, vSubArguments, ss, EmptyIsNan, GenerateArgType );
497 GenerateArg( 1, vSubArguments, ss, EmptyIsNan, GenerateArgType );
498 ss << " return cell_equal( arg0, arg1, arg0_is_string, arg1_is_string );\n";
499 ss << "}";
500}
501
502void OpNotEqual::BinInlineFun(std::set<std::string>& decls,
503 std::set<std::string>& funs)
504{
505 decls.insert(is_representable_integerDecl);
506 funs.insert(is_representable_integer);
507 decls.insert(approx_equalDecl);
508 funs.insert(approx_equal);
509 decls.insert(cell_equalDecl);
510 funs.insert(cell_equal);
511}
512
514 const std::string &sSymName, SubArguments &vSubArguments)
515{
516 CHECK_PARAMETER_COUNT( 2, 2 );
517 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
518 ss << "{\n";
519 ss << " double tmp = 0;\n";
520 ss << " int gid0 = get_global_id(0);\n";
521 GenerateArg( 0, vSubArguments, ss, EmptyIsNan, GenerateArgType );
522 GenerateArg( 1, vSubArguments, ss, EmptyIsNan, GenerateArgType );
523 ss << " return !cell_equal( arg0, arg1, arg0_is_string, arg1_is_string );\n";
524 ss << "}";
525}
526
527void OpLessEqual::BinInlineFun(std::set<std::string>& decls,
528 std::set<std::string>& funs)
529{
530 decls.insert(is_representable_integerDecl);
531 funs.insert(is_representable_integer);
532 decls.insert(approx_equalDecl);
533 funs.insert(approx_equal);
534}
535
537{
538 ss << " return approx_equal( arg0, arg1 ) || arg0 <= arg1;\n";
539}
540
542{
543 ss << " return arg0 < arg1;\n";
544}
545
546void OpGreaterEqual::BinInlineFun(std::set<std::string>& decls,
547 std::set<std::string>& funs)
548{
549 decls.insert(is_representable_integerDecl);
550 funs.insert(is_representable_integer);
551 decls.insert(approx_equalDecl);
552 funs.insert(approx_equal);
553}
554
556{
557 ss << " return approx_equal( arg0, arg1 ) || arg0 >= arg1;\n";
558}
559
561{
562 ss << " return arg0 > arg1;\n";
563}
564
566 const std::string &sSymName, SubArguments &vSubArguments)
567{
568 CHECK_PARAMETER_COUNT( 1, 2 );
569 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
570 ss << "{\n";
571 ss << " int gid0 = get_global_id(0);\n";
572 GenerateArg( "arg0", 0, vSubArguments, ss );
573 GenerateArgWithDefault( "arg1", 1, 10, vSubArguments, ss );
574 ss << " return log10(arg0)/log10(arg1);;\n";
575 ss << "}";
576}
577
579 const std::string &sSymName, SubArguments &vSubArguments)
580{
581 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
582 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
584 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
585 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
586 pCurDVR->GetRefRowSize() ;
587 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
588 ss << "{\n";
589 ss <<" int gid0=get_global_id(0);\n";
590 ss << " int tmp =0;\n";
591 ss << " int loop;\n";
592 GenTmpVariables(ss,vSubArguments);
593
594 ss<< " int singleIndex =gid0;\n";
595 int m=0;
596
597 outputstream tmpss;
598
599 for(size_t j=0;j<vSubArguments.size();j+=2,m++)
600 {
601 CheckSubArgumentIsNan(tmpss,vSubArguments,j);
602 CheckSubArgumentIsNan(ss,vSubArguments,j+1);
603 tmpss <<" if(isequal(";
604 tmpss <<"tmp";
605 tmpss <<j;
606 tmpss <<" , ";
607 tmpss << "tmp";
608 tmpss << j+1;
609 tmpss << ")){\n";
610 }
611 tmpss << " tmp ++;\n";
612 for(size_t j=0;j<vSubArguments.size();j+=2,m--)
613 {
614 for(int n = 0;n<m+1;n++)
615 {
616 tmpss << " ";
617 }
618 tmpss<< "}\n";
619 }
620 UnrollDoubleVector(ss,tmpss,pCurDVR,nCurWindowSize);
621
622 ss << "return tmp;\n";
623 ss << "}";
624}
625
627 const std::string &sSymName, SubArguments &vSubArguments)
628{
629 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
630 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
632 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
633 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
634 pCurDVR->GetRefRowSize() ;
635
636 mNeedReductionKernel = vSubArguments[0]->NeedParallelReduction();
638 {
639 // generate reduction functions
640
641 ss << "__kernel void ";
642 ss << vSubArguments[0]->GetName();
643 ss << "_SumIfs_reduction( ";
644 for (size_t i = 0; i < vSubArguments.size(); i++)
645 {
646 if (i)
647 ss << ",";
648 vSubArguments[i]->GenSlidingWindowDecl(ss);
649 }
650 ss << ", __global double *result,int arrayLength,int windowSize";
651
652 ss << ")\n{\n";
653 ss << " double tmp =0;\n";
654 ss << " int i ;\n";
655
656 GenTmpVariables(ss,vSubArguments);
657 ss << " double current_result = 0.0;\n";
658 ss << " int writePos = get_group_id(1);\n";
659 if (pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
660 ss << " int offset = 0;\n";
661 else if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
662 ss << " int offset = get_group_id(1);\n";
663 else
664 throw Unhandled(__FILE__, __LINE__);
665 // actually unreachable
666 ss << " int lidx = get_local_id(0);\n";
667 ss << " __local double shm_buf[256];\n";
668 ss << " barrier(CLK_LOCAL_MEM_FENCE);\n";
669 ss << " int loop = arrayLength/512 + 1;\n";
670 ss << " for (int l=0; l<loop; l++){\n";
671 ss << " tmp = 0.0;\n";
672 ss << " int loopOffset = l*512;\n";
673
674 ss << " int p1 = loopOffset + lidx + offset, p2 = p1 + 256;\n";
675 ss << " if (p2 < min(offset + windowSize, arrayLength)) {\n";
676 ss << " tmp0 = 0.0;\n";
677 int mm=0;
678 std::string p1 = "p1";
679 std::string p2 = "p2";
680 for(size_t j=1;j<vSubArguments.size();j+=2,mm++)
681 {
682 CheckSubArgumentIsNan2(ss,vSubArguments,j,p1);
683 CheckSubArgumentIsNan2(ss,vSubArguments,j+1,p1);
684 ss << "";
685 ss <<" if(isequal(";
686 ss <<"tmp";
687 ss <<j;
688 ss <<" , ";
689 ss << "tmp";
690 ss << j+1;
691 ss << "))";
692 ss << "{\n";
693 }
694 CheckSubArgumentIsNan2(ss,vSubArguments,0,p1);
695 ss << " tmp += tmp0;\n";
696 for(size_t j=1;j<vSubArguments.size();j+=2,mm--)
697 {
698 for(int n = 0;n<mm+1;n++)
699 {
700 ss << " ";
701 }
702 ss<< "}\n\n";
703 }
704 mm=0;
705 for(size_t j=1;j<vSubArguments.size();j+=2,mm++)
706 {
707 CheckSubArgumentIsNan2(ss,vSubArguments,j,p2);
708 CheckSubArgumentIsNan2(ss,vSubArguments,j+1,p2);
709 ss <<" if(isequal(";
710 ss <<"tmp";
711 ss <<j;
712 ss <<" , ";
713 ss << "tmp";
714 ss << j+1;
715 ss << ")){\n";
716 }
717 CheckSubArgumentIsNan2(ss,vSubArguments,0,p2);
718 ss << " tmp += tmp0;\n";
719 for(size_t j=1;j< vSubArguments.size();j+=2,mm--)
720 {
721 for(int n = 0;n<mm+1;n++)
722 {
723 ss << " ";
724 }
725 ss<< "}\n";
726 }
727 ss << " }\n";
728
729 ss << " else if (p1 < min(arrayLength, offset + windowSize)) {\n";
730 mm=0;
731 for(size_t j=1;j<vSubArguments.size();j+=2,mm++)
732 {
733 CheckSubArgumentIsNan2(ss,vSubArguments,j,p1);
734 CheckSubArgumentIsNan2(ss,vSubArguments,j+1,p1);
735
736 ss <<" if(isequal(";
737 ss <<"tmp";
738 ss <<j;
739 ss <<" , ";
740 ss << "tmp";
741 ss << j+1;
742 ss << ")){\n";
743 }
744 CheckSubArgumentIsNan2(ss,vSubArguments,0,p1);
745 ss << " tmp += tmp0;\n";
746 for(size_t j=1;j<vSubArguments.size();j+=2,mm--)
747 {
748 for(int n = 0;n<mm+1;n++)
749 {
750 ss << " ";
751 }
752 ss<< "}\n\n";
753 }
754
755 ss << " }\n";
756 ss << " shm_buf[lidx] = tmp;\n";
757 ss << " barrier(CLK_LOCAL_MEM_FENCE);\n";
758 ss << " for (int i = 128; i >0; i/=2) {\n";
759 ss << " if (lidx < i)\n";
760 ss << " shm_buf[lidx] += shm_buf[lidx + i];\n";
761 ss << " barrier(CLK_LOCAL_MEM_FENCE);\n";
762 ss << " }\n";
763 ss << " if (lidx == 0)\n";
764 ss << " current_result += shm_buf[0];\n";
765 ss << " barrier(CLK_LOCAL_MEM_FENCE);\n";
766 ss << " }\n";
767
768 ss << " if (lidx == 0)\n";
769 ss << " result[writePos] = current_result;\n";
770 ss << "}\n";
771 }// finish generate reduction code
772 // generate functions as usual
773 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
774 ss << "{\n";
775 ss <<" int gid0=get_global_id(0);\n";
776 ss << " double tmp =0;\n";
778 {
779 ss << " int i ;\n";
780 GenTmpVariables(ss,vSubArguments);
781 ss << " for (i = ";
782 if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
783 ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
784 } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
785 ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
786 } else {
787 ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
788 }
789 ss << " {\n";
790 if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
791 {
792 ss<< " int doubleIndex =i+gid0;\n";
793 }else
794 {
795 ss<< " int doubleIndex =i;\n";
796 }
797 ss<< " int singleIndex =gid0;\n";
798 int m=0;
799 for(size_t j=1;j<vSubArguments.size();j+=2,m++)
800 {
801 CheckSubArgumentIsNan(ss,vSubArguments,j);
802 CheckSubArgumentIsNan(ss,vSubArguments,j+1);
803 ss <<" if(isequal(";
804 ss <<"tmp";
805 ss <<j;
806 ss <<" , ";
807 ss << "tmp";
808 ss << j+1;
809 ss << ")){\n";
810 }
811 CheckSubArgumentIsNan(ss,vSubArguments,0);
812 ss << " tmp += tmp0;\n";
813 for(size_t j=1;j<=vSubArguments.size();j+=2,m--)
814 {
815 for(int n = 0;n<m+1;n++)
816 {
817 ss << " ";
818 }
819 ss<< "}\n";
820 }
821 }
823 {
824 ss << "tmp =";
825 vSubArguments[0]->GenDeclRef(ss);
826 ss << "[gid0];\n";
827 }
828 ss << "return tmp;\n";
829 ss << "}";
830}
831
833 const std::string &sSymName, SubArguments &vSubArguments)
834{
835 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
836 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
838 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
839 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
840 pCurDVR->GetRefRowSize() ;
841 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
842 ss << "{\n";
843 ss <<" int gid0=get_global_id(0);\n";
844 ss << " double tmp =0;\n";
845 ss << " int count=0;\n";
846 ss << " int loop;";
847 GenTmpVariables(ss,vSubArguments);
848 ss<< " int singleIndex =gid0;\n";
849 int m=0;
850 outputstream tmpss;
851 for(size_t j=1;j<vSubArguments.size();j+=2,m++)
852 {
853 CheckSubArgumentIsNan(tmpss,vSubArguments,j);
854 CheckSubArgumentIsNan(ss,vSubArguments,j+1);
855 tmpss <<" if(isequal(";
856 tmpss <<"tmp";
857 tmpss <<j;
858 tmpss <<" , ";
859 tmpss << "tmp";
860 tmpss << j+1;
861 tmpss << ")){\n";
862 }
863 CheckSubArgumentIsNan(tmpss,vSubArguments,0);
864 tmpss << " tmp += tmp0;\n";
865 tmpss << " count++;\n";
866 for(size_t j=1;j<vSubArguments.size();j+=2,m--)
867 {
868 for(int n = 0;n<m+1;n++)
869 {
870 tmpss << " ";
871 }
872 tmpss<< "}\n";
873 }
874
875 UnrollDoubleVector(ss,tmpss,pCurDVR,nCurWindowSize);
876
877 ss << " if(count!=0)\n";
878 ss << " tmp=tmp/count;\n";
879 ss << " else\n";
880 ss << " tmp= 0 ;\n";
881 ss << "return tmp;\n";
882 ss << "}";
883}
884
885void OpRound::BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs)
886{
887 decls.insert(nCorrValDecl);
888 decls.insert(RoundDecl);
889 funs.insert(Round);
890}
891
893 const std::string &sSymName, SubArguments &vSubArguments)
894{
895 CHECK_PARAMETER_COUNT( 1, 2 );
896 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
897 ss << "{\n";
898 ss << " int gid0=get_global_id(0);\n";
899 GenerateArg( "value", 0, vSubArguments, ss );
900 if(vSubArguments.size() ==1)
901 ss << " return round(value);\n";
902 else
903 {
904 GenerateArg( "fDec", 1, vSubArguments, ss );
905 ss << " int dec = floor( fDec );\n";
906 ss << " if( dec < -20 || dec > 20 )\n";
907 ss << " return CreateDoubleError( IllegalArgument );\n";
908 ss << " if( dec == 0 )\n";
909 ss << " return round(value);\n";
910 ss << " double orig_value = value;\n";
911 ss << " value = fabs(value);\n";
912 ss << " double multiply = pown(10.0, dec);\n";
913 ss << " double tmp = value*multiply;\n";
914 ss << " tmp = Round( tmp );\n";
915 ss << " return copysign(tmp/multiply, orig_value);\n";
916 }
917 ss << "}";
918}
919
921 const std::string &sSymName, SubArguments &vSubArguments)
922{
923 CHECK_PARAMETER_COUNT( 1, 2 );
924 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
925 ss << "{\n";
926 ss << " int gid0=get_global_id(0);\n";
927 GenerateArg( "value", 0, vSubArguments, ss );
928 GenerateArgWithDefault( "fDec", 1, 0, vSubArguments, ss );
929 ss << " int dec = floor( fDec );\n";
930 ss << " if( dec < -20 || dec > 20 )\n";
931 ss << " return CreateDoubleError( IllegalArgument );\n";
932 ss << " double orig_value = value;\n";
933 ss << " value = fabs(value);\n";
934 ss << " double multiply = pown(10.0, dec);\n";
935 ss << " double tmp = value*multiply;\n";
936 ss << " double integral;\n";
937 // The pown() above increases rounding error, so compensate for it here.
938 // If the fractional part is close above zero, adjusted for rounding error,
939 // the number just needs to be rounded (=truncated).
940 ss << " if( modf( tmp, &integral ) / multiply < 1e-12 )\n";
941 ss << " tmp = integral;\n";
942 ss << " else\n";
943 ss << " tmp = integral + 1;\n";
944 ss << " return copysign(tmp/multiply, orig_value);\n";
945 ss << "}";
946}
947
949 const std::string &sSymName, SubArguments &vSubArguments)
950{
951 CHECK_PARAMETER_COUNT( 1, 2 );
952 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
953 ss << "{\n";
954 ss << " int gid0=get_global_id(0);\n";
955 GenerateArg( "value", 0, vSubArguments, ss );
956 GenerateArgWithDefault( "fDec", 1, 0, vSubArguments, ss );
957 ss << " int dec = floor( fDec );\n";
958 ss << " if( dec < -20 || dec > 20 )\n";
959 ss << " return CreateDoubleError( IllegalArgument );\n";
960 ss << " double orig_value = value;\n";
961 ss << " value = fabs(value);\n";
962 ss << " double multiply = pown(10.0, dec);\n";
963 ss << " double tmp = value*multiply;\n";
964 ss << " double integral;\n";
965 // The pown() above increases rounding error, so compensate for it here.
966 // If the fractional part is close below one, adjusted for rounding error,
967 // the number just needs to be rounded (=truncated + 1).
968 ss << " if(( 1 - modf( tmp, &integral )) / multiply < 1e-12 )\n";
969 ss << " tmp = integral + 1;\n";
970 ss << " else\n";
971 ss << " tmp = integral;\n";
972 ss << " return copysign(tmp/multiply, orig_value);\n";
973 ss << "}";
974}
975
977 const std::string &sSymName, SubArguments &vSubArguments)
978{
979 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
980 ss << "{\n";
981 ss << " int gid0=get_global_id(0);\n";
982 ss << " double vara, varb;\n";
983 ss << " int varc = 0;\n";
984 FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
985 assert(tmpCur);
986 if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
987 {
988 if(tmpCur->GetType() == formula::svSingleVectorRef)
989 {
990 const formula::SingleVectorRefToken* tmpCurDVR=
991 static_cast<
992 const formula::SingleVectorRefToken *>(tmpCur);
993 ss << " varb = ";
994 ss << vSubArguments[1]->GenSlidingWindowDeclRef();
995 ss << ";\n";
996 ss << " if(isnan(varb)||(gid0>=";
997 ss << tmpCurDVR->GetArrayLength();
998 ss << "))\n";
999 ss << " varb = 0;\n";
1000 }
1001 else if(tmpCur->GetType() == formula::svDouble)
1002 {
1003 ss << " varb = ";
1004 ss << tmpCur->GetDouble() << ";\n";
1005 }
1006 }
1007 else
1008 {
1009 ss << " varb = ";
1010 ss << vSubArguments[1]->GenSlidingWindowDeclRef();
1011 ss << ";\n";
1012 }
1013 tmpCur = vSubArguments[0]->GetFormulaToken();
1014 assert(tmpCur);
1015 if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
1016 {
1017 //TODO DoubleVector
1018 if (tmpCur->GetType() == formula::svDoubleVectorRef)
1019 {
1020 const formula::DoubleVectorRefToken* pDVR =
1021 static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
1022 size_t nCurWindowSize = pDVR->GetRefRowSize();
1023 ss << " for (int i = ";
1024 if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
1025 {
1026 ss << "gid0; i < " << pDVR->GetArrayLength();
1027 ss << " && i < " << nCurWindowSize << "; ++i)\n";
1028 ss << " {\n";
1029 }
1030 else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
1031 {
1032 ss << "0; i < " << pDVR->GetArrayLength();
1033 ss << " && i < gid0+"<< nCurWindowSize << "; ++i)\n";
1034 ss << " {\n";
1035 }
1036 else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
1037 {
1038 ss << "0; i + gid0 < " << pDVR->GetArrayLength();
1039 ss << " && i < "<< nCurWindowSize << "; ++i)\n";
1040 ss << " {\n";
1041 }
1042 else
1043 {
1044 ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
1045 ss << " {\n";
1046 }
1047 ss << " vara = ";
1048 ss << vSubArguments[0]->GenSlidingWindowDeclRef();
1049 ss << ";\n";
1050 ss << " if (isnan(vara))\n";
1051 ss << " continue;\n";
1052 ss << " (vara == varb) && varc++;\n";
1053 ss << " }\n";
1054 }
1055 else if(tmpCur->GetType() == formula::svSingleVectorRef)
1056 {
1057 const formula::SingleVectorRefToken* tmpCurDVR=
1058 static_cast<
1059 const formula::SingleVectorRefToken *>(tmpCur);
1060 ss << " vara = ";
1061 ss << vSubArguments[0]->GenSlidingWindowDeclRef();
1062 ss << ";\n";
1063 ss << " if(isnan(vara)||(gid0>=";
1064 ss << tmpCurDVR->GetArrayLength();
1065 ss << "))\n";
1066 ss << " return 0;\n";
1067 ss << " (vara == varb) && varc++;\n";
1068 }
1069 }
1070 ss << " return varc;\n";
1071 ss << "}";
1072}
1073
1075 const std::string &sSymName, SubArguments &vSubArguments)
1076{
1077 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1078 ss << "{\n";
1079 ss << " int gid0=get_global_id(0);\n";
1080 ss << " double vara, varb, varc, sum = 0.0f;\n";
1081 int flag = 3 == vSubArguments.size() ? 2 : 0;
1082 FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
1083 assert(tmpCur);
1084 if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
1085 {
1086 if(tmpCur->GetType() == formula::svSingleVectorRef)
1087 {
1088 const formula::SingleVectorRefToken* tmpCurDVR=
1089 static_cast<
1090 const formula::SingleVectorRefToken *>(tmpCur);
1091 ss << " varb = ";
1092 ss << vSubArguments[1]->GenSlidingWindowDeclRef();
1093 ss << ";\n";
1094 ss << " if(isnan(varb)||(gid0>=";
1095 ss << tmpCurDVR->GetArrayLength();
1096 ss << "))\n";
1097 ss << " varb = 0;\n";
1098 }
1099 else if(tmpCur->GetType() == formula::svDouble)
1100 {
1101 ss << " varb = ";
1102 ss << tmpCur->GetDouble() << ";\n";
1103 }
1104 }
1105 else
1106 {
1107 ss << " varb = ";
1108 ss << vSubArguments[1]->GenSlidingWindowDeclRef();
1109 ss << ";\n";
1110 }
1111 tmpCur = vSubArguments[0]->GetFormulaToken();
1112 assert(tmpCur);
1113 if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
1114 {
1115 //TODO DoubleVector
1116 if (tmpCur->GetType() == formula::svDoubleVectorRef)
1117 {
1118 const formula::DoubleVectorRefToken* pDVR =
1119 static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
1120 size_t nCurWindowSize = pDVR->GetRefRowSize();
1121 ss << " for (int i = ";
1122 if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
1123 {
1124 ss << "gid0; i < " << pDVR->GetArrayLength();
1125 ss << " && i < " << nCurWindowSize << "; ++i)\n";
1126 ss << " {\n";
1127 }
1128 else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
1129 {
1130 ss << "0; i < " << pDVR->GetArrayLength();
1131 ss << " && i < gid0+"<< nCurWindowSize << "; ++i)\n";
1132 ss << " {\n";
1133 }
1134 else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
1135 {
1136 ss << "0; i + gid0 < " << pDVR->GetArrayLength();
1137 ss << " && i < "<< nCurWindowSize << "; ++i)\n";
1138 ss << " {\n";
1139 }
1140 else
1141 {
1142 ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
1143 ss << " {\n";
1144 }
1145 ss << " vara = ";
1146 ss << vSubArguments[0]->GenSlidingWindowDeclRef();
1147 ss << ";\n";
1148 ss << " if (isnan(vara))\n";
1149 ss << " continue;\n";
1150 ss << " varc = ";
1151 ss << vSubArguments[flag]->GenSlidingWindowDeclRef();
1152 ss << ";\n";
1153 ss << " if (isnan(varc))\n";
1154 ss << " varc = 0.0f;\n";
1155 ss << " (vara == varb)&&(sum = sum + varc);\n";
1156 ss << " }\n";
1157 }
1158 else if(tmpCur->GetType() == formula::svSingleVectorRef)
1159 {
1160 const formula::SingleVectorRefToken* tmpCurDVR=
1161 static_cast<
1162 const formula::SingleVectorRefToken *>(tmpCur);
1163 ss << " vara = ";
1164 ss << vSubArguments[0]->GenSlidingWindowDeclRef();
1165 ss << ";\n";
1166 ss << " if(isnan(vara)||(gid0>=";
1167 ss << tmpCurDVR->GetArrayLength();
1168 ss << "))\n";
1169 ss << " return 0;\n";
1170 ss << " int i = 0;\n";
1171 ss << " varc = ";
1172 ss << vSubArguments[flag]->GenSlidingWindowDeclRef();
1173 ss << ";\n";
1174 ss << " if(isnan(varc)||(gid0>=";
1175 ss << tmpCurDVR->GetArrayLength();
1176 ss << "))\n";
1177 ss << " varc = 0.0f;\n";
1178
1179 ss << " (vara == varb)&&(sum = sum + varc);\n";
1180
1181 }
1182 }
1183 ss << " return sum;\n";
1184 ss << "}";
1185}
1186
1188 outputstream &ss, const std::string &sSymName,
1189 SubArguments &vSubArguments)
1190{
1191 CHECK_PARAMETER_COUNT( 2, 3 );
1192 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1193 ss << "{\n";
1194 ss << " int gid0=get_global_id(0);\n";
1195 GenerateArg( "arg0", 0, vSubArguments, ss );
1196 GenerateArg( "arg1", 1, vSubArguments, ss );
1197 GenerateArgWithDefault( "arg2", 2, 0, vSubArguments, ss );
1198 ss << " if(isnan(arg0) || isnan(arg1))\n";
1199 ss << " return 0;\n";
1200 ss << " if(isnan(arg2))\n";
1201 ss << " arg2 = 0.0;\n";
1202 ss << " if(arg0*arg1<0)\n";
1203 ss << " return CreateDoubleError(IllegalArgument);\n";
1204 ss << " if(arg1 == 0.0)\n";
1205 ss << " return 0.0;\n";
1206 ss << " else if(arg2==0.0&&arg0<0.0)\n";
1207 ss << " return (trunc(arg0/arg1)+1)*arg1;\n";
1208 ss << " else\n";
1209 ss << " return trunc(arg0/arg1)*arg1;\n";
1210 ss << "}\n";
1211}
1212
1214 const std::string &sSymName, SubArguments &vSubArguments)
1215{
1216 CHECK_PARAMETER_COUNT( 1, 30 );
1217 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1218 ss << "{\n";
1219 ss << " int gid0=get_global_id(0);\n";
1220 ss << " double sum = 0.0f, arg;\n";
1221 GenerateRangeArgs( vSubArguments, ss, SkipEmpty,
1222 " sum += pown(arg, 2);\n"
1223 );
1224 ss << " return sum;\n";
1225 ss << "}";
1226}
1227
1229 const std::string &sSymName, SubArguments &vSubArguments)
1230{
1231 CHECK_PARAMETER_COUNT( 2, 3 );
1232 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1233 ss << "{\n";
1234 ss << " int gid0 = get_global_id(0);\n";
1235 GenerateArg( "num", 0, vSubArguments, ss );
1236 GenerateArg( "significance", 1, vSubArguments, ss );
1237 GenerateArgWithDefault( "bAbs", 2, 0, vSubArguments, ss );
1238 ss << " if(num*significance < 0.0)\n";
1239 ss << " return CreateDoubleError(IllegalArgument);\n";
1240 ss << " if(significance == 0.0)\n";
1241 ss << " return 0.0;\n";
1242 ss << " return ";
1243 ss << "( !(int)bAbs && num < 0.0 ? floor( num / significance ) : ";
1244 ss << "ceil( num / significance ) )";
1245 ss << "*significance;\n";
1246 ss << "}";
1247}
1248
1250 const std::string &sSymName, SubArguments &vSubArguments)
1251{
1252 CHECK_PARAMETER_COUNT( 1, 30 );
1253 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1254 ss << "{\n";
1255 ss << " int gid0 = get_global_id(0);\n";
1256 ss << " double product=1.0;\n";
1257 ss << " int count = 0;\n\n";
1258 GenerateRangeArgs( vSubArguments, ss, SkipEmpty,
1259 " product = product*arg;\n"
1260 " ++count;\n"
1261 );
1262 ss << " if(count == 0)\n";
1263 ss << " return 0;\n";
1264 ss << " return product;\n";
1265 ss << "}";
1266}
1267
1269 const std::string &sSymName, SubArguments &vSubArguments)
1270{
1271 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1272 ss << "{\n";
1273 ss << " int gid0=get_global_id(0);\n";
1274 ss << " double tmp =0;\n";
1275 ss << " double count=0;\n";
1276 ss << " int singleIndex =gid0;\n";
1277 ss << " int doubleIndex;\n";
1278 ss << " int i ;\n";
1279 ss << " int j ;\n";
1280 GenTmpVariables(ss,vSubArguments);
1281
1282 unsigned paraOneIsDoubleVector = 0;
1283 unsigned paraOneWidth = 1;
1284 unsigned paraTwoWidth = 1;
1285 unsigned loopTimes = 0;
1286
1287 if(vSubArguments[0]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef)
1288 {
1289 paraOneIsDoubleVector = 1;
1290 FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
1291 const formula::DoubleVectorRefToken*pCurDVR0= static_cast<const
1293 paraOneWidth = pCurDVR0->GetArrays().size();
1294 loopTimes = paraOneWidth;
1295 if(paraOneWidth > 1)
1296 {
1297 throw Unhandled(__FILE__, __LINE__);
1298 }
1299 }
1300
1301 if(vSubArguments[paraOneWidth]->GetFormulaToken()->GetType() ==
1303
1304 {
1305 FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
1306 const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
1308 paraTwoWidth = pCurDVR1->GetArrays().size();
1309 if(paraTwoWidth > 1)
1310 {
1311 throw Unhandled(__FILE__, __LINE__);
1312 }
1313 ss << " i = ";
1314 if (!pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed()) {
1315 ss << "gid0;\n";
1316 } else {
1317 ss << "0;\n";
1318 }
1319 if(!pCurDVR1->IsStartFixed() && !pCurDVR1->IsEndFixed())
1320 {
1321 ss << " doubleIndex =i+gid0;\n";
1322 }else
1323 {
1324 ss << " doubleIndex =i;\n";
1325 }
1326 }
1327
1328 CheckSubArgumentIsNan(ss,vSubArguments,paraOneWidth);
1329
1330 unsigned paraThreeIndex = paraOneWidth + paraTwoWidth;
1331 if(vSubArguments.size() > paraThreeIndex)
1332 {
1333 if(vSubArguments[paraThreeIndex]->GetFormulaToken()->GetType() ==
1335 {
1336 FormulaToken *tmpCur2 =
1337 vSubArguments[paraThreeIndex]->GetFormulaToken();
1338 const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
1340 unsigned paraThreeWidth = pCurDVR2->GetArrays().size();
1341 if(paraThreeWidth > 1)
1342 {
1343 throw Unhandled(__FILE__, __LINE__);
1344 }
1345 }
1346 }
1347
1348 if(paraOneIsDoubleVector)
1349 {
1350 unsigned loopIndex = 0;
1351 FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
1352 const formula::DoubleVectorRefToken*pCurDVR0= static_cast<const
1354 size_t nCurWindowSize = pCurDVR0->GetArrayLength() <
1355 pCurDVR0->GetRefRowSize() ? pCurDVR0->GetArrayLength():
1356 pCurDVR0->GetRefRowSize() ;
1357
1358 for(loopIndex =0; loopIndex < loopTimes; loopIndex++)
1359 {
1360 ss << " for (i = ";
1361 if (!pCurDVR0->IsStartFixed() && pCurDVR0->IsEndFixed()) {
1362 ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
1363 } else if (pCurDVR0->IsStartFixed() && !pCurDVR0->IsEndFixed()) {
1364 ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
1365 } else {
1366 ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
1367 }
1368 ss << " {\n";
1369 if(!pCurDVR0->IsStartFixed() && !pCurDVR0->IsEndFixed())
1370 {
1371 ss << " doubleIndex =i+gid0;\n";
1372 }else
1373 {
1374 ss << " doubleIndex =i;\n";
1375 }
1376
1377 CheckSubArgumentIsNan(ss,vSubArguments, loopIndex);
1378
1379 ss << " if ( isequal( tmp";
1380 ss << loopIndex<<" , tmp"<<paraOneWidth<<") ) \n";
1381 ss << " {\n";
1382 if(vSubArguments.size() == paraThreeIndex)
1383 ss << " tmp += tmp"<<loopIndex<<";\n";
1384 else
1385 {
1386 CheckSubArgumentIsNan(ss,vSubArguments,
1387 paraThreeIndex+loopIndex);
1388 ss << " tmp += tmp";
1389 ss << paraThreeIndex+loopIndex<<";\n";
1390 }
1391 ss << " count+=1.0;\n";
1392 ss << " }\n";
1393 ss << " }\n";
1394 }
1395 }
1396 else
1397 {
1398 CheckSubArgumentIsNan(ss,vSubArguments, 0);
1399 ss << " if ( isequal( tmp0 , tmp1 ) ) \n";
1400 ss << " {\n";
1401 if(vSubArguments.size() == 2)
1402 ss << " tmp += tmp0;\n";
1403 else
1404 {
1405 CheckSubArgumentIsNan(ss,vSubArguments,2);
1406 ss << " tmp += tmp2;\n";
1407 }
1408 ss << " count+=1.0;\n";
1409 ss << " }\n";
1410 }
1411
1412 ss << " if(count!=0)\n";
1413 ss << " tmp=tmp/count;\n";
1414 ss << " else\n";
1415 ss << " tmp= 0 ;\n";
1416 ss << " return tmp;\n";
1417 ss << "}";
1418}
1419
1421 const std::string &sSymName, SubArguments &vSubArguments)
1422{
1424 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1425 ss << "{\n";
1426 ss << " int gid0=get_global_id(0);\n";
1427 ss << " double var[3], coeff, res = 0.0f;\n";
1428 GenerateArg( "var0", 0, vSubArguments, ss );
1429 GenerateArg( "var1", 1, vSubArguments, ss );
1430 GenerateArg( "var2", 2, vSubArguments, ss );
1431 ss << " if( var0 == 0 && var1 == 0 )\n";
1432 ss << " return CreateDoubleError(NoValue);\n"; // pow(0,0)
1433 ss << " var[0] = var0;\n";
1434 ss << " var[1] = var1;\n";
1435 ss << " var[2] = var2;\n";
1436 ss << " int j = 0;\n";
1437 GenerateRangeArg( 3, vSubArguments, ss, SkipEmpty,
1438 " double coeff = arg;\n"
1439 " res = res + coeff * pow(var[0], var[1] + j * var[2]);\n"
1440 " ++j;\n"
1441 );
1442 ss << " return res;\n";
1443 ss << "}";
1444}
1445
1447 const std::string& sSymName, SubArguments& vSubArguments )
1448{
1449 size_t nCurWindowSize = 0;
1450 FormulaToken* tmpCur = nullptr;
1451 const formula::DoubleVectorRefToken* pCurDVR = nullptr;
1452 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1453 ss << "{\n";
1454 for (size_t i = 0; i < vSubArguments.size(); i++)
1455 {
1456 size_t nCurChildWindowSize = vSubArguments[i]->GetWindowSize();
1457 nCurWindowSize = (nCurWindowSize < nCurChildWindowSize) ?
1458 nCurChildWindowSize : nCurWindowSize;
1459 tmpCur = vSubArguments[i]->GetFormulaToken();
1460 if (ocPush == tmpCur->GetOpCode())
1461 {
1462 pCurDVR = static_cast<const formula::DoubleVectorRefToken*>(tmpCur);
1463 if (pCurDVR->IsStartFixed() != pCurDVR->IsEndFixed())
1464 throw Unhandled(__FILE__, __LINE__);
1465 }
1466 }
1467 ss << " double tmp = 0.0;\n";
1468 ss << " int gid0 = get_global_id(0);\n";
1469
1470 ss << "\tint i;\n\t";
1471 ss << "int currentCount0;\n";
1472 for (size_t i = 0; i < vSubArguments.size() - 1; i++)
1473 ss << "int currentCount" << i + 1 << ";\n";
1474 outputstream temp3, temp4;
1475 int outLoopSize = UNROLLING_FACTOR;
1476 if (nCurWindowSize / outLoopSize != 0)
1477 {
1478 ss << "for(int outLoop=0; outLoop<" <<
1479 nCurWindowSize / outLoopSize << "; outLoop++){\n\t";
1480 for (int count = 0; count < outLoopSize; count++)
1481 {
1482 ss << "i = outLoop*" << outLoopSize << "+" << count << ";\n";
1483 if (count == 0)
1484 {
1485 for (size_t i = 0; i < vSubArguments.size(); i++)
1486 {
1487 tmpCur = vSubArguments[i]->GetFormulaToken();
1488 if (ocPush == tmpCur->GetOpCode())
1489 {
1490 pCurDVR = static_cast<const formula::DoubleVectorRefToken*>(tmpCur);
1491 if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
1492 {
1493 temp3 << " currentCount";
1494 temp3 << i;
1495 temp3 << " =i+gid0+1;\n";
1496 }
1497 else
1498 {
1499 temp3 << " currentCount";
1500 temp3 << i;
1501 temp3 << " =i+1;\n";
1502 }
1503 }
1504 }
1505
1506 temp3 << "tmp = fsum(";
1507 for (size_t i = 0; i < vSubArguments.size(); i++)
1508 {
1509 if (i)
1510 temp3 << "*";
1511 if (ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
1512 {
1513 temp3 << "(";
1514 temp3 << "(currentCount";
1515 temp3 << i;
1516 temp3 << ">";
1517 if (vSubArguments[i]->GetFormulaToken()->GetType() ==
1519 {
1520 const formula::SingleVectorRefToken* pSVR =
1521 static_cast<const formula::SingleVectorRefToken*>
1522 (vSubArguments[i]->GetFormulaToken());
1523 temp3 << pSVR->GetArrayLength();
1524 temp3 << ")||isnan(" << vSubArguments[i]
1525 ->GenSlidingWindowDeclRef();
1526 temp3 << ")?0:";
1527 temp3 << vSubArguments[i]->GenSlidingWindowDeclRef();
1528 temp3 << ")";
1529 }
1530 else if (vSubArguments[i]->GetFormulaToken()->GetType() ==
1532 {
1533 const formula::DoubleVectorRefToken* pSVR =
1534 static_cast<const formula::DoubleVectorRefToken*>
1535 (vSubArguments[i]->GetFormulaToken());
1536 temp3 << pSVR->GetArrayLength();
1537 temp3 << ")||isnan(" << vSubArguments[i]
1538 ->GenSlidingWindowDeclRef(true);
1539 temp3 << ")?0:";
1540 temp3 << vSubArguments[i]->GenSlidingWindowDeclRef(true);
1541 temp3 << ")";
1542 }
1543
1544 }
1545 else
1546 temp3 << vSubArguments[i]->GenSlidingWindowDeclRef(true);
1547 }
1548 temp3 << ", tmp);\n\t";
1549 }
1550 ss << temp3.str();
1551 }
1552 ss << "}\n\t";
1553 }
1554 //The residual of mod outLoopSize
1555 for (size_t count = nCurWindowSize / outLoopSize * outLoopSize;
1556 count < nCurWindowSize; count++)
1557 {
1558 ss << "i =" << count << ";\n";
1559 if (count == nCurWindowSize / outLoopSize * outLoopSize)
1560 {
1561 for (size_t i = 0; i < vSubArguments.size(); i++)
1562 {
1563 tmpCur = vSubArguments[i]->GetFormulaToken();
1564 if (ocPush == tmpCur->GetOpCode())
1565 {
1566 pCurDVR = static_cast<const formula::DoubleVectorRefToken*>(tmpCur);
1567 if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
1568 {
1569 temp4 << " currentCount";
1570 temp4 << i;
1571 temp4 << " =i+gid0+1;\n";
1572 }
1573 else
1574 {
1575 temp4 << " currentCount";
1576 temp4 << i;
1577 temp4 << " =i+1;\n";
1578 }
1579 }
1580 }
1581
1582 temp4 << "tmp = fsum(";
1583 for (size_t i = 0; i < vSubArguments.size(); i++)
1584 {
1585 if (i)
1586 temp4 << "*";
1587 if (ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
1588 {
1589 temp4 << "(";
1590 temp4 << "(currentCount";
1591 temp4 << i;
1592 temp4 << ">";
1593 if (vSubArguments[i]->GetFormulaToken()->GetType() ==
1595 {
1596 const formula::SingleVectorRefToken* pSVR =
1597 static_cast<const formula::SingleVectorRefToken*>
1598 (vSubArguments[i]->GetFormulaToken());
1599 temp4 << pSVR->GetArrayLength();
1600 temp4 << ")||isnan(" << vSubArguments[i]
1601 ->GenSlidingWindowDeclRef();
1602 temp4 << ")?0:";
1603 temp4 << vSubArguments[i]->GenSlidingWindowDeclRef();
1604 temp4 << ")";
1605 }
1606 else if (vSubArguments[i]->GetFormulaToken()->GetType() ==
1608 {
1609 const formula::DoubleVectorRefToken* pSVR =
1610 static_cast<const formula::DoubleVectorRefToken*>
1611 (vSubArguments[i]->GetFormulaToken());
1612 temp4 << pSVR->GetArrayLength();
1613 temp4 << ")||isnan(" << vSubArguments[i]
1614 ->GenSlidingWindowDeclRef(true);
1615 temp4 << ")?0:";
1616 temp4 << vSubArguments[i]->GenSlidingWindowDeclRef(true);
1617 temp4 << ")";
1618 }
1619
1620 }
1621 else
1622 {
1623 temp4 << vSubArguments[i]
1624 ->GenSlidingWindowDeclRef(true);
1625 }
1626 }
1627 temp4 << ", tmp);\n\t";
1628 }
1629 ss << temp4.str();
1630 }
1631 ss << "return tmp;\n";
1632 ss << "}";
1633}
1634
1635void OpSum::BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs)
1636{
1637 decls.insert(is_representable_integerDecl);
1638 funs.insert(is_representable_integer);
1639 decls.insert(approx_equalDecl);
1640 funs.insert(approx_equal);
1641 decls.insert(fsum_approxDecl);
1642 funs.insert(fsum_approx);
1643}
1644
1645void OpSub::BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs)
1646{
1647 decls.insert(is_representable_integerDecl);
1648 funs.insert(is_representable_integer);
1649 decls.insert(approx_equalDecl);
1650 funs.insert(approx_equal);
1651 decls.insert(fsub_approxDecl);
1652 funs.insert(fsub_approx);
1653}
1654
1655}
1656
1657/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const std::vector< VectorRefArray > & GetArrays() const
OpCode GetOpCode() const
StackVar GetType() const
virtual double GetDouble() const
static void CheckSubArgumentIsNan2(outputstream &ss, SubArguments &vSubArguments, int argumentNum, const std::string &p)
Definition: opbase.cxx:669
static void CheckSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments, int argumentNum)
Definition: opbase.cxx:605
static void GenTmpVariables(outputstream &ss, const SubArguments &vSubArguments)
Definition: opbase.cxx:594
static void UnrollDoubleVector(outputstream &ss, const outputstream &unrollstr, const formula::DoubleVectorRefToken *pCurDVR, int nCurWindowSize)
Definition: opbase.cxx:706
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:134
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:151
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:146
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:139
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:181
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:176
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:198
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:193
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:186
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:417
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:424
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:208
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:203
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1268
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:832
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:429
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:450
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:436
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:461
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:443
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1228
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:316
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:323
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:346
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:46
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:68
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:61
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:73
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:79
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:86
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:976
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:578
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:108
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:103
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:259
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:477
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:488
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:91
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:113
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:264
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1187
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:555
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:546
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:560
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:229
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:220
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:244
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:249
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:527
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:536
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:541
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:215
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:118
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:565
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:308
virtual void GenerateCode(outputstream &ss) const =0
This writes out OpenCL code returning the computed value, the argument is "arg0".
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:20
virtual void GenerateCode(outputstream &ss) const =0
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:32
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:387
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:399
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:234
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:502
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:513
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:285
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:292
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:412
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1249
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the arguments are "arg0" and "arg1".
Definition: op_math.cxx:472
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:239
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:948
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:920
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
Definition: op_math.cxx:885
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:892
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:56
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:51
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1420
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:128
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:123
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:254
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:169
virtual void BinInlineFun(std::set< std::string > &decls, std::set< std::string > &funs) override
Definition: op_math.cxx:1645
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1074
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:626
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1213
virtual void BinInlineFun(std::set< std::string > &decls, std::set< std::string > &funs) override
Definition: op_math.cxx:1635
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:164
virtual void GenerateCode(outputstream &ss) const override
This writes out OpenCL code returning the computed value, the argument is "arg0".
Definition: op_math.cxx:158
void GenerateArg(const char *name, int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero, GenerateArgTypeType generateType=DoNotGenerateArgType)
Definition: opbase.cxx:226
static void GenerateRangeArg(int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:414
void GenerateArgWithDefault(const char *name, int arg, double def, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero)
Definition: opbase.cxx:304
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
Definition: opbase.cxx:563
static void GenerateRangeArgs(int firstArg, int lastArg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:313
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:347
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_math.cxx:1446
Inconsistent state.
Definition: opbase.hxx:65
sal_Int64 n
int i
m
const char fsum_approxDecl[]
const char local_cothDecl[]
const char is_representable_integerDecl[]
const char fsum_approx[]
const char atan2Decl[]
const char atan2Content[]
const char Round[]
const char Math_Intg[]
const char fsub_approx[]
const char fsub_approxDecl[]
const char local_cosh[]
const char bikDecl[]
const char RoundDecl[]
const char approx_equalDecl[]
const char approx_equal[]
const char local_coshDecl[]
const char local_coth[]
const char value_approxDecl[]
const char value_approx[]
const char cell_equal[]
const char Math_IntgDecl[]
const char nCorrValDecl[]
const char cell_equalDecl[]
const char is_representable_integer[]
const char bik[]
#define UNROLLING_FACTOR
Definition: opbase.hxx:33
#define CHECK_PARAMETER_COUNT(min, max)
Definition: opbase.hxx:85
ocPush