/[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 2086 by jfenwick, Mon Nov 24 02:38:50 2008 UTC revision 2092 by jfenwick, Tue Nov 25 04:18:17 2008 UTC
# Line 28  Line 28 
28  #include "UnaryFuncs.h"     // for escript::fsign  #include "UnaryFuncs.h"     // for escript::fsign
29  #include "Utils.h"  #include "Utils.h"
30    
31    // #define LAZYDEBUG(X) X;
32    #define LAZYDEBUG(X)
33    
34  /*  /*
35  How does DataLazy work?  How does DataLazy work?
36  ~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~
# Line 340  DataLazy::DataLazy(DataAbstract_ptr p) Line 343  DataLazy::DataLazy(DataAbstract_ptr p)
343     m_buffsRequired=1;     m_buffsRequired=1;
344     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
345     m_maxsamplesize=m_samplesize;     m_maxsamplesize=m_samplesize;
346  cout << "(1)Lazy created with " << m_samplesize << endl;  LAZYDEBUG(cout << "(1)Lazy created with " << m_samplesize << endl;)
347  }  }
348    
349    
# Line 433  DataLazy::DataLazy(DataAbstract_ptr left Line 436  DataLazy::DataLazy(DataAbstract_ptr left
436     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
437     m_maxsamplesize=max(max(m_samplesize,m_right->getMaxSampleSize()),m_left->getMaxSampleSize());       m_maxsamplesize=max(max(m_samplesize,m_right->getMaxSampleSize()),m_left->getMaxSampleSize());  
438     m_buffsRequired=calcBuffs(m_left, m_right,m_op);     m_buffsRequired=calcBuffs(m_left, m_right,m_op);
439  cout << "(3)Lazy created with " << m_samplesize << endl;  LAZYDEBUG(cout << "(3)Lazy created with " << m_samplesize << endl;)
440  }  }
441    
442  DataLazy::DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op, int axis_offset, int transpose)  DataLazy::DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op, int axis_offset, int transpose)
# Line 497  DataLazy::DataLazy(DataAbstract_ptr left Line 500  DataLazy::DataLazy(DataAbstract_ptr left
500     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
501     m_maxsamplesize=max(max(m_samplesize,m_right->getMaxSampleSize()),m_left->getMaxSampleSize());       m_maxsamplesize=max(max(m_samplesize,m_right->getMaxSampleSize()),m_left->getMaxSampleSize());  
502     m_buffsRequired=calcBuffs(m_left, m_right,m_op);     m_buffsRequired=calcBuffs(m_left, m_right,m_op);
503  cout << "(4)Lazy created with " << m_samplesize << endl;  LAZYDEBUG(cout << "(4)Lazy created with " << m_samplesize << endl;)
504  }  }
505    
506    
# Line 525  DataLazy::DataLazy(DataAbstract_ptr left Line 528  DataLazy::DataLazy(DataAbstract_ptr left
528     m_buffsRequired=calcBuffs(m_left, m_right,m_op); // yeah m_right will be null at this point     m_buffsRequired=calcBuffs(m_left, m_right,m_op); // yeah m_right will be null at this point
529     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
530     m_maxsamplesize=max(m_samplesize,m_left->getMaxSampleSize());     m_maxsamplesize=max(m_samplesize,m_left->getMaxSampleSize());
531  cout << "(5)Lazy created with " << m_samplesize << endl;  LAZYDEBUG(cout << "(5)Lazy created with " << m_samplesize << endl;)
532  }  }
533    
534    
# Line 952  DataLazy::resolveNP1OUT_P(ValueType& v, Line 955  DataLazy::resolveNP1OUT_P(ValueType& v,
955  DataTypes::ValueType*  DataTypes::ValueType*
956  DataLazy::resolveBinary(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const  DataLazy::resolveBinary(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const
957  {  {
958  cout << "Resolve binary: " << toString() << endl;  LAZYDEBUG(cout << "Resolve binary: " << toString() << endl;)
959    
960    size_t lroffset=0, rroffset=0;    // offsets in the left and right result vectors    size_t lroffset=0, rroffset=0;    // offsets in the left and right result vectors
961      // first work out which of the children are expanded      // first work out which of the children are expanded
# Line 1027  cout << "Resolve binary: " << toString() Line 1030  cout << "Resolve binary: " << toString()
1030  DataTypes::ValueType*  DataTypes::ValueType*
1031  DataLazy::resolveTProd(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const  DataLazy::resolveTProd(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const
1032  {  {
1033  cout << "Resolve TensorProduct: " << toString() << endl;  LAZYDEBUG(cout << "Resolve TensorProduct: " << toString() << endl;)
1034    
1035    size_t lroffset=0, rroffset=0;    // offsets in the left and right result vectors    size_t lroffset=0, rroffset=0;    // offsets in the left and right result vectors
1036      // first work out which of the children are expanded      // first work out which of the children are expanded
# Line 1081  cout << "Resolve TensorProduct: " << toS Line 1084  cout << "Resolve TensorProduct: " << toS
1084  const DataTypes::ValueType*  const DataTypes::ValueType*
1085  DataLazy::resolveSample(ValueType& v, size_t offset, int sampleNo, size_t& roffset)  DataLazy::resolveSample(ValueType& v, size_t offset, int sampleNo, size_t& roffset)
1086  {  {
1087  cout << "Resolve sample " << toString() << endl;  LAZYDEBUG(cout << "Resolve sample " << toString() << endl;)
1088      // 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
1089    if (m_readytype!='E' && m_op!=IDENTITY)    if (m_readytype!='E' && m_op!=IDENTITY)
1090    {    {
# Line 1121  DataReady_ptr Line 1124  DataReady_ptr
1124  DataLazy::resolve()  DataLazy::resolve()
1125  {  {
1126    
1127  cout << "Sample size=" << m_samplesize << endl;  LAZYDEBUG(cout << "Sample size=" << m_samplesize << endl;)
1128  cout << "Buffers=" << m_buffsRequired << endl;  LAZYDEBUG(cout << "Buffers=" << m_buffsRequired << endl;)
1129    
1130    if (m_readytype!='E')     // if the whole sub-expression is Constant or Tagged, then evaluate it normally    if (m_readytype!='E')     // if the whole sub-expression is Constant or Tagged, then evaluate it normally
1131    {    {
# Line 1140  cout << "Buffers=" << m_buffsRequired << Line 1143  cout << "Buffers=" << m_buffsRequired <<
1143    numthreads=getNumberOfThreads();    numthreads=getNumberOfThreads();
1144  #endif  #endif
1145    ValueType v(numthreads*threadbuffersize);    ValueType v(numthreads*threadbuffersize);
1146  cout << "Buffer created with size=" << v.size() << endl;  LAZYDEBUG(cout << "Buffer created with size=" << v.size() << endl;)
1147    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));    DataExpanded* result=new DataExpanded(getFunctionSpace(),getShape(),  ValueType(getNoValues()));
1148    ValueType& resvec=result->getVector();    ValueType& resvec=result->getVector();
1149    DataReady_ptr resptr=DataReady_ptr(result);    DataReady_ptr resptr=DataReady_ptr(result);
# Line 1152  cout << "Buffer created with size=" << v Line 1155  cout << "Buffer created with size=" << v
1155    #pragma omp parallel for private(sample,resoffset,outoffset,res) schedule(static)    #pragma omp parallel for private(sample,resoffset,outoffset,res) schedule(static)
1156    for (sample=0;sample<totalsamples;++sample)    for (sample=0;sample<totalsamples;++sample)
1157    {    {
1158  cout << "################################# " << sample << endl;  LAZYDEBUG(cout << "################################# " << sample << endl;)
1159  #ifdef _OPENMP  #ifdef _OPENMP
1160      res=resolveSample(v,threadbuffersize*omp_get_thread_num(),sample,resoffset);      res=resolveSample(v,threadbuffersize*omp_get_thread_num(),sample,resoffset);
1161  #else  #else
1162      res=resolveSample(v,0,sample,resoffset);   // res would normally be v, but not if its a single IDENTITY op.      res=resolveSample(v,0,sample,resoffset);   // res would normally be v, but not if its a single IDENTITY op.
1163  #endif  #endif
1164  cerr << "-------------------------------- " << endl;  LAZYDEBUG(cerr << "-------------------------------- " << endl;)
1165      outoffset=result->getPointOffset(sample,0);      outoffset=result->getPointOffset(sample,0);
1166  cerr << "offset=" << outoffset << endl;  LAZYDEBUG(cerr << "offset=" << outoffset << endl;)
1167      for (unsigned int i=0;i<m_samplesize;++i,++outoffset,++resoffset)   // copy values into the output vector      for (unsigned int i=0;i<m_samplesize;++i,++outoffset,++resoffset)   // copy values into the output vector
1168      {      {
1169      resvec[outoffset]=(*res)[resoffset];      resvec[outoffset]=(*res)[resoffset];
1170      }      }
1171  cerr << "*********************************" << endl;  LAZYDEBUG(cerr << "*********************************" << endl;)
1172    }    }
1173    return resptr;    return resptr;
1174  }  }

Legend:
Removed from v.2086  
changed lines
  Added in v.2092

  ViewVC Help
Powered by ViewVC 1.1.26