/[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 6511 by jfenwick, Fri Mar 3 01:41:39 2017 UTC revision 6512 by jfenwick, Fri Mar 3 02:01:57 2017 UTC
# Line 389  void DataLazy::LazyNodeSetup() Line 389  void DataLazy::LazyNodeSetup()
389  {  {
390  #ifdef _OPENMP  #ifdef _OPENMP
391      int numthreads=omp_get_max_threads();      int numthreads=omp_get_max_threads();
392      m_samples.resize(numthreads*m_samplesize);      m_samples_r.resize(numthreads*m_samplesize);
393      m_sampleids=new int[numthreads];      m_sampleids=new int[numthreads];
394      for (int i=0;i<numthreads;++i)      for (int i=0;i<numthreads;++i)
395      {      {
396          m_sampleids[i]=-1;            m_sampleids[i]=-1;  
397      }      }
398  #else  #else
399      m_samples.resize(m_samplesize);      if (m_iscompl)
400        {
401            m_samples_c.resize(m_samplesize);
402        }
403        else
404        {
405            m_samples_r.resize(m_samplesize);
406        }
407      m_sampleids=new int[1];      m_sampleids=new int[1];
408      m_sampleids[0]=-1;      m_sampleids[0]=-1;
409  #endif  // _OPENMP  #endif  // _OPENMP
# Line 407  void DataLazy::LazyNodeSetup() Line 414  void DataLazy::LazyNodeSetup()
414  DataLazy::DataLazy(DataAbstract_ptr p)  DataLazy::DataLazy(DataAbstract_ptr p)
415          : parent(p->getFunctionSpace(),p->getShape())          : parent(p->getFunctionSpace(),p->getShape())
416          ,m_sampleids(0),          ,m_sampleids(0),
417          m_samples(1)          m_samples_r(1)
418  {  {
419     if (p->isLazy())     if (p->isLazy())
420     {     {
# Line 963  if (&x<stackend[omp_get_thread_num()]) Line 970  if (&x<stackend[omp_get_thread_num()])
970    if (m_sampleids[tid]==sampleNo)    if (m_sampleids[tid]==sampleNo)
971    {    {
972          roffset=tid*m_samplesize;          roffset=tid*m_samplesize;
973          return &(m_samples);            // sample is already resolved          return &(m_samples_r);            // sample is already resolved
974    }    }
975    m_sampleids[tid]=sampleNo;    m_sampleids[tid]=sampleNo;
976    
# Line 1001  DataLazy::resolveNodeUnary(int tid, int Line 1008  DataLazy::resolveNodeUnary(int tid, int
1008    const DataTypes::RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, roffset);    const DataTypes::RealVectorType* leftres=m_left->resolveNodeSample(tid, sampleNo, roffset);
1009    const double* left=&((*leftres)[roffset]);    const double* left=&((*leftres)[roffset]);
1010    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1011    double* result=&(m_samples[roffset]);    double* result=&(m_samples_r[roffset]);
1012    if (m_op==POS)    if (m_op==POS)
1013    {    {
1014      // this should be prevented earlier      // this should be prevented earlier
# Line 1013  DataLazy::resolveNodeUnary(int tid, int Line 1020  DataLazy::resolveNodeUnary(int tid, int
1020                               result,                               result,
1021                               m_op,                               m_op,
1022                               m_tol);                                 m_tol);  
1023    return &(m_samples);    return &(m_samples_r);
1024  }  }
1025    
1026    
# Line 1038  DataLazy::resolveNodeReduction(int tid, Line 1045  DataLazy::resolveNodeReduction(int tid,
1045    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1046    unsigned int ndpps=getNumDPPSample();    unsigned int ndpps=getNumDPPSample();
1047    unsigned int psize=DataTypes::noValues(m_left->getShape());    unsigned int psize=DataTypes::noValues(m_left->getShape());
1048    double* result=&(m_samples[roffset]);    double* result=&(m_samples_r[roffset]);
1049    switch (m_op)    switch (m_op)
1050    {    {
1051      case MINVAL:      case MINVAL:
# Line 1066  DataLazy::resolveNodeReduction(int tid, Line 1073  DataLazy::resolveNodeReduction(int tid,
1073      default:      default:
1074          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveUnary can not resolve operator "+opToString(m_op)+".");
1075    }    }
1076    return &(m_samples);    return &(m_samples_r);
1077  }  }
1078    
1079  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1095  DataLazy::resolveNodeNP1OUT(int tid, int Line 1102  DataLazy::resolveNodeNP1OUT(int tid, int
1102      case SYM:      case SYM:
1103          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1104          {          {
1105              escript::symmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::symmetric(*leftres,m_left->getShape(),subroffset, m_samples_r, getShape(), offset);
1106              subroffset+=step;              subroffset+=step;
1107              offset+=step;              offset+=step;
1108          }          }
# Line 1103  DataLazy::resolveNodeNP1OUT(int tid, int Line 1110  DataLazy::resolveNodeNP1OUT(int tid, int
1110      case NSYM:      case NSYM:
1111          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1112          {          {
1113              escript::antisymmetric(*leftres,m_left->getShape(),subroffset, m_samples, getShape(), offset);              escript::antisymmetric(*leftres,m_left->getShape(),subroffset, m_samples_r, getShape(), offset);
1114              subroffset+=step;              subroffset+=step;
1115              offset+=step;              offset+=step;
1116          }          }
# Line 1111  DataLazy::resolveNodeNP1OUT(int tid, int Line 1118  DataLazy::resolveNodeNP1OUT(int tid, int
1118      default:      default:
1119          throw DataException("Programmer error - resolveNP1OUT can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveNP1OUT can not resolve operator "+opToString(m_op)+".");
1120    }    }
1121    return &m_samples;    return &m_samples_r;
1122  }  }
1123    
1124  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1142  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1149  DataLazy::resolveNodeNP1OUT_P(int tid, i
1149      case TRACE:      case TRACE:
1150          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1151          {          {
1152              escript::trace(*leftres,m_left->getShape(),subroffset, m_samples ,getShape(),offset,m_axis_offset);              escript::trace(*leftres,m_left->getShape(),subroffset, m_samples_r ,getShape(),offset,m_axis_offset);
1153              subroffset+=instep;              subroffset+=instep;
1154              offset+=outstep;              offset+=outstep;
1155          }          }
# Line 1150  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1157  DataLazy::resolveNodeNP1OUT_P(int tid, i
1157      case TRANS:      case TRANS:
1158          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1159          {          {
1160              escript::transpose(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset,m_axis_offset);              escript::transpose(*leftres,m_left->getShape(),subroffset, m_samples_r, getShape(),offset,m_axis_offset);
1161              subroffset+=instep;              subroffset+=instep;
1162              offset+=outstep;              offset+=outstep;
1163          }          }
# Line 1158  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1165  DataLazy::resolveNodeNP1OUT_P(int tid, i
1165      default:      default:
1166          throw DataException("Programmer error - resolveNP1OUTP can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveNP1OUTP can not resolve operator "+opToString(m_op)+".");
1167    }    }
1168    return &m_samples;    return &m_samples_r;
1169  }  }
1170    
1171    
# Line 1187  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1194  DataLazy::resolveNodeNP1OUT_2P(int tid,
1194      case SWAP:      case SWAP:
1195          for (loop=0;loop<numsteps;++loop)          for (loop=0;loop<numsteps;++loop)
1196          {          {
1197              escript::swapaxes(*leftres,m_left->getShape(),subroffset, m_samples, getShape(),offset, m_axis_offset, m_transpose);              escript::swapaxes(*leftres,m_left->getShape(),subroffset, m_samples_r, getShape(),offset, m_axis_offset, m_transpose);
1198              subroffset+=instep;              subroffset+=instep;
1199              offset+=outstep;              offset+=outstep;
1200          }          }
# Line 1195  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1202  DataLazy::resolveNodeNP1OUT_2P(int tid,
1202      default:      default:
1203          throw DataException("Programmer error - resolveNodeNP1OUT2P can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveNodeNP1OUT2P can not resolve operator "+opToString(m_op)+".");
1204    }    }
1205    return &m_samples;    return &m_samples_r;
1206  }  }
1207    
1208  const DataTypes::RealVectorType*  const DataTypes::RealVectorType*
# Line 1227  DataLazy::resolveNodeCondEval(int tid, i Line 1234  DataLazy::resolveNodeCondEval(int tid, i
1234    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1235    for (int i=0;i<m_samplesize;++i)    for (int i=0;i<m_samplesize;++i)
1236    {    {
1237          m_samples[roffset+i]=(*srcres)[subroffset+i];            m_samples_r[roffset+i]=(*srcres)[subroffset+i];  
1238    }    }
1239    
1240    return &m_samples;    return &m_samples_r;
1241  }  }
1242    
1243  // This method assumes that any subexpressions which evaluate to Constant or Tagged Data  // This method assumes that any subexpressions which evaluate to Constant or Tagged Data
# Line 1370  LAZYDEBUG(cout << "Right res["<< rroffse Line 1377  LAZYDEBUG(cout << "Right res["<< rroffse
1377    
1378    
1379    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1380    double* resultp=&(m_samples[roffset]);                // results are stored at the vector offset we received    double* resultp=&(m_samples_r[roffset]);                // results are stored at the vector offset we received
1381    switch(m_op)    switch(m_op)
1382    {    {
1383      case ADD:      case ADD:
# Line 1461  LAZYDEBUG(cout << "Right res["<< rroffse Line 1468  LAZYDEBUG(cout << "Right res["<< rroffse
1468      default:      default:
1469          throw DataException("Programmer error - resolveBinary can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveBinary can not resolve operator "+opToString(m_op)+".");
1470    }    }
1471  LAZYDEBUG(cout << "Result res[" << roffset<< "]" << m_samples[roffset] << endl;)  LAZYDEBUG(cout << "Result res[" << roffset<< "]" << m_samples_r[roffset] << endl;)
1472    return &m_samples;    return &m_samples_r;
1473  }  }
1474    
1475    
# Line 1502  LAZYDEBUG(cout << "m_samplesize=" << m_s Line 1509  LAZYDEBUG(cout << "m_samplesize=" << m_s
1509  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)
1510  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)
1511    
1512    double* resultp=&(m_samples[offset]);         // results are stored at the vector offset we received    double* resultp=&(m_samples_r[offset]);         // results are stored at the vector offset we received
1513    switch(m_op)    switch(m_op)
1514    {    {
1515      case PROD:      case PROD:
# Line 1524  LAZYDEBUG(cout << DataTypes::pointToStri Line 1531  LAZYDEBUG(cout << DataTypes::pointToStri
1531          throw DataException("Programmer error - resolveTProduct can not resolve operator "+opToString(m_op)+".");          throw DataException("Programmer error - resolveTProduct can not resolve operator "+opToString(m_op)+".");
1532    }    }
1533    roffset=offset;    roffset=offset;
1534    return &m_samples;    return &m_samples_r;
1535  }  }
1536    
1537    
# Line 1580  void DataLazy::makeIdentity(const DataRe Line 1587  void DataLazy::makeIdentity(const DataRe
1587     m_samplesize=p->getNumDPPSample()*p->getNoValues();     m_samplesize=p->getNumDPPSample()*p->getNoValues();
1588     m_left.reset();     m_left.reset();
1589     m_right.reset();     m_right.reset();
1590       m_iscompl=p->isComplex();
1591  }  }
1592    
1593    

Legend:
Removed from v.6511  
changed lines
  Added in v.6512

  ViewVC Help
Powered by ViewVC 1.1.26