/[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 6066 by jfenwick, Tue Mar 15 06:42:55 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 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 "DataMaths.h"  #include "DataVectorOps.h"
24    
25  #ifdef USE_NETCDF  #ifdef USE_NETCDF
26  #include <netcdfcpp.h>  #include <netcdfcpp.h>
# Line 156  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 174  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 479  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 944  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 964  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 1150  DataLazy::resolveNodeUnary(int tid, int Line 1155  DataLazy::resolveNodeUnary(int tid, int
1155      break;      break;
1156      case EZ:      case EZ:
1157          operation=EQZEROF;          operation=EQZEROF;
 cerr << "Trying to evaluate " << m_tol << endl;  
       
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)+".");
# Line 1194  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 1205  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 1243  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 1251  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 1290  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 1298  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 1335  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 1523  LAZYDEBUG(cout << "Right res["<< rroffse Line 1526  LAZYDEBUG(cout << "Right res["<< rroffse
1526    {    {
1527      case ADD:      case ADD:
1528          //PROC_OP(NO_ARG,plus<double>());          //PROC_OP(NO_ARG,plus<double>());
1529        DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1530               &(*left)[0],               &(*left)[0],
1531               &(*right)[0],               &(*right)[0],
1532               chunksize,               chunksize,
# Line 1539  LAZYDEBUG(cout << "Right res["<< rroffse Line 1542  LAZYDEBUG(cout << "Right res["<< rroffse
1542               escript::ESFunction::PLUSF);                 escript::ESFunction::PLUSF);  
1543          break;          break;
1544      case SUB:      case SUB:
1545        DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1546               &(*left)[0],               &(*left)[0],
1547               &(*right)[0],               &(*right)[0],
1548               chunksize,               chunksize,
# Line 1557  LAZYDEBUG(cout << "Right res["<< rroffse Line 1560  LAZYDEBUG(cout << "Right res["<< rroffse
1560          break;          break;
1561      case MUL:      case MUL:
1562          //PROC_OP(NO_ARG,multiplies<double>());          //PROC_OP(NO_ARG,multiplies<double>());
1563        DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1564               &(*left)[0],               &(*left)[0],
1565               &(*right)[0],               &(*right)[0],
1566               chunksize,               chunksize,
# Line 1574  LAZYDEBUG(cout << "Right res["<< rroffse Line 1577  LAZYDEBUG(cout << "Right res["<< rroffse
1577          break;          break;
1578      case DIV:      case DIV:
1579          //PROC_OP(NO_ARG,divides<double>());          //PROC_OP(NO_ARG,divides<double>());
1580        DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1581               &(*left)[0],               &(*left)[0],
1582               &(*right)[0],               &(*right)[0],
1583               chunksize,               chunksize,
# Line 1591  LAZYDEBUG(cout << "Right res["<< rroffse Line 1594  LAZYDEBUG(cout << "Right res["<< rroffse
1594          break;          break;
1595      case POW:      case POW:
1596         //PROC_OP(double (double,double),::pow);         //PROC_OP(double (double,double),::pow);
1597        DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,        escript::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1598               &(*left)[0],               &(*left)[0],
1599               &(*right)[0],               &(*right)[0],
1600               chunksize,               chunksize,

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

  ViewVC Help
Powered by ViewVC 1.1.26