/[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

trunk/escript/src/DataLazy.cpp revision 4264 by jfenwick, Thu Feb 28 11:32:57 2013 UTC trunk/escriptcore/src/DataLazy.cpp revision 4621 by jfenwick, Thu Jan 16 10:07:44 2014 UTC
# Line 61  A special operation, IDENTITY, stores an Line 61  A special operation, IDENTITY, stores an
61  This means that all "internal" nodes in the structure are instances of DataLazy.  This means that all "internal" nodes in the structure are instances of DataLazy.
62    
63  Each operation has a string representation as well as an opgroup - eg G_IDENTITY, G_BINARY, ...  Each operation has a string representation as well as an opgroup - eg G_IDENTITY, G_BINARY, ...
64  Note that IDENITY is not considered a unary operation.  Note that IDENTITY is not considered a unary operation.
65    
66  I am avoiding calling the structure formed a tree because it is not guaranteed to be one (eg c=a+a).  I am avoiding calling the structure formed a tree because it is not guaranteed to be one (eg c=a+a).
67  It must however form a DAG (directed acyclic graph).  It must however form a DAG (directed acyclic graph).
# Line 70  I will refer to individual DataLazy obje Line 70  I will refer to individual DataLazy obje
70  Each node also stores:  Each node also stores:
71  - m_readytype \in {'E','T','C','?'} ~ indicates what sort of DataReady would be produced if the expression was  - m_readytype \in {'E','T','C','?'} ~ indicates what sort of DataReady would be produced if the expression was
72      evaluated.      evaluated.
73  - m_buffsrequired ~ the larged number of samples which would need to be kept simultaneously in order to  - m_buffsrequired ~ the large number of samples which would need to be kept simultaneously in order to
74      evaluate the expression.      evaluate the expression.
75  - m_samplesize ~ the number of doubles stored in a sample.  - m_samplesize ~ the number of doubles stored in a sample.
76    
# Line 822  DataLazy::~DataLazy() Line 822  DataLazy::~DataLazy()
822    For reasons of efficiency do not call this method on DataExpanded nodes.    For reasons of efficiency do not call this method on DataExpanded nodes.
823  */  */
824  DataReady_ptr  DataReady_ptr
825  DataLazy::collapseToReady()  DataLazy::collapseToReady() const
826  {  {
827    if (m_readytype=='E')    if (m_readytype=='E')
828    { // this is more an efficiency concern than anything else    { // this is more an efficiency concern than anything else
# Line 977  DataLazy::collapseToReady() Line 977  DataLazy::collapseToReady()
977     the purpose of using DataLazy in the first place).     the purpose of using DataLazy in the first place).
978  */  */
979  void  void
980  DataLazy::collapse()  DataLazy::collapse() const
981  {  {
982    if (m_op==IDENTITY)    if (m_op==IDENTITY)
983    {    {
# Line 1016  LAZYDEBUG(cout << " result=      " << re Line 1016  LAZYDEBUG(cout << " result=      " << re
1016  // The result will be stored in m_samples  // The result will be stored in m_samples
1017  // 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
1018  const DataTypes::ValueType*  const DataTypes::ValueType*
1019  DataLazy::resolveNodeSample(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeSample(int tid, int sampleNo, size_t& roffset) const
1020  {  {
1021  LAZYDEBUG(cout << "Resolve sample " << toString() << endl;)  LAZYDEBUG(cout << "Resolve sample " << toString() << endl;)
1022      // collapse so we have a 'E' node or an IDENTITY for some other type      // collapse so we have a 'E' node or an IDENTITY for some other type
# Line 1065  if (&x<stackend[omp_get_thread_num()]) Line 1065  if (&x<stackend[omp_get_thread_num()])
1065  }  }
1066    
1067  const DataTypes::ValueType*  const DataTypes::ValueType*
1068  DataLazy::resolveNodeUnary(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeUnary(int tid, int sampleNo, size_t& roffset) const
1069  {  {
1070      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1071      // since we only have one argument we don't need to think about only      // since we only have one argument we don't need to think about only
# Line 1197  DataLazy::resolveNodeUnary(int tid, int Line 1197  DataLazy::resolveNodeUnary(int tid, int
1197    
1198    
1199  const DataTypes::ValueType*  const DataTypes::ValueType*
1200  DataLazy::resolveNodeReduction(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeReduction(int tid, int sampleNo, size_t& roffset) const
1201  {  {
1202      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1203      // since we only have one argument we don't need to think about only      // since we only have one argument we don't need to think about only
# Line 1249  DataLazy::resolveNodeReduction(int tid, Line 1249  DataLazy::resolveNodeReduction(int tid,
1249  }  }
1250    
1251  const DataTypes::ValueType*  const DataTypes::ValueType*
1252  DataLazy::resolveNodeNP1OUT(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT(int tid, int sampleNo, size_t& roffset) const
1253  {  {
1254      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1255      // since we only have one argument we don't need to think about only      // since we only have one argument we don't need to think about only
# Line 1294  DataLazy::resolveNodeNP1OUT(int tid, int Line 1294  DataLazy::resolveNodeNP1OUT(int tid, int
1294  }  }
1295    
1296  const DataTypes::ValueType*  const DataTypes::ValueType*
1297  DataLazy::resolveNodeNP1OUT_P(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT_P(int tid, int sampleNo, size_t& roffset) const
1298  {  {
1299      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1300      // since we only have one argument we don't need to think about only      // since we only have one argument we don't need to think about only
# Line 1342  DataLazy::resolveNodeNP1OUT_P(int tid, i Line 1342  DataLazy::resolveNodeNP1OUT_P(int tid, i
1342    
1343    
1344  const DataTypes::ValueType*  const DataTypes::ValueType*
1345  DataLazy::resolveNodeNP1OUT_2P(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT_2P(int tid, int sampleNo, size_t& roffset) const
1346  {  {
1347    if (m_readytype!='E')    if (m_readytype!='E')
1348    {    {
# Line 1378  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1378  DataLazy::resolveNodeNP1OUT_2P(int tid,
1378  }  }
1379    
1380  const DataTypes::ValueType*  const DataTypes::ValueType*
1381  DataLazy::resolveNodeCondEval(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeCondEval(int tid, int sampleNo, size_t& roffset) const
1382  {  {
1383    if (m_readytype!='E')    if (m_readytype!='E')
1384    {    {
# Line 1422  DataLazy::resolveNodeCondEval(int tid, i Line 1422  DataLazy::resolveNodeCondEval(int tid, i
1422  // For example, 2+Vector.  // For example, 2+Vector.
1423  // In this case each double within the point is treated individually  // In this case each double within the point is treated individually
1424  const DataTypes::ValueType*  const DataTypes::ValueType*
1425  DataLazy::resolveNodeBinary(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeBinary(int tid, int sampleNo, size_t& roffset) const
1426  {  {
1427  LAZYDEBUG(cout << "Resolve binary: " << toString() << endl;)  LAZYDEBUG(cout << "Resolve binary: " << toString() << endl;)
1428    
# Line 1549  LAZYDEBUG(cout << "Right res["<< rroffse Line 1549  LAZYDEBUG(cout << "Right res["<< rroffse
1549    
1550    
1551    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1552    double* resultp=&(m_samples[roffset]);        // results are stored at the vector offset we recieved    double* resultp=&(m_samples[roffset]);        // results are stored at the vector offset we received
1553    switch(m_op)    switch(m_op)
1554    {    {
1555      case ADD:      case ADD:
# Line 1579  LAZYDEBUG(cout << "Result res[" << roffs Line 1579  LAZYDEBUG(cout << "Result res[" << roffs
1579  // have already been collapsed to IDENTITY. So we must have at least one expanded child.  // have already been collapsed to IDENTITY. So we must have at least one expanded child.
1580  // unlike the other resolve helpers, we must treat these datapoints separately.  // unlike the other resolve helpers, we must treat these datapoints separately.
1581  const DataTypes::ValueType*  const DataTypes::ValueType*
1582  DataLazy::resolveNodeTProd(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeTProd(int tid, int sampleNo, size_t& roffset) const
1583  {  {
1584  LAZYDEBUG(cout << "Resolve TensorProduct: " << toString() << endl;)  LAZYDEBUG(cout << "Resolve TensorProduct: " << toString() << endl;)
1585    
# Line 1611  LAZYDEBUG(cout << "m_samplesize=" << m_s Line 1611  LAZYDEBUG(cout << "m_samplesize=" << m_s
1611  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)
1612  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)
1613    
1614    double* resultp=&(m_samples[offset]);     // results are stored at the vector offset we recieved    double* resultp=&(m_samples[offset]);     // results are stored at the vector offset we received
1615    switch(m_op)    switch(m_op)
1616    {    {
1617      case PROD:      case PROD:
# Line 1638  LAZYDEBUG(cout << DataTypes::pointToStri Line 1638  LAZYDEBUG(cout << DataTypes::pointToStri
1638    
1639    
1640  const DataTypes::ValueType*  const DataTypes::ValueType*
1641  DataLazy::resolveSample(int sampleNo, size_t& roffset)  DataLazy::resolveSample(int sampleNo, size_t& roffset) const
1642  {  {
1643  #ifdef _OPENMP  #ifdef _OPENMP
1644      int tid=omp_get_thread_num();      int tid=omp_get_thread_num();

Legend:
Removed from v.4264  
changed lines
  Added in v.4621

  ViewVC Help
Powered by ViewVC 1.1.26