/[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 6042 by jfenwick, Wed Mar 9 04:30:36 2016 UTC
# 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"
# Line 24  Line 21 
21  #include "FunctionSpace.h"  #include "FunctionSpace.h"
22  #include "UnaryFuncs.h"    // for escript::fsign  #include "UnaryFuncs.h"    // for escript::fsign
23  #include "Utils.h"  #include "Utils.h"
24    #include "DataMaths.h"
25    
26  #ifdef USE_NETCDF  #ifdef USE_NETCDF
27  #include <netcdfcpp.h>  #include <netcdfcpp.h>
# Line 1028  LAZYDEBUG(cout << "Resolve sample " << t Line 1026  LAZYDEBUG(cout << "Resolve sample " << t
1026    }    }
1027    if (m_op==IDENTITY)      if (m_op==IDENTITY)  
1028    {    {
1029      const ValueType& vec=m_id->getVectorRO();      const RealVectorType& vec=m_id->getVectorRO();
1030      roffset=m_id->getPointOffset(sampleNo, 0);      roffset=m_id->getPointOffset(sampleNo, 0);
1031  #ifdef LAZY_STACK_PROF  #ifdef LAZY_STACK_PROF
1032  int x;  int x;
# Line 1265  DataLazy::resolveNodeNP1OUT(int tid, int Line 1263  DataLazy::resolveNodeNP1OUT(int tid, int
1263      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");      throw DataException("Programmer error - resolveNodeNP1OUT should not be called on identity nodes.");
1264    }    }
1265    size_t subroffset;    size_t subroffset;
1266    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1267    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1268    size_t loop=0;    size_t loop=0;
1269    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;    size_t numsteps=(m_readytype=='E')?getNumDPPSample():1;
# Line 1311  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1309  DataLazy::resolveNodeNP1OUT_P(int tid, i
1309    }    }
1310    size_t subroffset;    size_t subroffset;
1311    size_t offset;    size_t offset;
1312    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1313    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1314    offset=roffset;    offset=roffset;
1315    size_t loop=0;    size_t loop=0;
# Line 1356  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1354  DataLazy::resolveNodeNP1OUT_2P(int tid,
1354    }    }
1355    size_t subroffset;    size_t subroffset;
1356    size_t offset;    size_t offset;
1357    const ValueType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
1358    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1359    offset=roffset;    offset=roffset;
1360    size_t loop=0;    size_t loop=0;
# Line 1392  DataLazy::resolveNodeCondEval(int tid, i Line 1390  DataLazy::resolveNodeCondEval(int tid, i
1390    }    }
1391    size_t subroffset;    size_t subroffset;
1392    
1393    const ValueType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);    const RealVectorType* maskres=m_mask->resolveNodeSample(tid, sampleNo, subroffset);
1394    const ValueType* srcres=0;    const RealVectorType* srcres=0;
1395    if ((*maskres)[subroffset]>0)    if ((*maskres)[subroffset]>0)
1396    {    {
1397          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);          srcres=m_left->resolveNodeSample(tid, sampleNo, subroffset);
# Line 1536  LAZYDEBUG(cout << "Resolve binary: " << Line 1534  LAZYDEBUG(cout << "Resolve binary: " <<
1534    
1535    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0    int resultStep=max(leftstep,rightstep);       // only one (at most) should be !=0
1536          // Get the values of sub-expressions          // Get the values of sub-expressions
1537    const ValueType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);          const RealVectorType* left=m_left->resolveNodeSample(tid,sampleNo,lroffset);      
1538    const ValueType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid,sampleNo,rroffset);
1539  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)  LAZYDEBUG(cout << "Post sub calls in " << toString() << endl;)
1540  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;)
1541  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 1553  LAZYDEBUG(cout << "Right res["<< rroffse
1553    switch(m_op)    switch(m_op)
1554    {    {
1555      case ADD:      case ADD:
1556          PROC_OP(NO_ARG,plus<double>());          //PROC_OP(NO_ARG,plus<double>());
1557          DataMaths::binaryOpVectorLazyHelper<real_t, real_t, real_t>(resultp,
1558                 &(*left)[0],
1559                 &(*right)[0],
1560                 chunksize,
1561                 onumsteps,
1562                 numsteps,
1563                 resultStep,
1564                 leftstep,
1565                 rightstep,
1566                 oleftstep,
1567                 orightstep,
1568                 escript::ESFunction::PLUSF);  
1569          break;          break;
1570      case SUB:      case SUB:
1571          PROC_OP(NO_ARG,minus<double>());          PROC_OP(NO_ARG,minus<double>());
# Line 1597  LAZYDEBUG(cout << "Resolve TensorProduct Line 1607  LAZYDEBUG(cout << "Resolve TensorProduct
1607    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1608    size_t offset=roffset;    size_t offset=roffset;
1609    
1610    const ValueType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);    const RealVectorType* left=m_left->resolveNodeSample(tid, sampleNo, lroffset);
1611    
1612    const ValueType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);    const RealVectorType* right=m_right->resolveNodeSample(tid, sampleNo, rroffset);
1613    
1614  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;
1615  cout << getNoValues() << endl;)  cout << getNoValues() << endl;)
# Line 1736  DataLazy::resolveGroupWorker(std::vector Line 1746  DataLazy::resolveGroupWorker(std::vector
1746    {             // 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
1747                  // all the other functionspaces match.                  // all the other functionspaces match.
1748          vector<DataExpanded*> dep;          vector<DataExpanded*> dep;
1749          vector<ValueType*> vecs;          vector<RealVectorType*> vecs;
1750          for (int i=0;i<work.size();++i)          for (int i=0;i<work.size();++i)
1751          {          {
1752                  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())));
1753                  vecs.push_back(&(dep[i]->getVectorRW()));                  vecs.push_back(&(dep[i]->getVectorRW()));
1754          }          }
1755          int totalsamples=work[0]->getNumSamples();          int totalsamples=work[0]->getNumSamples();
1756          const ValueType* res=0; // Storage for answer          const RealVectorType* res=0; // Storage for answer
1757          int sample;          int sample;
1758          #pragma omp parallel private(sample, res)          #pragma omp parallel private(sample, res)
1759          {          {
# Line 1795  DataLazy::resolveNodeWorker() Line 1805  DataLazy::resolveNodeWorker()
1805      return m_id;      return m_id;
1806    }    }
1807          // 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'
1808    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  RealVectorType(getNoValues()));
1809    ValueType& resvec=result->getVectorRW();    RealVectorType& resvec=result->getVectorRW();
1810    DataReady_ptr resptr=DataReady_ptr(result);    DataReady_ptr resptr=DataReady_ptr(result);
1811    
1812    int sample;    int sample;
1813    int totalsamples=getNumSamples();    int totalsamples=getNumSamples();
1814    const ValueType* res=0;       // Storage for answer    const RealVectorType* res=0;       // Storage for answer
1815  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)  LAZYDEBUG(cout << "Total number of samples=" <<totalsamples << endl;)
1816    #pragma omp parallel private(sample,res)    #pragma omp parallel private(sample,res)
1817    {    {

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

  ViewVC Help
Powered by ViewVC 1.1.26