LCOV - code coverage report
Current view: top level - sc/source/core/opencl - op_array.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 114 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_array.hxx"
      11             : 
      12             : #include "formulagroup.hxx"
      13             : #include "document.hxx"
      14             : #include "formulacell.hxx"
      15             : #include "tokenarray.hxx"
      16             : #include "compiler.hxx"
      17             : #include "interpre.hxx"
      18             : #include "formula/vectortoken.hxx"
      19             : #include <sstream>
      20             : 
      21             : using namespace formula;
      22             : 
      23             : namespace sc { namespace opencl {
      24             : 
      25           0 : void OpSumX2MY2::GenSlidingWindowFunction(std::stringstream &ss,
      26             :             const std::string &sSymName, SubArguments &vSubArguments)
      27             : {
      28           0 :     ss << "\ndouble " << sSymName;
      29           0 :     ss << "_"<< BinFuncName() <<"(";
      30           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
      31             :     {
      32           0 :         if (i)
      33           0 :             ss << ",";
      34           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
      35             :     }
      36           0 :     ss << ")\n    {\n";
      37           0 :     ss <<"     int gid0=get_global_id(0);\n";
      38           0 :     ss << "    double tmp =0;\n";
      39           0 :     GenTmpVariables(ss,vSubArguments);
      40           0 :     if(vSubArguments[0]->GetFormulaToken()->GetType() ==
      41             :     formula::svDoubleVectorRef)
      42             :     {
      43           0 :         FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
      44             :         const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
      45           0 :             formula::DoubleVectorRefToken *>(tmpCur);
      46           0 :         size_t nCurWindowSize = pCurDVR->GetArrayLength() <
      47           0 :         pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
      48           0 :         pCurDVR->GetRefRowSize() ;
      49           0 :          ss << "    int i ;\n";
      50           0 :          ss << "    for (i = ";
      51           0 :          if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
      52           0 :             ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
      53           0 :          } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
      54           0 :             ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
      55             :          } else {
      56           0 :             ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
      57             :          }
      58           0 :          ss << "    {\n";
      59           0 :          if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
      60             :          {
      61           0 :             ss << "    int doubleIndex =i+gid0;\n";
      62             :          }else
      63             :          {
      64           0 :             ss << "    int doubleIndex =i;\n";
      65             :          }
      66             : 
      67           0 :         CheckSubArgumentIsNan(ss,vSubArguments,0);
      68           0 :         CheckSubArgumentIsNan(ss,vSubArguments,1);
      69           0 :         ss << "     tmp +=pow(tmp0,2) - pow(tmp1,2);\n";
      70           0 :         ss <<"    }\n";
      71             :     }
      72             :     else
      73             :     {
      74           0 :         ss << "    int singleIndex =gid0;\n";
      75           0 :         CheckAllSubArgumentIsNan(ss, vSubArguments);
      76           0 :         ss << "    tmp = pow(tmp0,2) - pow(tmp1,2);\n";
      77             :     }
      78           0 :     ss << "return tmp;\n";
      79           0 :     ss << "}";
      80           0 : }
      81             : 
      82           0 : void OpSumX2PY2::GenSlidingWindowFunction(std::stringstream &ss,
      83             :             const std::string &sSymName, SubArguments &vSubArguments)
      84             : {
      85           0 :     ss << "\ndouble " << sSymName;
      86           0 :     ss << "_"<< BinFuncName() <<"(";
      87           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
      88             :     {
      89           0 :         if (i)
      90           0 :             ss << ",";
      91           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
      92             :     }
      93           0 :     ss << ")\n    {\n";
      94           0 :     ss << "    int gid0=get_global_id(0);\n";
      95           0 :     ss << "    double tmp =0;\n";
      96           0 :     GenTmpVariables(ss,vSubArguments);
      97           0 :     if(vSubArguments[0]->GetFormulaToken()->GetType() ==
      98             :     formula::svDoubleVectorRef)
      99             :     {
     100           0 :         FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
     101             :         const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
     102           0 :             formula::DoubleVectorRefToken *>(tmpCur);
     103           0 :         size_t nCurWindowSize = pCurDVR->GetArrayLength() <
     104           0 :         pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
     105           0 :         pCurDVR->GetRefRowSize() ;
     106           0 :          ss << "    int i ;\n";
     107           0 :          ss << "    for (i = ";
     108           0 :          if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
     109           0 :             ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
     110           0 :          } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
     111           0 :             ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
     112             :          } else {
     113           0 :             ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
     114             :          }
     115           0 :          ss << "    {\n";
     116           0 :          if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
     117             :          {
     118           0 :             ss << "    int doubleIndex =i+gid0;\n";
     119             :          }else
     120             :          {
     121           0 :             ss << "    int doubleIndex =i;\n";
     122             :          }
     123             : 
     124           0 :         CheckSubArgumentIsNan(ss,vSubArguments,0);
     125           0 :         CheckSubArgumentIsNan(ss,vSubArguments,1);
     126           0 :         ss << "     tmp +=pow(tmp0,2) + pow(tmp1,2);\n";
     127           0 :         ss <<"    }\n";
     128             :     }
     129             :     else
     130             :     {
     131           0 :         ss << "    int singleIndex =gid0;\n";
     132           0 :         CheckAllSubArgumentIsNan(ss, vSubArguments);
     133           0 :         ss << "    tmp = pow(tmp0,2) + pow(tmp1,2);\n";
     134             :     }
     135           0 :     ss << "    return tmp;\n";
     136           0 :     ss << "}";
     137           0 : }
     138           0 : void OpSumXMY2::GenSlidingWindowFunction(std::stringstream &ss,
     139             :             const std::string &sSymName, SubArguments &vSubArguments)
     140             : {
     141           0 :     ss << "\ndouble " << sSymName;
     142           0 :     ss << "_"<< BinFuncName() <<"(";
     143           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
     144             :     {
     145           0 :         if (i)
     146           0 :             ss << ",";
     147           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
     148             :     }
     149           0 :     ss << ")\n    {\n";
     150           0 :     ss << "    int gid0=get_global_id(0);\n";
     151           0 :     ss << "    double tmp =0;\n";
     152           0 :     GenTmpVariables(ss,vSubArguments);
     153           0 :     if(vSubArguments[0]->GetFormulaToken()->GetType() ==
     154             :     formula::svDoubleVectorRef)
     155             :     {
     156           0 :         FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
     157             :         const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
     158           0 :             formula::DoubleVectorRefToken *>(tmpCur);
     159           0 :         size_t nCurWindowSize = pCurDVR->GetArrayLength() <
     160           0 :         pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
     161           0 :         pCurDVR->GetRefRowSize() ;
     162           0 :          ss << "    int i ;\n";
     163           0 :          ss << "    for (i = ";
     164           0 :          if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
     165           0 :             ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
     166           0 :          } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
     167           0 :             ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
     168             :          } else {
     169           0 :             ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
     170             :          }
     171           0 :          ss << "    {\n";
     172           0 :          if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
     173             :          {
     174           0 :             ss << "    int doubleIndex =i+gid0;\n";
     175             :          }else
     176             :          {
     177           0 :             ss << "    int doubleIndex =i;\n";
     178             :          }
     179             : 
     180           0 :         CheckSubArgumentIsNan(ss,vSubArguments,0);
     181           0 :         CheckSubArgumentIsNan(ss,vSubArguments,1);
     182           0 :         ss << "     tmp +=pow((tmp0-tmp1),2);\n";
     183           0 :         ss <<"    }\n";
     184             :     }
     185             :     else
     186             :     {
     187           0 :         ss << "    int singleIndex =gid0;\n";
     188           0 :         CheckAllSubArgumentIsNan(ss, vSubArguments);
     189           0 :         ss << "    tmp = pow((tmp0-tmp1),2);\n";
     190             :     }
     191           0 :     ss << "    return tmp;\n";
     192           0 :     ss << "}";
     193           0 : }
     194             : 
     195             : }}
     196             : 
     197             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10