/[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 5972 by caltinay, Wed Feb 24 04:05:30 2016 UTC revision 6125 by jfenwick, Tue Apr 5 04:12: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"
24    
 #include "esysUtils/Esys_MPI.h"  
   
 #ifdef _OPENMP  
 #include <omp.h>  
 #endif  
25  #ifdef USE_NETCDF  #ifdef USE_NETCDF
26  #include <netcdfcpp.h>  #include <netcdfcpp.h>
27  #endif  #endif
28    
29  #include <iomanip>              // for some fancy formatting in debug  #include <iomanip> // for some fancy formatting in debug
30    
31  using namespace escript::DataTypes;  using namespace escript::DataTypes;
32    
# Line 163  string ES_opstrings[]={"UNKNOWN","IDENTI Line 155  string ES_opstrings[]={"UNKNOWN","IDENTI
155                          "asinh","acosh","atanh",                          "asinh","acosh","atanh",
156                          "log10","log","sign","abs","neg","pos","exp","sqrt",                          "log10","log","sign","abs","neg","pos","exp","sqrt",
157                          "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",
158                          "symmetric","nonsymmetric",                          "symmetric","antisymmetric",
159                          "prod",                          "prod",
160                          "transpose", "trace",                          "transpose", "trace",
161                          "swapaxes",                          "swapaxes",
162                          "minval", "maxval",                          "minval", "maxval",
163                          "condEval"};                          "condEval",
164  int ES_opcount=44;                          "hermitian","antihermitian"
165    };
166    int ES_opcount=46;
167  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,
168                          G_UNARY,G_UNARY,G_UNARY, //10                          G_UNARY,G_UNARY,G_UNARY, //10
169                          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 181  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENT Line 175  ES_opgroup opgroups[]={G_UNKNOWN,G_IDENT
175                          G_NP1OUT_P, G_NP1OUT_P,                          G_NP1OUT_P, G_NP1OUT_P,
176                          G_NP1OUT_2P,                          G_NP1OUT_2P,
177                          G_REDUCTION, G_REDUCTION,                          G_REDUCTION, G_REDUCTION,
178                          G_CONDEVAL};                          G_CONDEVAL,
179                            G_UNARY,G_UNARY
180    };
181  inline  inline
182  ES_opgroup  ES_opgroup
183  getOpgroup(ES_optype op)  getOpgroup(ES_optype op)
# Line 486  DataLazy::DataLazy(DataAbstract_ptr p) Line 482  DataLazy::DataLazy(DataAbstract_ptr p)
482     }     }
483     else     else
484     {     {
         p->makeLazyShared();  
485          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);          DataReady_ptr dr=dynamic_pointer_cast<DataReady>(p);
486          makeIdentity(dr);          makeIdentity(dr);
487  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)  LAZYDEBUG(cout << "Wrapping " << dr.get() << " id=" << m_id.get() << endl;)
# Line 951  DataLazy::collapseToReady() const Line 946  DataLazy::collapseToReady() const
946          result=left.symmetric();          result=left.symmetric();
947          break;          break;
948      case NSYM:      case NSYM:
949          result=left.nonsymmetric();          result=left.antisymmetric();
950          break;          break;
951      case PROD:      case PROD:
952          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);          result=C_GeneralTensorProduct(left,right,m_axis_offset, m_transpose);
# Line 971  DataLazy::collapseToReady() const Line 966  DataLazy::collapseToReady() const
966      case MAXVAL:      case MAXVAL:
967          result=left.minval();          result=left.minval();
968          break;          break;
969        case HER:
970        result=left.hermitian();
971        break;
972      default:      default:
973          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)+".");
974    }    }
# Line 998  DataLazy::collapse() const Line 996  DataLazy::collapse() const
996    m_op=IDENTITY;    m_op=IDENTITY;
997  }  }
998    
   
   
   
   
   
 #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;\  
         }  
   
   
999  // The result will be stored in m_samples  // The result will be stored in m_samples
1000  // 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
1001  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1033  LAZYDEBUG(cout << "Resolve sample " << t Line 1009  LAZYDEBUG(cout << "Resolve sample " << t
1009    }    }
1010    if (m_op==IDENTITY)      if (m_op==IDENTITY)  
1011    {    {
1012      const ValueType& vec=m_id->getVectorRO();      const RealVectorType& vec=m_id->getVectorRO();
1013      roffset=m_id->getPointOffset(sampleNo, 0);      roffset=m_id->getPointOffset(sampleNo, 0);
1014  #ifdef LAZY_STACK_PROF  #ifdef LAZY_STACK_PROF
1015  int x;  int x;
# Line 1090  DataLazy::resolveNodeUnary(int tid, int Line 1066  DataLazy::resolveNodeUnary(int tid, int
1066    const double* left=&((*leftres)[roffset]);    const double* left=&((*leftres)[roffset]);
1067    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1068    double* result=&(m_samples[roffset]);    double* result=&(m_samples[roffset]);
1069      escript::ESFunction operation=SINF;
1070    switch (m_op)    switch (m_op)
1071    {    {
1072      case SIN:        case SIN:
1073          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sin);      operation=SINF;
1074          break;      break;
1075      case COS:      case COS:
1076          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cos);          operation=COSF;
1077          break;      break;
1078      case TAN:      case TAN:
1079          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tan);          operation=TANF;
1080          break;      break;
1081      case ASIN:      case ASIN:
1082          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::asin);          operation=ASINF;
1083          break;      break;
1084      case ACOS:      case ACOS:
1085          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::acos);          operation=ACOSF;
1086          break;      break;
1087      case ATAN:      case ATAN:
1088          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::atan);          operation=ATANF;
1089          break;      break;
1090      case SINH:      case SINH:
1091          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sinh);          operation=SINHF;
1092          break;      break;
1093      case COSH:      case COSH:
1094          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::cosh);          operation=COSHF;
1095          break;      break;
1096      case TANH:      case TANH:
1097          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::tanh);          operation=TANHF;
1098          break;      break;
1099      case ERF:      case ERF:
1100  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ERFF;
1101          throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::erf);  
         break;  
 #endif  
1102     case ASINH:     case ASINH:
1103  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ASINHF;
1104          tensor_unary_operation(m_samplesize, left, result, escript::asinh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::asinh);  
 #endif    
         break;  
1105     case ACOSH:     case ACOSH:
1106  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ACOSHF;
1107          tensor_unary_operation(m_samplesize, left, result, escript::acosh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::acosh);  
 #endif    
         break;  
1108     case ATANH:     case ATANH:
1109  #if defined (_WIN32) && !defined(__INTEL_COMPILER)          operation=ATANHF;
1110          tensor_unary_operation(m_samplesize, left, result, escript::atanh_substitute);      break;
 #else  
         tensor_unary_operation(m_samplesize, left, result, ::atanh);  
 #endif    
         break;  
1111      case LOG10:      case LOG10:
1112          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log10);          operation=LOG10F;
1113          break;      break;
1114      case LOG:      case LOG:
1115          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::log);          operation=LOGF;
1116          break;      break;
1117      case SIGN:      case SIGN:
1118          tensor_unary_operation(m_samplesize, left, result, escript::fsign);          operation=SIGNF;
1119          break;      break;
1120      case ABS:      case ABS:
1121          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::fabs);          operation=ABSF;
1122          break;      break;
1123      case NEG:      case NEG:
1124          tensor_unary_operation(m_samplesize, left, result, negate<double>());          operation=NEGF;
1125          break;      break;
1126      case POS:      case POS:
1127          // it doesn't mean anything for delayed.          // it doesn't mean anything for delayed.
1128          // it will just trigger a deep copy of the lazy object          // it will just trigger a deep copy of the lazy object
1129          throw DataException("Programmer error - POS not supported for lazy data.");          throw DataException("Programmer error - POS not supported for lazy data.");
1130          break;          break;
1131      case EXP:      case EXP:
1132          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::exp);          operation=EXPF;
1133          break;      break;
1134      case SQRT:      case SQRT:
1135          tensor_unary_operation<double (*)(double)>(m_samplesize, left, result, ::sqrt);          operation=SQRTF;
1136          break;      break;
1137      case RECIP:      case RECIP:
1138          tensor_unary_operation(m_samplesize, left, result, bind1st(divides<double>(),1.));          operation=INVF;
1139          break;      break;
1140      case GZ:      case GZ:
1141          tensor_unary_operation(m_samplesize, left, result, bind2nd(greater<double>(),0.0));          operation=GTZEROF;
1142          break;      break;
1143      case LZ:      case LZ:
1144          tensor_unary_operation(m_samplesize, left, result, bind2nd(less<double>(),0.0));          operation=LTZEROF;
1145          break;      break;
1146      case GEZ:      case GEZ:
1147          tensor_unary_operation(m_samplesize, left, result, bind2nd(greater_equal<double>(),0.0));          operation=GEZEROF;
1148          break;      break;
1149      case LEZ:      case LEZ:
1150          tensor_unary_operation(m_samplesize, left, result, bind2nd(less_equal<double>(),0.0));          operation=LEZEROF;
1151          break;      break;
1152  // 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
1153      case NEZ:      case NEZ:
1154          tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsGT(),m_tol));          operation=NEQZEROF;
1155          break;      break;
1156      case EZ:      case EZ:
1157          tensor_unary_operation(m_samplesize, left, result, bind2nd(AbsLTE(),m_tol));          operation=EQZEROF;
1158          break;      break;
   
1159      default:      default:
1160          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");
1161    }    }
1162      tensor_unary_array_operation(m_samplesize,
1163                                 left,
1164                                 result,
1165                                 operation,
1166                                 m_tol);  
1167    return &(m_samples);    return &(m_samples);
1168  }  }
1169    
# Line 1232  DataLazy::resolveNodeReduction(int tid, Line 1197  DataLazy::resolveNodeReduction(int tid,
1197            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1198            {            {
1199              FMin op;              FMin op;
1200              *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());
1201              loffset+=psize;              loffset+=psize;
1202              result++;              result++;
1203            }            }
# Line 1243  DataLazy::resolveNodeReduction(int tid, Line 1208  DataLazy::resolveNodeReduction(int tid,
1208            for (unsigned int z=0;z<ndpps;++z)            for (unsigned int z=0;z<ndpps;++z)
1209            {            {
1210            FMax op;            FMax op;
1211            *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);
1212            loffset+=psize;            loffset+=psize;
1213            result++;            result++;
1214            }            }
# Line 1270  DataLazy::resolveNodeNP1OUT(int tid, int Line 1235  DataLazy::resolveNodeNP1OUT(int tid, int
1235      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");
1236    }    }
1237    size_t subroffset;    size_t subroffset;
1238    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1239    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1240    size_t loop=0;    size_t loop=0;
1241    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;
# Line 1281  DataLazy::resolveNodeNP1OUT(int tid, int Line 1246  DataLazy::resolveNodeNP1OUT(int tid, int
1246      case SYM:      case SYM:
1247          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1248          {          {
1249              DataMaths::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1250              subroffset+=step;              subroffset+=step;
1251              offset+=step;              offset+=step;
1252          }          }
# Line 1289  DataLazy::resolveNodeNP1OUT(int tid, int Line 1254  DataLazy::resolveNodeNP1OUT(int tid, int
1254      case NSYM:      case NSYM:
1255          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1256          {          {
1257              DataMaths::nonsymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::antisymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);
1258              subroffset+=step;              subroffset+=step;
1259              offset+=step;              offset+=step;
1260          }          }
# Line 1316  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1281  DataLazy::resolveNodeNP1OUT_P(int tid, i
1281    }    }
1282    size_t subroffset;    size_t subroffset;
1283    size_t offset;    size_t offset;
1284    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1285    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1286    offset=roffset;    offset=roffset;
1287    size_t loop=0;    size_t loop=0;
# Line 1328  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1293  DataLazy::resolveNodeNP1OUT_P(int tid, i
1293      case TRACE:      case TRACE:
1294          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1295          {          {
1296              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);
1297              subroffset+=instep;              subroffset+=instep;
1298              offset+=outstep;              offset+=outstep;
1299          }          }
# Line 1336  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1301  DataLazy::resolveNodeNP1OUT_P(int tid, i
1301      case TRANS:      case TRANS:
1302          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1303          {          {
1304              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);
1305              subroffset+=instep;              subroffset+=instep;
1306              offset+=outstep;              offset+=outstep;
1307          }          }
# Line 1361  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1326  DataLazy::resolveNodeNP1OUT_2P(int tid,
1326    }    }
1327    size_t subroffset;    size_t subroffset;
1328    size_t offset;    size_t offset;
1329    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1330    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1331    offset=roffset;    offset=roffset;
1332    size_t loop=0;    size_t loop=0;
# Line 1373  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1338  DataLazy::resolveNodeNP1OUT_2P(int tid,
1338      case SWAP:      case SWAP:
1339          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1340          {          {
1341              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);
1342              subroffset+=instep;              subroffset+=instep;
1343              offset+=outstep;              offset+=outstep;
1344          }          }
# Line 1397  DataLazy::resolveNodeCondEval(int tid, i Line 1362  DataLazy::resolveNodeCondEval(int tid, i
1362    }    }
1363    size_t subroffset;    size_t subroffset;
1364    
1365    const ValueType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);
1366    const ValueType* srcres=0;    const RealVectorType* srcres=0;
1367    if ((*maskres)[subroffset]>0)    if ((*maskres)[subroffset]>0)
1368    {    {
1369          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
# Line 1541  LAZYDEBUG(cout << "Resolve binary: " << Line 1506  LAZYDEBUG(cout << "Resolve binary: " <<
1506    
1507    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0
1508          // Get the values of sub-expressions          // Get the values of sub-expressions
1509    const ValueType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);          const RealVectorType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);      
1510    const ValueType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);
1511  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)
1512  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;)
1513  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)  LAZYDEBUG(cout << "chunksize=" << chunksize << endl << "leftstep=" << leftstep << " rightstep=" << rightstep;)
# Line 1560  LAZYDEBUG(cout << "Right res["<< rroffse Line 1525  LAZYDEBUG(cout << "Right res["<< rroffse
1525    switch(m_op)    switch(m_op)
1526    {    {
1527      case ADD:      case ADD:
1528          PROC_OP(NO_ARG,plus<double>());          //PROC_OP(NO_ARG,plus<double>());
1529          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1530                 &(*left)[0],
1531                 &(*right)[0],
1532                 chunksize,
1533                 onumsteps,
1534                 numsteps,
1535                 resultStep,
1536                 leftstep,
1537                 rightstep,
1538                 oleftstep,
1539                 orightstep,
1540                 lroffset,
1541                 rroffset,
1542                 escript::ESFunction::PLUSF);  
1543          break;          break;
1544      case SUB:      case SUB:
1545          PROC_OP(NO_ARG,minus<double>());        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1546                 &(*left)[0],
1547                 &(*right)[0],
1548                 chunksize,
1549                 onumsteps,
1550                 numsteps,
1551                 resultStep,
1552                 leftstep,
1553                 rightstep,
1554                 oleftstep,
1555                 orightstep,
1556                 lroffset,
1557                 rroffset,
1558                 escript::ESFunction::MINUSF);        
1559            //PROC_OP(NO_ARG,minus<double>());
1560          break;          break;
1561      case MUL:      case MUL:
1562          PROC_OP(NO_ARG,multiplies<double>());          //PROC_OP(NO_ARG,multiplies<double>());
1563          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1564                 &(*left)[0],
1565                 &(*right)[0],
1566                 chunksize,
1567                 onumsteps,
1568                 numsteps,
1569                 resultStep,
1570                 leftstep,
1571                 rightstep,
1572                 oleftstep,
1573                 orightstep,
1574                 lroffset,
1575                 rroffset,
1576                 escript::ESFunction::MULTIPLIESF);      
1577          break;          break;
1578      case DIV:      case DIV:
1579          PROC_OP(NO_ARG,divides<double>());          //PROC_OP(NO_ARG,divides<double>());
1580          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1581                 &(*left)[0],
1582                 &(*right)[0],
1583                 chunksize,
1584                 onumsteps,
1585                 numsteps,
1586                 resultStep,
1587                 leftstep,
1588                 rightstep,
1589                 oleftstep,
1590                 orightstep,
1591                 lroffset,
1592                 rroffset,
1593                 escript::ESFunction::DIVIDESF);          
1594          break;          break;
1595      case POW:      case POW:
1596         PROC_OP(double (double,double),::pow);         //PROC_OP(double (double,double),::pow);
1597          escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1598                 &(*left)[0],
1599                 &(*right)[0],
1600                 chunksize,
1601                 onumsteps,
1602                 numsteps,
1603                 resultStep,
1604                 leftstep,
1605                 rightstep,
1606                 oleftstep,
1607                 orightstep,
1608                 lroffset,
1609                 rroffset,
1610                 escript::ESFunction::POWF);          
1611          break;          break;
1612      default:      default:
1613          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 1602  LAZYDEBUG(cout << "Resolve TensorProduct Line 1637  LAZYDEBUG(cout << "Resolve TensorProduct
1637    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1638    size_t offset=roffset;    size_t offset=roffset;
1639    
1640    const ValueType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);    const RealVectorType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);
1641    
1642    const ValueType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);
1643    
1644  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;
1645  cout << getNoValues() << endl;)  cout << getNoValues() << endl;)
# Line 1741  DataLazy::resolveGroupWorker(std::vector Line 1776  DataLazy::resolveGroupWorker(std::vector
1776    {             // 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
1777                  // all the other functionspaces match.                  // all the other functionspaces match.
1778          vector<DataExpanded*> dep;          vector<DataExpanded*> dep;
1779          vector<ValueType*> vecs;          vector<RealVectorType*> vecs;
1780          for (int i=0;i<work.size();++i)          for (int i=0;i<work.size();++i)
1781          {          {
1782                  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())));
1783                  vecs.push_back(&(dep[i]->getVectorRW()));                  vecs.push_back(&(dep[i]->getVectorRW()));
1784          }          }
1785          int totalsamples=work[0]->getNumSamples();          int totalsamples=work[0]->getNumSamples();
1786          const ValueType* res=0; // Storage for answer          const RealVectorType* res=0; // Storage for answer
1787          int sample;          int sample;
1788          #pragma omp parallel private(sample, res)          #pragma omp parallel private(sample, res)
1789          {          {
# Line 1773  DataLazy::resolveGroupWorker(std::vector Line 1808  DataLazy::resolveGroupWorker(std::vector
1808          // Now we need to load the new results as identity ops into the lazy nodes          // Now we need to load the new results as identity ops into the lazy nodes
1809          for (int i=work.size()-1;i>=0;--i)          for (int i=work.size()-1;i>=0;--i)
1810          {          {
1811              work[i]->makeIdentity(boost::dynamic_pointer_cast<DataReady>(dep[i]->getPtr()));              work[i]->makeIdentity(REFCOUNTNS::dynamic_pointer_cast<DataReady>(dep[i]->getPtr()));
1812          }          }
1813    }    }
1814    else  // functionspaces do not match    else  // functionspaces do not match
# Line 1800  DataLazy::resolveNodeWorker() Line 1835  DataLazy::resolveNodeWorker()
1835      return m_id;      return m_id;
1836    }    }
1837          // 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'
1838    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  RealVectorType(getNoValues()));
1839    ValueType& resvec=result->getVectorRW();    RealVectorType& resvec=result->getVectorRW();
1840    DataReady_ptr resptr=DataReady_ptr(result);    DataReady_ptr resptr=DataReady_ptr(result);
1841    
1842    int sample;    int sample;
1843    int totalsamples=getNumSamples();    int totalsamples=getNumSamples();
1844    const ValueType* res=0;       // Storage for answer    const RealVectorType* res=0;       // Storage for answer
1845  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)
1846    #pragma omp parallel private(sample,res)    #pragma omp parallel private(sample,res)
1847    {    {
# Line 2111  DataLazy::actsExpanded() const Line 2146  DataLazy::actsExpanded() const
2146          return (m_readytype=='E');          return (m_readytype=='E');
2147  }  }
2148    
2149  }       // end namespace  } // end namespace
2150    

Legend:
Removed from v.5972  
changed lines
  Added in v.6125

  ViewVC Help
Powered by ViewVC 1.1.26