LCOV - code coverage report
Current view: top level - sc/source/core/opencl - op_logical.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 195 0.0 %
Date: 2014-04-14 Functions: 0 4 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_logical.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             : 
      22             : using namespace formula;
      23             : 
      24             : namespace sc { namespace opencl {
      25           0 : void OpAnd::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";
      37           0 :     ss << "    int gid0 = get_global_id(0);\n";
      38           0 :     ss << "    double t = 1,tmp=0;\n";
      39           0 :     for(unsigned int j = 0; j< vSubArguments.size(); j++)
      40             :     {
      41           0 :         ss << "    double tmp"<<j<<" = 1;\n";
      42           0 :         FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
      43           0 :         if(tmpCur0->GetType() == formula::svSingleVectorRef)
      44             :         {
      45             : #ifdef ISNAN
      46             :         const formula::SingleVectorRefToken*pCurDVR= static_cast<const
      47           0 :             formula::SingleVectorRefToken *>(tmpCur0);
      48           0 :         ss<< "    int buffer_len"<<j<<" = "<<pCurDVR->GetArrayLength();
      49           0 :         ss<< ";\n";
      50           0 :         ss <<"    if(gid0 >= buffer_len"<<j<<" || isNan(";
      51           0 :         ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
      52           0 :         ss <<"))\n";
      53           0 :         ss <<"        tmp = 1;\n    else\n";
      54             : #endif
      55           0 :         ss <<"        tmp = ";
      56           0 :         ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
      57           0 :         ss <<"    tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
      58             :         }
      59           0 :         else if(tmpCur0->GetType() == formula::svDouble)
      60             :         {
      61           0 :             ss <<"        tmp = ";
      62           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
      63           0 :             ss <<"    tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
      64             :         }
      65           0 :         else if(tmpCur0->GetType() == formula::svDoubleVectorRef)
      66             :         {
      67             :             const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
      68           0 :             formula::DoubleVectorRefToken *>(tmpCur0);
      69           0 :             size_t nCurWindowSize = pCurDVR->GetArrayLength() <
      70           0 :             pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
      71           0 :             pCurDVR->GetRefRowSize() ;
      72           0 :             ss << "    for(int i = ";
      73           0 :             if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
      74           0 :             ss << "gid0; i < " << nCurWindowSize << "; i++) {\n";
      75             :             }
      76           0 :             else if(pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()){
      77           0 :             ss << "0; i < gid0 + " << nCurWindowSize << "; i++) {\n";
      78             :             }
      79             :             else{
      80           0 :             ss << "0; i < " << nCurWindowSize << "; i++) {\n";
      81             :             }
      82             : #ifdef ISNAN
      83           0 :             if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
      84             :                 {
      85           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
      86           0 :             ss <<")||i+gid0>="<<pCurDVR->GetArrayLength();
      87           0 :             ss <<")\n";
      88           0 :             ss <<"        tmp = 1;\n    else\n";
      89             :                 }
      90             :             else
      91             :                 {
      92           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
      93           0 :             ss <<")||i>="<<pCurDVR->GetArrayLength();
      94           0 :             ss <<")\n";
      95           0 :             ss <<"        tmp = 1;\n    else\n";
      96             :                 }
      97             : #endif
      98           0 :             ss <<"        tmp = ";
      99           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     100           0 :             ss <<"    tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
     101           0 :             ss <<"    }\n";
     102             :         }
     103           0 :         ss <<"    t = t && tmp"<<j<<";\n";
     104             :     }
     105           0 :     ss << "    return t;\n";
     106           0 :     ss << "}\n";
     107           0 : }
     108             : 
     109           0 : void OpOr::GenSlidingWindowFunction(std::stringstream &ss,
     110             :     const std::string &sSymName, SubArguments &vSubArguments)
     111             : {
     112           0 :     ss << "\ndouble " << sSymName;
     113           0 :     ss << "_"<< BinFuncName() <<"(";
     114           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
     115             :     {
     116           0 :         if (i)
     117           0 :             ss << ",";
     118           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
     119             :     }
     120           0 :     ss << ") {\n";
     121           0 :     ss << "    int gid0 = get_global_id(0);\n";
     122           0 :     ss << "    double t = 0,tmp=0;\n";
     123           0 :     for(unsigned int j = 0; j< vSubArguments.size(); j++)
     124             :     {
     125           0 :         ss << "    double tmp"<<j<<" = 0;\n";
     126           0 :         FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
     127           0 :         if(tmpCur0->GetType() == formula::svSingleVectorRef)
     128             :         {
     129             : #ifdef ISNAN
     130             :         const formula::SingleVectorRefToken*pCurDVR= static_cast<const
     131           0 :             formula::SingleVectorRefToken *>(tmpCur0);
     132           0 :         ss<< "    int buffer_len"<<j<<" = "<<pCurDVR->GetArrayLength();
     133           0 :         ss<< ";\n";
     134           0 :         ss <<"    if(gid0 >= buffer_len"<<j<<" || isNan(";
     135           0 :         ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
     136           0 :         ss <<"))\n";
     137           0 :         ss <<"        tmp = 0;\n    else\n";
     138             : #endif
     139           0 :         ss <<"        tmp = ";
     140           0 :         ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     141           0 :         ss <<"    tmp"<<j<<" = tmp"<<j<<" || tmp;\n";
     142             :         }
     143           0 :         else if(tmpCur0->GetType() == formula::svDouble)
     144             :         {
     145           0 :             ss <<"        tmp = ";
     146           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     147           0 :             ss <<"    tmp"<<j<<" = tmp"<<j<<" || tmp;\n";
     148             :         }
     149           0 :         else if(tmpCur0->GetType() == formula::svDoubleVectorRef)
     150             :         {
     151             :             const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
     152           0 :             formula::DoubleVectorRefToken *>(tmpCur0);
     153           0 :             size_t nCurWindowSize = pCurDVR->GetArrayLength() <
     154           0 :             pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
     155           0 :             pCurDVR->GetRefRowSize() ;
     156           0 :             ss << "    for(int i = ";
     157           0 :             if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
     158           0 :             ss << "gid0; i < " << nCurWindowSize << "; i++) {\n";
     159             :             }
     160           0 :             else if(pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()){
     161           0 :             ss << "0; i < gid0 + " << nCurWindowSize << "; i++) {\n";
     162             :             }
     163             :             else{
     164           0 :             ss << "0; i < " << nCurWindowSize << "; i++) {\n";
     165             :             }
     166             : #ifdef ISNAN
     167           0 :             if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
     168             :                 {
     169           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
     170           0 :             ss <<")||i+gid0>="<<pCurDVR->GetArrayLength();
     171           0 :             ss <<")\n";
     172           0 :             ss <<"        tmp = 0;\n    else\n";
     173             :                 }
     174             :             else
     175             :                 {
     176           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
     177           0 :             ss <<")||i>="<<pCurDVR->GetArrayLength();
     178           0 :             ss <<")\n";
     179           0 :             ss <<"        tmp = 0;\n    else\n";
     180             :                 }
     181             : #endif
     182           0 :             ss <<"        tmp = ";
     183           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     184           0 :             ss <<"    tmp"<<j<<" = tmp"<<j<<" || tmp;\n";
     185           0 :             ss <<"    }\n";
     186             :         }
     187           0 :         ss <<"    t = t || tmp"<<j<<";\n";
     188             :     }
     189           0 :     ss << "    return t;\n";
     190           0 :     ss << "}\n";
     191           0 : }
     192           0 : void OpNot::GenSlidingWindowFunction(std::stringstream &ss,
     193             :     const std::string &sSymName, SubArguments &vSubArguments)
     194             : {
     195           0 :     ss << "\ndouble " << sSymName;
     196           0 :     ss << "_"<< BinFuncName() <<"(";
     197           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
     198             :     {
     199           0 :         if (i)
     200           0 :             ss << ",";
     201           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
     202             :     }
     203           0 :     ss << ") {\n";
     204           0 :     ss << "    int gid0 = get_global_id(0);\n";
     205           0 :     ss << "    double tmp=0;\n";
     206           0 :     FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
     207           0 :     if(tmpCur0->GetType() == formula::svSingleVectorRef)
     208             :     {
     209             : #ifdef ISNAN
     210             :         const formula::SingleVectorRefToken*pCurDVR= static_cast<const
     211           0 :             formula::SingleVectorRefToken *>(tmpCur0);
     212           0 :         ss <<"    if(gid0 >= "<<pCurDVR->GetArrayLength()<<" || isNan(";
     213           0 :         ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
     214           0 :         ss <<"))\n";
     215           0 :         ss <<"        tmp = 0;\n    else\n";
     216             : #endif
     217           0 :         ss <<"        tmp = ";
     218           0 :         ss <<vSubArguments[0]->GenSlidingWindowDeclRef()<<";\n";
     219           0 :         ss <<"    tmp = (tmp == 0.0);\n";
     220             :     }
     221           0 :     else if(tmpCur0->GetType() == formula::svDouble)
     222             :     {
     223           0 :         ss <<"        tmp = ";
     224           0 :         ss <<vSubArguments[0]->GenSlidingWindowDeclRef()<<";\n";
     225           0 :         ss <<"    tmp = (tmp == 0.0);\n";
     226             :     }
     227           0 :     ss << "    return tmp;\n";
     228           0 :     ss << "}\n";
     229           0 : }
     230             : 
     231           0 : void OpXor::GenSlidingWindowFunction(std::stringstream &ss,
     232             :     const std::string &sSymName, SubArguments &vSubArguments)
     233             : {
     234           0 :     ss << "\ndouble " << sSymName;
     235           0 :     ss << "_"<< BinFuncName() <<"(";
     236           0 :     for (unsigned i = 0; i < vSubArguments.size(); i++)
     237             :     {
     238           0 :         if (i)
     239           0 :             ss << ",";
     240           0 :         vSubArguments[i]->GenSlidingWindowDecl(ss);
     241             :     }
     242           0 :     ss << ") {\n";
     243           0 :     ss << "    int gid0 = get_global_id(0);\n";
     244           0 :     ss << "    int t = 0,tmp0 = 0;\n";
     245           0 :     ss << "    double tmp = 0;\n";
     246           0 :     for(unsigned int j = 0; j< vSubArguments.size(); j++)
     247             :     {
     248           0 :         FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
     249           0 :         if(tmpCur0->GetType() == formula::svSingleVectorRef)
     250             :         {
     251             : #ifdef ISNAN
     252             :             const formula::SingleVectorRefToken*pCurDVR= static_cast<const
     253           0 :                 formula::SingleVectorRefToken *>(tmpCur0);
     254           0 :             ss <<"    if(gid0 >= "<<pCurDVR->GetArrayLength()<<" || isNan(";
     255           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
     256           0 :             ss <<"))\n";
     257           0 :             ss <<"        tmp = 0;\n    else\n";
     258             : #endif
     259           0 :             ss <<"        tmp = ";
     260           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     261           0 :             ss <<"    tmp0 = (tmp != 0);\n";
     262           0 :             ss <<"    t = t ^tmp0;\n";
     263             :         }
     264           0 :         else if(tmpCur0->GetType() == formula::svDouble)
     265             :         {
     266           0 :             ss <<"        tmp = ";
     267           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     268           0 :             ss <<"    tmp0 = (tmp != 0);\n";
     269           0 :             ss <<"    t = t ^tmp0;\n";
     270             :         }
     271           0 :         else if(tmpCur0->GetType() == formula::svDoubleVectorRef)
     272             :         {
     273             :             const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
     274           0 :             formula::DoubleVectorRefToken *>(tmpCur0);
     275           0 :             size_t nCurWindowSize = pCurDVR->GetArrayLength() <
     276           0 :             pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
     277           0 :             pCurDVR->GetRefRowSize() ;
     278           0 :             ss << "    for(int i = ";
     279           0 :             if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
     280           0 :             ss << "gid0; i < " << nCurWindowSize << "; i++) {\n";
     281             :             }
     282           0 :             else if(pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()){
     283           0 :             ss << "0; i < gid0 + " << nCurWindowSize << "; i++) {\n";
     284             :             }
     285             :             else{
     286           0 :             ss << "0; i < " << nCurWindowSize << "; i++) {\n";
     287             :             }
     288             : #ifdef ISNAN
     289           0 :             if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
     290             :                 {
     291           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
     292           0 :             ss <<")||i+gid0>="<<pCurDVR->GetArrayLength();
     293           0 :             ss <<")\n";
     294           0 :             ss <<"        tmp = 0;\n    else\n";
     295             :                 }
     296             :             else
     297             :                 {
     298           0 :             ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
     299           0 :             ss <<")||i>="<<pCurDVR->GetArrayLength();
     300           0 :             ss <<")\n";
     301           0 :             ss <<"        tmp = 0;\n    else\n";
     302             :                 }
     303             : #endif
     304           0 :             ss <<"        tmp = ";
     305           0 :             ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
     306           0 :             ss <<"    tmp0 = (tmp != 0);\n";
     307           0 :             ss <<"    t = t ^tmp0;\n";
     308           0 :             ss <<"    }\n";
     309             :         }
     310             :     }
     311           0 :     ss << "    return t;\n";
     312           0 :     ss << "}\n";
     313           0 : }
     314             : 
     315             : }}
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10