/[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 5448 by jfenwick, Fri Feb 6 05:31:37 2015 UTC
# Line 1  Line 1 
1    
2  /*****************************************************************************  /*****************************************************************************
3  *  *
4  * Copyright (c) 2003-2013 by University of Queensland  * Copyright (c) 2003-2015 by University of Queensland
5  * http://www.uq.edu.au  * http://www.uq.edu.au
6  *  *
7  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
# Line 9  Line 9 
9  * http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
10  *  *
11  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12  * Development since 2012 by School of Earth Sciences  * Development 2012-2013 by School of Earth Sciences
13    * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
# Line 61  A special operation, IDENTITY, stores an Line 62  A special operation, IDENTITY, stores an
62  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.
63    
64  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, ...
65  Note that IDENITY is not considered a unary operation.  Note that IDENTITY is not considered a unary operation.
66    
67  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).
68  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 71  I will refer to individual DataLazy obje
71  Each node also stores:  Each node also stores:
72  - 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
73      evaluated.      evaluated.
74  - 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
75      evaluate the expression.      evaluate the expression.
76  - m_samplesize ~ the number of doubles stored in a sample.  - m_samplesize ~ the number of doubles stored in a sample.
77    
# Line 822  DataLazy::~DataLazy() Line 823  DataLazy::~DataLazy()
823    For reasons of efficiency do not call this method on DataExpanded nodes.    For reasons of efficiency do not call this method on DataExpanded nodes.
824  */  */
825  DataReady_ptr  DataReady_ptr
826  DataLazy::collapseToReady()  DataLazy::collapseToReady() const
827  {  {
828    if (m_readytype=='E')    if (m_readytype=='E')
829    { // this is more an efficiency concern than anything else    { // this is more an efficiency concern than anything else
# Line 977  DataLazy::collapseToReady() Line 978  DataLazy::collapseToReady()
978     the purpose of using DataLazy in the first place).     the purpose of using DataLazy in the first place).
979  */  */
980  void  void
981  DataLazy::collapse()  DataLazy::collapse() const
982  {  {
983    if (m_op==IDENTITY)    if (m_op==IDENTITY)
984    {    {
# Line 1016  LAZYDEBUG(cout << " result=      " << re Line 1017  LAZYDEBUG(cout << " result=      " << re
1017  // The result will be stored in m_samples  // The result will be stored in m_samples
1018  // 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
1019  const DataTypes::ValueType*  const DataTypes::ValueType*
1020  DataLazy::resolveNodeSample(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeSample(int tid, int sampleNo, size_t& roffset) const
1021  {  {
1022  LAZYDEBUG(cout << "Resolve sample " << toString() << endl;)  LAZYDEBUG(cout << "Resolve sample " << toString() << endl;)
1023      // 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 1066  if (&x<stackend[omp_get_thread_num()])
1066  }  }
1067    
1068  const DataTypes::ValueType*  const DataTypes::ValueType*
1069  DataLazy::resolveNodeUnary(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeUnary(int tid, int sampleNo, size_t& roffset) const
1070  {  {
1071      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1072      // 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 1198  DataLazy::resolveNodeUnary(int tid, int
1198    
1199    
1200  const DataTypes::ValueType*  const DataTypes::ValueType*
1201  DataLazy::resolveNodeReduction(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeReduction(int tid, int sampleNo, size_t& roffset) const
1202  {  {
1203      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1204      // 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 1250  DataLazy::resolveNodeReduction(int tid,
1250  }  }
1251    
1252  const DataTypes::ValueType*  const DataTypes::ValueType*
1253  DataLazy::resolveNodeNP1OUT(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT(int tid, int sampleNo, size_t& roffset) const
1254  {  {
1255      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1256      // 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 1295  DataLazy::resolveNodeNP1OUT(int tid, int
1295  }  }
1296    
1297  const DataTypes::ValueType*  const DataTypes::ValueType*
1298  DataLazy::resolveNodeNP1OUT_P(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT_P(int tid, int sampleNo, size_t& roffset) const
1299  {  {
1300      // we assume that any collapsing has been done before we get here      // we assume that any collapsing has been done before we get here
1301      // 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 1343  DataLazy::resolveNodeNP1OUT_P(int tid, i
1343    
1344    
1345  const DataTypes::ValueType*  const DataTypes::ValueType*
1346  DataLazy::resolveNodeNP1OUT_2P(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeNP1OUT_2P(int tid, int sampleNo, size_t& roffset) const
1347  {  {
1348    if (m_readytype!='E')    if (m_readytype!='E')
1349    {    {
# Line 1378  DataLazy::resolveNodeNP1OUT_2P(int tid, Line 1379  DataLazy::resolveNodeNP1OUT_2P(int tid,
1379  }  }
1380    
1381  const DataTypes::ValueType*  const DataTypes::ValueType*
1382  DataLazy::resolveNodeCondEval(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeCondEval(int tid, int sampleNo, size_t& roffset) const
1383  {  {
1384    if (m_readytype!='E')    if (m_readytype!='E')
1385    {    {
# Line 1422  DataLazy::resolveNodeCondEval(int tid, i Line 1423  DataLazy::resolveNodeCondEval(int tid, i
1423  // For example, 2+Vector.  // For example, 2+Vector.
1424  // In this case each double within the point is treated individually  // In this case each double within the point is treated individually
1425  const DataTypes::ValueType*  const DataTypes::ValueType*
1426  DataLazy::resolveNodeBinary(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeBinary(int tid, int sampleNo, size_t& roffset) const
1427  {  {
1428  LAZYDEBUG(cout << "Resolve binary: " << toString() << endl;)  LAZYDEBUG(cout << "Resolve binary: " << toString() << endl;)
1429    
# Line 1549  LAZYDEBUG(cout << "Right res["<< rroffse Line 1550  LAZYDEBUG(cout << "Right res["<< rroffse
1550    
1551    
1552    roffset=m_samplesize*tid;    roffset=m_samplesize*tid;
1553    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
1554    switch(m_op)    switch(m_op)
1555    {    {
1556      case ADD:      case ADD:
# Line 1579  LAZYDEBUG(cout << "Result res[" << roffs Line 1580  LAZYDEBUG(cout << "Result res[" << roffs
1580  // 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.
1581  // unlike the other resolve helpers, we must treat these datapoints separately.  // unlike the other resolve helpers, we must treat these datapoints separately.
1582  const DataTypes::ValueType*  const DataTypes::ValueType*
1583  DataLazy::resolveNodeTProd(int tid, int sampleNo, size_t& roffset)  DataLazy::resolveNodeTProd(int tid, int sampleNo, size_t& roffset) const
1584  {  {
1585  LAZYDEBUG(cout << "Resolve TensorProduct: " << toString() << endl;)  LAZYDEBUG(cout << "Resolve TensorProduct: " << toString() << endl;)
1586    
# Line 1611  LAZYDEBUG(cout << "m_samplesize=" << m_s Line 1612  LAZYDEBUG(cout << "m_samplesize=" << m_s
1612  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)  LAZYDEBUG(cout << "outputshape=" << DataTypes::shapeToString(getShape()) << endl;)
1613  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)  LAZYDEBUG(cout << "DPPS=" << m_right->getNumDPPSample() <<"."<<endl;)
1614    
1615    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
1616    switch(m_op)    switch(m_op)
1617    {    {
1618      case PROD:      case PROD:
# Line 1638  LAZYDEBUG(cout << DataTypes::pointToStri Line 1639  LAZYDEBUG(cout << DataTypes::pointToStri
1639    
1640    
1641  const DataTypes::ValueType*  const DataTypes::ValueType*
1642  DataLazy::resolveSample(int sampleNo, size_t& roffset)  DataLazy::resolveSample(int sampleNo, size_t& roffset) const
1643  {  {
1644  #ifdef _OPENMP  #ifdef _OPENMP
1645      int tid=omp_get_thread_num();      int tid=omp_get_thread_num();
# Line 2094  DataLazy::setToZero() Line 2095  DataLazy::setToZero()
2095  //   m_readytype='C';  //   m_readytype='C';
2096  //   m_buffsRequired=1;  //   m_buffsRequired=1;
2097    
2098    privdebug=privdebug;  // to stop the compiler complaining about unused privdebug    (void)privdebug;  // to stop the compiler complaining about unused privdebug
2099    throw DataException("Programmer error - setToZero not supported for DataLazy (DataLazy objects should be read only).");    throw DataException("Programmer error - setToZero not supported for DataLazy (DataLazy objects should be read only).");
2100  }  }
2101    

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

  ViewVC Help
Powered by ViewVC 1.1.26