/[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 5997 by caltinay, Mon Feb 29 07:24:47 2016 UTC revision 6144 by caltinay, Wed Apr 6 05:25:13 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 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
 #define ESNEEDPYTHON  
 #include "esysUtils/first.h"  
   
17  #include "DataLazy.h"  #include "DataLazy.h"
18  #include "Data.h"  #include "Data.h"
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 158  string ES_opstrings[]={"UNKNOWN","IDENTI Line 151  string ES_opstrings[]={"UNKNOWN","IDENTI
151                          "asinh","acosh","atanh",                          "asinh","acosh","atanh",
152                          "log10","log","sign","abs","neg","pos","exp","sqrt",                          "log10","log","sign","abs","neg","pos","exp","sqrt",
153                          "1/","where>0","where<0","where>=0","where<=0", "where<>0","where=0",                          "1/","where>0","where<0","where>=0","where<=0", "where<>0","where=0",
154                          "symmetric","nonsymmetric",                          "symmetric","antisymmetric",
155                          "prod",                          "prod",
156                          "transpose", "trace",                          "transpose", "trace",
157                          "swapaxes",                          "swapaxes",
158                          "minval", "maxval",                          "minval", "maxval",
159                          "condEval"};                          "condEval",
160  int ES_opcount=44;                          "hermitian","antihermitian"
161    };
162    int ES_opcount=46;
163  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENTITY,G_BINARY,G_BINARY,G_BINARY,G_BINARY, G_BINARY,  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENTITY,G_BINARY,G_BINARY,G_BINARY,G_BINARY, G_BINARY,
164                          G_UNARY,G_UNARY,G_UNARY, //10                          G_UNARY,G_UNARY,G_UNARY, //10
165                          G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,        // 17                          G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,G_UNARY,        // 17
# Line 176  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENT Line 171  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENT
171                          G_NP1OUT_P, G_NP1OUT_P,                          G_NP1OUT_P, G_NP1OUT_P,
172                          G_NP1OUT_2P,                          G_NP1OUT_2P,
173                          G_REDUCTION, G_REDUCTION,                          G_REDUCTION, G_REDUCTION,
174                          G_CONDEVAL};                          G_CONDEVAL,
175                            G_UNARY,G_UNARY
176    };
177  inline  inline
178  ES_opgroup  ES_opgroup
179  getOpgroup(ES_optype op)  getOpgroup(ES_optype op)
# Line 481  DataLazy::DataLazy(DataAbstract_ptr p) Line 478  DataLazy::DataLazy(DataAbstract_ptr p)
478     }     }
479     else     else
480     {     {
         p->makeLazyShared();  
481          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);
482          makeIdentity(dr);          makeIdentity(dr);
483  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)
# Line 946  DataLazy::collapseToReady() const Line 942  DataLazy::collapseToReady() const
942          result=left.symmetric();          result=left.symmetric();
943          break;          break;
944      case NSYM:      case NSYM:
945          result=left.nonsymmetric();          result=left.antisymmetric();
946          break;          break;
947      case PROD:      case PROD:
948          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);
# Line 966  DataLazy::collapseToReady() const Line 962  DataLazy::collapseToReady() const
962      case MAXVAL:      case MAXVAL:
963          result=left.minval();          result=left.minval();
964          break;          break;
965        case HER:
966        result=left.hermitian();
967        break;
968      default:      default:
969          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)+".");
970    }    }
# Line 993  DataLazy::collapse() const Line 992  DataLazy::collapse() const
992    m_op=IDENTITY;    m_op=IDENTITY;
993  }  }
994    
   
   
   
   
   
 #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;\  
         }  
   
   
995  // The result will be stored in m_samples  // The result will be stored in m_samples
996  // 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
997  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1028  LAZYDEBUG(cout << "Resolve sample " << t Line 1005  LAZYDEBUG(cout << "Resolve sample " << t
1005    }    }
1006    if (m_op==IDENTITY)      if (m_op==IDENTITY)  
1007    {    {
1008      const ValueType& vec=m_id->getVectorRO();      const RealVectorType& vec=m_id->getVectorRO();
1009      roffset=m_id->getPointOffset(sampleNo, 0);      roffset=m_id->getPointOffset(sampleNo, 0);
1010  #ifdef LAZY_STACK_PROF  #ifdef LAZY_STACK_PROF
1011  int x;  int x;
# Line 1085  DataLazy::resolveNodeUnary(int tid, int Line 1062  DataLazy::resolveNodeUnary(int tid, int
1062    const double* left=&((*leftres)[roffset]);    const double* left=&((*leftres)[roffset]);
1063    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1064    double* result=&(m_samples[roffset]);    double* result=&(m_samples[roffset]);
1065      escript::ESFunction operation=SINF;
1066    switch (m_op)    switch (m_op)
1067    {    {
1068      case SIN:        case SIN:
1069          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sin);      operation=SINF;
1070          break;      break;
1071      case COS:      case COS:
1072          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cos);          operation=COSF;
1073          break;      break;
1074      case TAN:      case TAN:
1075          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tan);          operation=TANF;
1076          break;      break;
1077      case ASIN:      case ASIN:
1078          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::asin);          operation=ASINF;
1079          break;      break;
1080      case ACOS:      case ACOS:
1081          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::acos);          operation=ACOSF;
1082          break;      break;
1083      case ATAN:      case ATAN:
1084          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::atan);          operation=ATANF;
1085          break;      break;
1086      case SINH:      case SINH:
1087          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sinh);          operation=SINHF;
1088          break;      break;
1089      case COSH:      case COSH:
1090          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cosh);          operation=COSHF;
1091          break;      break;
1092      case TANH:      case TANH:
1093          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tanh);          operation=TANHF;
1094          break;      break;
1095      case ERF:      case ERF:
1096  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ERFF;
1097          throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::erf);  
         break;  
 #endif  
1098     case ASINH:     case ASINH:
1099  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ASINHF;
1100          tensor_unary_operation(m_samplesize, left, result, escript::asinh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::asinh);  
 #endif    
         break;  
1101     case ACOSH:     case ACOSH:
1102  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ACOSHF;
1103          tensor_unary_operation(m_samplesize, left, result, escript::acosh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::acosh);  
 #endif    
         break;  
1104     case ATANH:     case ATANH:
1105  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ATANHF;
1106          tensor_unary_operation(m_samplesize, left, result, escript::atanh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::atanh);  
 #endif    
         break;  
1107      case LOG10:      case LOG10:
1108          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log10);          operation=LOG10F;
1109          break;      break;
1110      case LOG:      case LOG:
1111          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log);          operation=LOGF;
1112          break;      break;
1113      case SIGN:      case SIGN:
1114          tensor_unary_operation(m_samplesize, left, result, escript::fsign);          operation=SIGNF;
1115          break;      break;
1116      case ABS:      case ABS:
1117          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::fabs);          operation=ABSF;
1118          break;      break;
1119      case NEG:      case NEG:
1120          tensor_unary_operation(m_samplesize, left, result, negate<double>());          operation=NEGF;
1121          break;      break;
1122      case POS:      case POS:
1123          // it doesn't mean anything for delayed.          // it doesn't mean anything for delayed.
1124          // it will just trigger a deep copy of the lazy object          // it will just trigger a deep copy of the lazy object
1125          throw DataException("Programmer error - POS not supported for lazy data.");          throw DataException("Programmer error - POS not supported for lazy data.");
1126          break;          break;
1127      case EXP:      case EXP:
1128          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::exp);          operation=EXPF;
1129          break;      break;
1130      case SQRT:      case SQRT:
1131          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sqrt);          operation=SQRTF;
1132          break;      break;
1133      case RECIP:      case RECIP:
1134          tensor_unary_operation(m_samplesize, left, result, bind1st(divides<double>(),1.));          operation=INVF;
1135          break;      break;
1136      case GZ:      case GZ:
1137          tensor_unary_operation(m_samplesize, left, result, bind2nd(greater<double>(),0.0));          operation=GTZEROF;
1138          break;      break;
1139      case LZ:      case LZ:
1140          tensor_unary_operation(m_samplesize, left, result, bind2nd(less<double>(),0.0));          operation=LTZEROF;
1141          break;      break;
1142      case GEZ:      case GEZ:
1143          tensor_unary_operation(m_samplesize, left, result, bind2nd(greater_equal<double>(),0.0));          operation=GEZEROF;
1144          break;      break;
1145      case LEZ:      case LEZ:
1146          tensor_unary_operation(m_samplesize, left, result, bind2nd(less_equal<double>(),0.0));          operation=LEZEROF;
1147          break;      break;
1148  // There are actually G_UNARY_P but I don't see a compelling reason to treat them differently  // There are actually G_UNARY_P but I don't see a compelling reason to treat them differently
1149      case NEZ:      case NEZ:
1150          tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsGT(),m_tol));          operation=NEQZEROF;
1151          break;      break;
1152      case EZ:      case EZ:
1153          tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsLTE(),m_tol));          operation=EQZEROF;
1154          break;      break;
   
1155      default:      default:
1156          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");
1157    }    }
1158      tensor_unary_array_operation(m_samplesize,
1159                                 left,
1160                                 result,
1161                                 operation,
1162                                 m_tol);  
1163    return &(m_samples);    return &(m_samples);
1164  }  }
1165    
# Line 1227  DataLazy::resolveNodeReduction(int tid, Line 1193  DataLazy::resolveNodeReduction(int tid,
1193            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1194            {            {
1195              FMin op;              FMin op;
1196              *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());
1197              loffset+=psize;              loffset+=psize;
1198              result++;              result++;
1199            }            }
# Line 1238  DataLazy::resolveNodeReduction(int tid, Line 1204  DataLazy::resolveNodeReduction(int tid,
1204            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1205            {            {
1206            FMax op;            FMax op;
1207            *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);
1208            loffset+=psize;            loffset+=psize;
1209            result++;            result++;
1210            }            }
# Line 1265  DataLazy::resolveNodeNP1OUT(int tid, int Line 1231  DataLazy::resolveNodeNP1OUT(int tid, int
1231      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");
1232    }    }
1233    size_t subroffset;    size_t subroffset;
1234    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1235    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1236    size_t loop=0;    size_t loop=0;
1237    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;
# Line 1276  DataLazy::resolveNodeNP1OUT(int tid, int Line 1242  DataLazy::resolveNodeNP1OUT(int tid, int
1242      case SYM:      case SYM:
1243          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1244          {          {
1245              DataMaths::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1246              subroffset+=step;              subroffset+=step;
1247              offset+=step;              offset+=step;
1248          }          }
# Line 1284  DataLazy::resolveNodeNP1OUT(int tid, int Line 1250  DataLazy::resolveNodeNP1OUT(int tid, int
1250      case NSYM:      case NSYM:
1251          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1252          {          {
1253              DataMaths::nonsymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::antisymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1254              subroffset+=step;              subroffset+=step;
1255              offset+=step;              offset+=step;
1256          }          }
# Line 1311  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1277  DataLazy::resolveNodeNP1OUT_P(int tid, i
1277    }    }
1278    size_t subroffset;    size_t subroffset;
1279    size_t offset;    size_t offset;
1280    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1281    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1282    offset=roffset;    offset=roffset;
1283    size_t loop=0;    size_t loop=0;
# Line 1323  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1289  DataLazy::resolveNodeNP1OUT_P(int tid, i
1289      case TRACE:      case TRACE:
1290          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1291          {          {
1292              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);
1293              subroffset+=instep;              subroffset+=instep;
1294              offset+=outstep;              offset+=outstep;
1295          }          }
# Line 1331  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1297  DataLazy::resolveNodeNP1OUT_P(int tid, i
1297      case TRANS:      case TRANS:
1298          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1299          {          {
1300              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);
1301              subroffset+=instep;              subroffset+=instep;
1302              offset+=outstep;              offset+=outstep;
1303          }          }
# Line 1356  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1322  DataLazy::resolveNodeNP1OUT_2P(int tid,
1322    }    }
1323    size_t subroffset;    size_t subroffset;
1324    size_t offset;    size_t offset;
1325    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1326    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1327    offset=roffset;    offset=roffset;
1328    size_t loop=0;    size_t loop=0;
# Line 1368  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1334  DataLazy::resolveNodeNP1OUT_2P(int tid,
1334      case SWAP:      case SWAP:
1335          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1336          {          {
1337              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);
1338              subroffset+=instep;              subroffset+=instep;
1339              offset+=outstep;              offset+=outstep;
1340          }          }
# Line 1392  DataLazy::resolveNodeCondEval(int tid, i Line 1358  DataLazy::resolveNodeCondEval(int tid, i
1358    }    }
1359    size_t subroffset;    size_t subroffset;
1360    
1361    const ValueType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);
1362    const ValueType* srcres=0;    const RealVectorType* srcres=0;
1363    if ((*maskres)[subroffset]>0)    if ((*maskres)[subroffset]>0)
1364    {    {
1365          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
# Line 1536  LAZYDEBUG(cout << "Resolve binary: " << Line 1502  LAZYDEBUG(cout << "Resolve binary: " <<
1502    
1503    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0
1504          // Get the values of sub-expressions          // Get the values of sub-expressions
1505    const ValueType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);          const RealVectorType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);      
1506    const ValueType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);
1507  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)
1508  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;)
1509  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)
# Line 1555  LAZYDEBUG(cout << "Right res["<< rroffse Line 1521  LAZYDEBUG(cout << "Right res["<< rroffse
1521    switch(m_op)    switch(m_op)
1522    {    {
1523      case ADD:      case ADD:
1524          PROC_OP(NO_ARG,plus<double>());          //PROC_OP(NO_ARG,plus<double>());
1525          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1526                 &(*left)[0],
1527                 &(*right)[0],
1528                 chunksize,
1529                 onumsteps,
1530                 numsteps,
1531                 resultStep,
1532                 leftstep,
1533                 rightstep,
1534                 oleftstep,
1535                 orightstep,
1536                 lroffset,
1537                 rroffset,
1538                 escript::ESFunction::PLUSF);  
1539          break;          break;
1540      case SUB:      case SUB:
1541          PROC_OP(NO_ARG,minus<double>());        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1542                 &(*left)[0],
1543                 &(*right)[0],
1544                 chunksize,
1545                 onumsteps,
1546                 numsteps,
1547                 resultStep,
1548                 leftstep,
1549                 rightstep,
1550                 oleftstep,
1551                 orightstep,
1552                 lroffset,
1553                 rroffset,
1554                 escript::ESFunction::MINUSF);        
1555            //PROC_OP(NO_ARG,minus<double>());
1556          break;          break;
1557      case MUL:      case MUL:
1558          PROC_OP(NO_ARG,multiplies<double>());          //PROC_OP(NO_ARG,multiplies<double>());
1559          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1560                 &(*left)[0],
1561                 &(*right)[0],
1562                 chunksize,
1563                 onumsteps,
1564                 numsteps,
1565                 resultStep,
1566                 leftstep,
1567                 rightstep,
1568                 oleftstep,
1569                 orightstep,
1570                 lroffset,
1571                 rroffset,
1572                 escript::ESFunction::MULTIPLIESF);      
1573          break;          break;
1574      case DIV:      case DIV:
1575          PROC_OP(NO_ARG,divides<double>());          //PROC_OP(NO_ARG,divides<double>());
1576          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1577                 &(*left)[0],
1578                 &(*right)[0],
1579                 chunksize,
1580                 onumsteps,
1581                 numsteps,
1582                 resultStep,
1583                 leftstep,
1584                 rightstep,
1585                 oleftstep,
1586                 orightstep,
1587                 lroffset,
1588                 rroffset,
1589                 escript::ESFunction::DIVIDESF);          
1590          break;          break;
1591      case POW:      case POW:
1592         PROC_OP(double (double,double),::pow);         //PROC_OP(double (double,double),::pow);
1593          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1594                 &(*left)[0],
1595                 &(*right)[0],
1596                 chunksize,
1597                 onumsteps,
1598                 numsteps,
1599                 resultStep,
1600                 leftstep,
1601                 rightstep,
1602                 oleftstep,
1603                 orightstep,
1604                 lroffset,
1605                 rroffset,
1606                 escript::ESFunction::POWF);          
1607          break;          break;
1608      default:      default:
1609          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 1597  LAZYDEBUG(cout << "Resolve TensorProduct Line 1633  LAZYDEBUG(cout << "Resolve TensorProduct
1633    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1634    size_t offset=roffset;    size_t offset=roffset;
1635    
1636    const ValueType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);    const RealVectorType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);
1637    
1638    const ValueType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);
1639    
1640  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;
1641  cout << getNoValues() << endl;)  cout << getNoValues() << endl;)
# Line 1736  DataLazy::resolveGroupWorker(std::vector Line 1772  DataLazy::resolveGroupWorker(std::vector
1772    {             // 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
1773                  // all the other functionspaces match.                  // all the other functionspaces match.
1774          vector<DataExpanded*> dep;          vector<DataExpanded*> dep;
1775          vector<ValueType*> vecs;          vector<RealVectorType*> vecs;
1776          for (int i=0;i<work.size();++i)          for (int i=0;i<work.size();++i)
1777          {          {
1778                  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())));
1779                  vecs.push_back(&(dep[i]->getVectorRW()));                  vecs.push_back(&(dep[i]->getVectorRW()));
1780          }          }
1781          int totalsamples=work[0]->getNumSamples();          int totalsamples=work[0]->getNumSamples();
1782          const ValueType* res=0; // Storage for answer          const RealVectorType* res=0; // Storage for answer
1783          int sample;          int sample;
1784          #pragma omp parallel private(sample, res)          #pragma omp parallel private(sample, res)
1785          {          {
# Line 1795  DataLazy::resolveNodeWorker() Line 1831  DataLazy::resolveNodeWorker()
1831      return m_id;      return m_id;
1832    }    }
1833          // 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'
1834    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  RealVectorType(getNoValues()));
1835    ValueType& resvec=result->getVectorRW();    RealVectorType& resvec=result->getVectorRW();
1836    DataReady_ptr resptr=DataReady_ptr(result);    DataReady_ptr resptr=DataReady_ptr(result);
1837    
1838    int sample;    int sample;
1839    int totalsamples=getNumSamples();    int totalsamples=getNumSamples();
1840    const ValueType* res=0;       // Storage for answer    const RealVectorType* res=0;       // Storage for answer
1841  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)
1842    #pragma omp parallel private(sample,res)    #pragma omp parallel private(sample,res)
1843    {    {

Legend:
Removed from v.5997  
changed lines
  Added in v.6144

  ViewVC Help
Powered by ViewVC 1.1.26