/[escript]/branches/clazy/escriptcore/src/DataLazy.cpp
ViewVC logotype

Diff of /branches/clazy/escriptcore/src/DataLazy.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6001 by caltinay, Tue Mar 1 05:01:49 2016 UTC revision 6168 by jfenwick, Wed Apr 13 03:08:12 2016 UTC
# Line 5  Line 5 
5  * http://www.uq.edu.au  * http://www.uq.edu.au
6  *  *
7  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
8  * Licensed under the Open Software License version 3.0  * Licensed under the Apache License, version 2.0
9  * http://www.opensource.org/licenses/osl-3.0.php  * http://www.apache.org/licenses/LICENSE-2.0
10  *  *
11  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12  * Development 2012-2013 by School of Earth Sciences  * Development 2012-2013 by School of Earth Sciences
# Line 19  Line 19 
19  #include "DataTypes.h"  #include "DataTypes.h"
20  #include "EscriptParams.h"  #include "EscriptParams.h"
21  #include "FunctionSpace.h"  #include "FunctionSpace.h"
 #include "UnaryFuncs.h"    // for escript::fsign  
22  #include "Utils.h"  #include "Utils.h"
23    #include "DataVectorOps.h"
 #ifdef USE_NETCDF  
 #include <netcdfcpp.h>  
 #endif  
24    
25  #include <iomanip> // for some fancy formatting in debug  #include <iomanip> // for some fancy formatting in debug
26    
# Line 131  std::vector<void*> stackend(getNumberOfT Line 127  std::vector<void*> stackend(getNumberOfT
127  size_t maxstackuse=0;  size_t maxstackuse=0;
128  #endif  #endif
129    
 enum ES_opgroup  
 {  
    G_UNKNOWN,  
    G_IDENTITY,  
    G_BINARY,            // pointwise operations with two arguments  
    G_UNARY,             // pointwise operations with one argument  
    G_UNARY_P,           // pointwise operations with one argument, requiring a parameter  
    G_NP1OUT,            // non-pointwise op with one output  
    G_NP1OUT_P,          // non-pointwise op with one output requiring a parameter  
    G_TENSORPROD,        // general tensor product  
    G_NP1OUT_2P,         // non-pointwise op with one output requiring two params  
    G_REDUCTION,         // non-pointwise unary op with a scalar output  
    G_CONDEVAL  
 };  
   
   
   
   
 string ES_opstrings[]={"UNKNOWN","IDENTITY","+","-","*","/","^",  
                         "sin","cos","tan",  
                         "asin","acos","atan","sinh","cosh","tanh","erf",  
                         "asinh","acosh","atanh",  
                         "log10","log","sign","abs","neg","pos","exp","sqrt",  
                         "1/","where>0","where<0","where>=0","where<=0", "where<>0","where=0",  
                         "symmetric","nonsymmetric",  
                         "prod",  
                         "transpose", "trace",  
                         "swapaxes",  
                         "minval", "maxval",  
                         "condEval"};  
 int ES_opcount=44;  
 ES_opgroup opgroups[]={G_UNKNOWN,G_IDENTITY,G_BINARY,G_BINARY,G_BINARY,G_BINARY, G_BINARY,  
                         G_UNARY,G_UNARY,G_UNARY, //10  
                         G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,        // 17  
                         G_UNARY,G_UNARY,G_UNARY,                                        // 20  
                         G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,        // 28  
                         G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY, G_UNARY_P, G_UNARY_P,          // 35  
                         G_NP1OUT,G_NP1OUT,  
                         G_TENSORPROD,  
                         G_NP1OUT_P, G_NP1OUT_P,  
                         G_NP1OUT_2P,  
                         G_REDUCTION, G_REDUCTION,  
                         G_CONDEVAL};  
 inline  
 ES_opgroup  
 getOpgroup(ES_optype op)  
 {  
   return opgroups[op];  
 }  
130    
131  // return the FunctionSpace of the result of "left op right"  // return the FunctionSpace of the result of "left op right"
132  FunctionSpace  FunctionSpace
# Line 432  GTPShape(DataAbstract_ptr left, DataAbst Line 379  GTPShape(DataAbstract_ptr left, DataAbst
379    
380  }       // end anonymous namespace  }       // end anonymous namespace
381    
   
   
 // Return a string representing the operation  
 const std::string&  
 opToString(ES_optype op)  
 {  
   if (op<0 || op>=ES_opcount)  
   {  
     op=UNKNOWNOP;  
   }  
   return ES_opstrings[op];  
 }  
   
382  void DataLazy::LazyNodeSetup()  void DataLazy::LazyNodeSetup()
383  {  {
384  #ifdef _OPENMP  #ifdef _OPENMP
# Line 478  DataLazy::DataLazy(DataAbstract_ptr p) Line 412  DataLazy::DataLazy(DataAbstract_ptr p)
412     }     }
413     else     else
414     {     {
         p->makeLazyShared();  
415          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);
416          makeIdentity(dr);          makeIdentity(dr);
417  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)
# Line 943  DataLazy::collapseToReady() const Line 876  DataLazy::collapseToReady() const
876          result=left.symmetric();          result=left.symmetric();
877          break;          break;
878      case NSYM:      case NSYM:
879          result=left.nonsymmetric();          result=left.antisymmetric();
880          break;          break;
881      case PROD:      case PROD:
882          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);
# Line 963  DataLazy::collapseToReady() const Line 896  DataLazy::collapseToReady() const
896      case MAXVAL:      case MAXVAL:
897          result=left.minval();          result=left.minval();
898          break;          break;
899        case HER:
900        result=left.hermitian();
901        break;
902      default:      default:
903          throw DataException("Programmer error - collapseToReady does not know how to resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - collapseToReady does not know how to resolve operator "+opToString(m_op)+".");
904    }    }
# Line 990  DataLazy::collapse() const Line 926  DataLazy::collapse() const
926    m_op=IDENTITY;    m_op=IDENTITY;
927  }  }
928    
   
   
   
   
   
 #define PROC_OP(TYPE,X)                               \  
         for (int j=0;j<onumsteps;++j)\  
         {\  
           for (int i=0;i<numsteps;++i,resultp+=resultStep) \  
           { \  
 LAZYDEBUG(cout << "[left,right]=[" << lroffset << "," << rroffset << "]" << endl;)\  
 LAZYDEBUG(cout << "{left,right}={" << (*left)[lroffset] << "," << (*right)[rroffset] << "}\n";)\  
              tensor_binary_operation< TYPE >(chunksize, &((*left)[lroffset]), &((*right)[rroffset]), resultp, X); \  
 LAZYDEBUG(cout << " result=      " << resultp[0] << endl;) \  
              lroffset+=leftstep; \  
              rroffset+=rightstep; \  
           }\  
           lroffset+=oleftstep;\  
           rroffset+=orightstep;\  
         }  
   
   
929  // The result will be stored in m_samples  // The result will be stored in m_samples
930  // The return value is a pointer to the DataVector, offset is the offset within the return value  // The return value is a pointer to the DataVector, offset is the offset within the return value
931  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1025  LAZYDEBUG(cout << "Resolve sample " << t Line 939  LAZYDEBUG(cout << "Resolve sample " << t
939    }    }
940    if (m_op==IDENTITY)      if (m_op==IDENTITY)  
941    {    {
942      const ValueType& vec=m_id->getVectorRO();      const RealVectorType& vec=m_id->getVectorRO();
943      roffset=m_id->getPointOffset(sampleNo, 0);      roffset=m_id->getPointOffset(sampleNo, 0);
944  #ifdef LAZY_STACK_PROF  #ifdef LAZY_STACK_PROF
945  int x;  int x;
# Line 1082  DataLazy::resolveNodeUnary(int tid, int Line 996  DataLazy::resolveNodeUnary(int tid, int
996    const double* left=&((*leftres)[roffset]);    const double* left=&((*leftres)[roffset]);
997    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
998    double* result=&(m_samples[roffset]);    double* result=&(m_samples[roffset]);
999    switch (m_op)    if (m_op==POS)
1000    {    {
1001      case SIN:        // this should be prevented earlier
1002          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sin);      // operation is meaningless for lazy
1003          break;          throw DataException("Programmer error - POS not supported for lazy data.");    
1004      case COS:    }
1005          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cos);    tensor_unary_array_operation(m_samplesize,
1006          break;                               left,
1007      case TAN:                               result,
1008          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tan);                               m_op,
1009          break;                               m_tol);  
     case ASIN:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::asin);  
         break;  
     case ACOS:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::acos);  
         break;  
     case ATAN:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::atan);  
         break;  
     case SINH:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sinh);  
         break;  
     case COSH:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cosh);  
         break;  
     case TANH:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tanh);  
         break;  
     case ERF:  
 #if defined (_WIN32) && !defined(__INTEL_COMPILER)  
         throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");  
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::erf);  
         break;  
 #endif  
    case ASINH:  
 #if defined (_WIN32) && !defined(__INTEL_COMPILER)  
         tensor_unary_operation(m_samplesize, left, result, escript::asinh_substitute);  
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::asinh);  
 #endif    
         break;  
    case ACOSH:  
 #if defined (_WIN32) && !defined(__INTEL_COMPILER)  
         tensor_unary_operation(m_samplesize, left, result, escript::acosh_substitute);  
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::acosh);  
 #endif    
         break;  
    case ATANH:  
 #if defined (_WIN32) && !defined(__INTEL_COMPILER)  
         tensor_unary_operation(m_samplesize, left, result, escript::atanh_substitute);  
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::atanh);  
 #endif    
         break;  
     case LOG10:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log10);  
         break;  
     case LOG:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log);  
         break;  
     case SIGN:  
         tensor_unary_operation(m_samplesize, left, result, escript::fsign);  
         break;  
     case ABS:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::fabs);  
         break;  
     case NEG:  
         tensor_unary_operation(m_samplesize, left, result, negate<double>());  
         break;  
     case POS:  
         // it doesn't mean anything for delayed.  
         // it will just trigger a deep copy of the lazy object  
         throw DataException("Programmer error - POS not supported for lazy data.");  
         break;  
     case EXP:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::exp);  
         break;  
     case SQRT:  
         tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sqrt);  
         break;  
     case RECIP:  
         tensor_unary_operation(m_samplesize, left, result, bind1st(divides<double>(),1.));  
         break;  
     case GZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(greater<double>(),0.0));  
         break;  
     case LZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(less<double>(),0.0));  
         break;  
     case GEZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(greater_equal<double>(),0.0));  
         break;  
     case LEZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(less_equal<double>(),0.0));  
         break;  
 // There are actually G_UNARY_P but I don't see a compelling reason to treat them differently  
     case NEZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsGT(),m_tol));  
         break;  
     case EZ:  
         tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsLTE(),m_tol));  
         break;  
   
     default:  
         throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");  
   }  
1010    return &(m_samples);    return &(m_samples);
1011  }  }
1012    
# Line 1224  DataLazy::resolveNodeReduction(int tid, Line 1040  DataLazy::resolveNodeReduction(int tid,
1040            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1041            {            {
1042              FMin op;              FMin op;
1043              *result=DataMaths::reductionOp(*leftres, m_left->getShape(), loffset, op, numeric_limits<double>::max());              *result=escript::reductionOpVector(*leftres, m_left->getShape(), loffset, op, numeric_limits<double>::max());
1044              loffset+=psize;              loffset+=psize;
1045              result++;              result++;
1046            }            }
# Line 1235  DataLazy::resolveNodeReduction(int tid, Line 1051  DataLazy::resolveNodeReduction(int tid,
1051            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1052            {            {
1053            FMax op;            FMax op;
1054            *result=DataMaths::reductionOp(*leftres, m_left->getShape(), loffset, op, numeric_limits<double>::max()*-1);            *result=escript::reductionOpVector(*leftres, m_left->getShape(), loffset, op, numeric_limits<double>::max()*-1);
1055            loffset+=psize;            loffset+=psize;
1056            result++;            result++;
1057            }            }
# Line 1262  DataLazy::resolveNodeNP1OUT(int tid, int Line 1078  DataLazy::resolveNodeNP1OUT(int tid, int
1078      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");
1079    }    }
1080    size_t subroffset;    size_t subroffset;
1081    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1082    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1083    size_t loop=0;    size_t loop=0;
1084    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;
# Line 1273  DataLazy::resolveNodeNP1OUT(int tid, int Line 1089  DataLazy::resolveNodeNP1OUT(int tid, int
1089      case SYM:      case SYM:
1090          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1091          {          {
1092              DataMaths::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1093              subroffset+=step;              subroffset+=step;
1094              offset+=step;              offset+=step;
1095          }          }
# Line 1281  DataLazy::resolveNodeNP1OUT(int tid, int Line 1097  DataLazy::resolveNodeNP1OUT(int tid, int
1097      case NSYM:      case NSYM:
1098          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1099          {          {
1100              DataMaths::nonsymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::antisymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1101              subroffset+=step;              subroffset+=step;
1102              offset+=step;              offset+=step;
1103          }          }
# Line 1308  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1124  DataLazy::resolveNodeNP1OUT_P(int tid, i
1124    }    }
1125    size_t subroffset;    size_t subroffset;
1126    size_t offset;    size_t offset;
1127    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1128    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1129    offset=roffset;    offset=roffset;
1130    size_t loop=0;    size_t loop=0;
# Line 1320  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1136  DataLazy::resolveNodeNP1OUT_P(int tid, i
1136      case TRACE:      case TRACE:
1137          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1138          {          {
1139              DataMaths::trace(*leftres,m_left->getShape(),subroffset, m_samples ,getShape(),offset,m_axis_offset);              escript::trace(*leftres,m_left->getShape(),subroffset, m_samples ,getShape(),offset,m_axis_offset);
1140              subroffset+=instep;              subroffset+=instep;
1141              offset+=outstep;              offset+=outstep;
1142          }          }
# Line 1328  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1144  DataLazy::resolveNodeNP1OUT_P(int tid, i
1144      case TRANS:      case TRANS:
1145          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1146          {          {
1147              DataMaths::transpose(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset,m_axis_offset);              escript::transpose(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset,m_axis_offset);
1148              subroffset+=instep;              subroffset+=instep;
1149              offset+=outstep;              offset+=outstep;
1150          }          }
# Line 1353  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1169  DataLazy::resolveNodeNP1OUT_2P(int tid,
1169    }    }
1170    size_t subroffset;    size_t subroffset;
1171    size_t offset;    size_t offset;
1172    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1173    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1174    offset=roffset;    offset=roffset;
1175    size_t loop=0;    size_t loop=0;
# Line 1365  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1181  DataLazy::resolveNodeNP1OUT_2P(int tid,
1181      case SWAP:      case SWAP:
1182          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1183          {          {
1184              DataMaths::swapaxes(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset, m_axis_offset, m_transpose);              escript::swapaxes(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset, m_axis_offset, m_transpose);
1185              subroffset+=instep;              subroffset+=instep;
1186              offset+=outstep;              offset+=outstep;
1187          }          }
# Line 1389  DataLazy::resolveNodeCondEval(int tid, i Line 1205  DataLazy::resolveNodeCondEval(int tid, i
1205    }    }
1206    size_t subroffset;    size_t subroffset;
1207    
1208    const ValueType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);
1209    const ValueType* srcres=0;    const RealVectorType* srcres=0;
1210    if ((*maskres)[subroffset]>0)    if ((*maskres)[subroffset]>0)
1211    {    {
1212          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
# Line 1533  LAZYDEBUG(cout << "Resolve binary: " << Line 1349  LAZYDEBUG(cout << "Resolve binary: " <<
1349    
1350    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0
1351          // Get the values of sub-expressions          // Get the values of sub-expressions
1352    const ValueType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);          const RealVectorType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);      
1353    const ValueType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);
1354  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)
1355  LAZYDEBUG(cout << "shapes=" << DataTypes::shapeToString(m_left->getShape()) << "," << DataTypes::shapeToString(m_right->getShape()) << endl;)  LAZYDEBUG(cout << "shapes=" << DataTypes::shapeToString(m_left->getShape()) << "," << DataTypes::shapeToString(m_right->getShape()) << endl;)
1356  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)
# Line 1552  LAZYDEBUG(cout << "Right res["<< rroffse Line 1368  LAZYDEBUG(cout << "Right res["<< rroffse
1368    switch(m_op)    switch(m_op)
1369    {    {
1370      case ADD:      case ADD:
1371          PROC_OP(NO_ARG,plus<double>());          //PROC_OP(NO_ARG,plus<double>());
1372          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1373                 &(*left)[0],
1374                 &(*right)[0],
1375                 chunksize,
1376                 onumsteps,
1377                 numsteps,
1378                 resultStep,
1379                 leftstep,
1380                 rightstep,
1381                 oleftstep,
1382                 orightstep,
1383                 lroffset,
1384                 rroffset,
1385                 escript::ES_optype::ADD);  
1386          break;          break;
1387      case SUB:      case SUB:
1388          PROC_OP(NO_ARG,minus<double>());        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1389                 &(*left)[0],
1390                 &(*right)[0],
1391                 chunksize,
1392                 onumsteps,
1393                 numsteps,
1394                 resultStep,
1395                 leftstep,
1396                 rightstep,
1397                 oleftstep,
1398                 orightstep,
1399                 lroffset,
1400                 rroffset,
1401                 escript::ES_optype::SUB);        
1402            //PROC_OP(NO_ARG,minus<double>());
1403          break;          break;
1404      case MUL:      case MUL:
1405          PROC_OP(NO_ARG,multiplies<double>());          //PROC_OP(NO_ARG,multiplies<double>());
1406          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1407                 &(*left)[0],
1408                 &(*right)[0],
1409                 chunksize,
1410                 onumsteps,
1411                 numsteps,
1412                 resultStep,
1413                 leftstep,
1414                 rightstep,
1415                 oleftstep,
1416                 orightstep,
1417                 lroffset,
1418                 rroffset,
1419                 escript::ES_optype::MUL);        
1420          break;          break;
1421      case DIV:      case DIV:
1422          PROC_OP(NO_ARG,divides<double>());          //PROC_OP(NO_ARG,divides<double>());
1423          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1424                 &(*left)[0],
1425                 &(*right)[0],
1426                 chunksize,
1427                 onumsteps,
1428                 numsteps,
1429                 resultStep,
1430                 leftstep,
1431                 rightstep,
1432                 oleftstep,
1433                 orightstep,
1434                 lroffset,
1435                 rroffset,
1436                 escript::ES_optype::DIV);        
1437          break;          break;
1438      case POW:      case POW:
1439         PROC_OP(double (double,double),::pow);         //PROC_OP(double (double,double),::pow);
1440          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1441                 &(*left)[0],
1442                 &(*right)[0],
1443                 chunksize,
1444                 onumsteps,
1445                 numsteps,
1446                 resultStep,
1447                 leftstep,
1448                 rightstep,
1449                 oleftstep,
1450                 orightstep,
1451                 lroffset,
1452                 rroffset,
1453                 escript::ES_optype::POW);        
1454          break;          break;
1455      default:      default:
1456          throw DataException("Programmer error - resolveBinary can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveBinary can not resolve operator "+opToString(m_op)+".");
# Line 1594  LAZYDEBUG(cout << "Resolve TensorProduct Line 1480  LAZYDEBUG(cout << "Resolve TensorProduct
1480    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1481    size_t offset=roffset;    size_t offset=roffset;
1482    
1483    const ValueType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);    const RealVectorType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);
1484    
1485    const ValueType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);
1486    
1487  LAZYDEBUG(cerr << "[Left shape]=" << DataTypes::shapeToString(m_left->getShape()) << "\n[Right shape]=" << DataTypes::shapeToString(m_right->getShape()) << " result=" <<DataTypes::shapeToString(getShape()) <<  endl;  LAZYDEBUG(cerr << "[Left shape]=" << DataTypes::shapeToString(m_left->getShape()) << "\n[Right shape]=" << DataTypes::shapeToString(m_right->getShape()) << " result=" <<DataTypes::shapeToString(getShape()) <<  endl;
1488  cout << getNoValues() << endl;)  cout << getNoValues() << endl;)
# Line 1733  DataLazy::resolveGroupWorker(std::vector Line 1619  DataLazy::resolveGroupWorker(std::vector
1619    {             // it is possible that dats[0] is one of the objects which we discarded and    {             // it is possible that dats[0] is one of the objects which we discarded and
1620                  // all the other functionspaces match.                  // all the other functionspaces match.
1621          vector<DataExpanded*> dep;          vector<DataExpanded*> dep;
1622          vector<ValueType*> vecs;          vector<RealVectorType*> vecs;
1623          for (int i=0;i<work.size();++i)          for (int i=0;i<work.size();++i)
1624          {          {
1625                  dep.push_back(new DataExpanded(fs,work[i]->getShape(), ValueType(work[i]->getNoValues())));                  dep.push_back(new DataExpanded(fs,work[i]->getShape(), RealVectorType(work[i]->getNoValues())));
1626                  vecs.push_back(&(dep[i]->getVectorRW()));                  vecs.push_back(&(dep[i]->getVectorRW()));
1627          }          }
1628          int totalsamples=work[0]->getNumSamples();          int totalsamples=work[0]->getNumSamples();
1629          const ValueType* res=0; // Storage for answer          const RealVectorType* res=0; // Storage for answer
1630          int sample;          int sample;
1631          #pragma omp parallel private(sample, res)          #pragma omp parallel private(sample, res)
1632          {          {
# Line 1792  DataLazy::resolveNodeWorker() Line 1678  DataLazy::resolveNodeWorker()
1678      return m_id;      return m_id;
1679    }    }
1680          // from this point on we must have m_op!=IDENTITY and m_readytype=='E'          // from this point on we must have m_op!=IDENTITY and m_readytype=='E'
1681    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  RealVectorType(getNoValues()));
1682    ValueType& resvec=result->getVectorRW();    RealVectorType& resvec=result->getVectorRW();
1683    DataReady_ptr resptr=DataReady_ptr(result);    DataReady_ptr resptr=DataReady_ptr(result);
1684    
1685    int sample;    int sample;
1686    int totalsamples=getNumSamples();    int totalsamples=getNumSamples();
1687    const ValueType* res=0;       // Storage for answer    const RealVectorType* res=0;       // Storage for answer
1688  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)
1689    #pragma omp parallel private(sample,res)    #pragma omp parallel private(sample,res)
1690    {    {

Legend:
Removed from v.6001  
changed lines
  Added in v.6168

  ViewVC Help
Powered by ViewVC 1.1.26