/[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 6512 by jfenwick, Fri Mar 3 02:01:57 2017 UTC revision 6513 by jfenwick, Fri Mar 3 03:04:03 2017 UTC
# Line 134  size_t maxstackuse=0; Line 134  size_t maxstackuse=0;
134  #endif  #endif
135    
136    
137    // namespace
138    // {
139    
140        inline int max3(int a, int b, int c)
141        {
142            int t=(a>b?a:b);
143            return (t>c?t:c);
144    
145        }
146        
147        
148        DataLazy_ptr makePromote(DataLazy_ptr p)
149        {
150            if (p->isComplex())
151            {
152                return p;
153            }
154            DataLazy* temp=new DataLazy(p, PROM);
155            return DataLazy_ptr(temp);
156        }
157    // }
158    
159    
160  // return the FunctionSpace of the result of "left op right"  // return the FunctionSpace of the result of "left op right"
161  FunctionSpace  FunctionSpace
162  resultFS(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op)  resultFS(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op)
# Line 432  LAZYDEBUG(cout << "Wrapping " << dr.get( Line 455  LAZYDEBUG(cout << "Wrapping " << dr.get(
455  LAZYDEBUG(cout << "(1)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(1)Lazy created with " << m_samplesize << endl;)
456  }  }
457    
458    // Wrapping a unary operation
459  DataLazy::DataLazy(DataAbstract_ptr left, ES_optype op)  DataLazy::DataLazy(DataAbstract_ptr left, ES_optype op)
460          : parent(left->getFunctionSpace(),(getOpgroup(op)!=G_REDUCTION)?left->getShape():DataTypes::scalarShape),          : parent(left->getFunctionSpace(),(getOpgroup(op)!=G_REDUCTION)?left->getShape():DataTypes::scalarShape),
461          m_op(op),          m_op(op),
# Line 458  DataLazy::DataLazy(DataAbstract_ptr left Line 482  DataLazy::DataLazy(DataAbstract_ptr left
482     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
483     m_children=m_left->m_children+1;     m_children=m_left->m_children+1;
484     m_height=m_left->m_height+1;     m_height=m_left->m_height+1;
485       m_iscompl=left->isComplex();
486     LazyNodeSetup();     LazyNodeSetup();
487     SIZELIMIT     SIZELIMIT
488  }  }
489    
490    
491  // In this constructor we need to consider interpolation  // In this constructor we need to consider interpolation and promotion
492  DataLazy::DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op)  DataLazy::DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op)
493          : parent(resultFS(left,right,op), resultShape(left,right,op)),          : parent(resultFS(left,right,op), resultShape(left,right,op)),
494          m_op(op),          m_op(op),
# Line 527  LAZYDEBUG(cout << "Right " << right.get( Line 552  LAZYDEBUG(cout << "Right " << right.get(
552     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
553     m_children=m_left->m_children+m_right->m_children+2;     m_children=m_left->m_children+m_right->m_children+2;
554     m_height=max(m_left->m_height,m_right->m_height)+1;     m_height=max(m_left->m_height,m_right->m_height)+1;
555      
556       // now we need to work out if we need to promote anything
557       if (left->isComplex()!=right->isComplex())
558       {
559           if (left->isComplex())
560           {
561               m_right=makePromote(m_right);
562           }
563           else
564           {
565               m_left=makePromote(m_left);
566           }
567       }
568       m_iscompl=left->isComplex();
569     LazyNodeSetup();     LazyNodeSetup();
570     SIZELIMIT     SIZELIMIT
571  LAZYDEBUG(cout << "(3)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(3)Lazy created with " << m_samplesize << endl;)
572  }  }
573    
574    // need to consider promotion
575  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)
576          : parent(resultFS(left,right,op), GTPShape(left,right, axis_offset, transpose, m_SL,m_SM, m_SR)),          : parent(resultFS(left,right,op), GTPShape(left,right, axis_offset, transpose, m_SL,m_SM, m_SR)),
577          m_op(op),          m_op(op),
# Line 593  DataLazy::DataLazy(DataAbstract_ptr left Line 633  DataLazy::DataLazy(DataAbstract_ptr left
633     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
634     m_children=m_left->m_children+m_right->m_children+2;     m_children=m_left->m_children+m_right->m_children+2;
635     m_height=max(m_left->m_height,m_right->m_height)+1;     m_height=max(m_left->m_height,m_right->m_height)+1;
636      
637      
638       // now we need to work out if we need to promote anything
639       if (left->isComplex()!=right->isComplex())
640       {
641           if (left->isComplex())
642           {
643               m_right=makePromote(m_right);
644           }
645           else
646           {
647               m_left=makePromote(m_left);
648           }
649       }
650       m_iscompl=left->isComplex();      
651     LazyNodeSetup();     LazyNodeSetup();
652     SIZELIMIT     SIZELIMIT
653  LAZYDEBUG(cout << "(4)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(4)Lazy created with " << m_samplesize << endl;)
# Line 624  DataLazy::DataLazy(DataAbstract_ptr left Line 679  DataLazy::DataLazy(DataAbstract_ptr left
679     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
680     m_children=m_left->m_children+1;     m_children=m_left->m_children+1;
681     m_height=m_left->m_height+1;     m_height=m_left->m_height+1;
682       m_iscompl=left->isComplex();
683     LazyNodeSetup();     LazyNodeSetup();
684     SIZELIMIT     SIZELIMIT
685  LAZYDEBUG(cout << "(5)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(5)Lazy created with " << m_samplesize << endl;)
# Line 654  DataLazy::DataLazy(DataAbstract_ptr left Line 710  DataLazy::DataLazy(DataAbstract_ptr left
710     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
711     m_children=m_left->m_children+1;     m_children=m_left->m_children+1;
712     m_height=m_left->m_height+1;     m_height=m_left->m_height+1;
713       m_iscompl=left->isComplex();
714     LazyNodeSetup();     LazyNodeSetup();
715     SIZELIMIT     SIZELIMIT
716  LAZYDEBUG(cout << "(6)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(6)Lazy created with " << m_samplesize << endl;)
# Line 685  DataLazy::DataLazy(DataAbstract_ptr left Line 742  DataLazy::DataLazy(DataAbstract_ptr left
742     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
743     m_children=m_left->m_children+1;     m_children=m_left->m_children+1;
744     m_height=m_left->m_height+1;     m_height=m_left->m_height+1;
745       m_iscompl=left->isComplex();
746     LazyNodeSetup();     LazyNodeSetup();
747     SIZELIMIT     SIZELIMIT
748  LAZYDEBUG(cout << "(7)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(7)Lazy created with " << m_samplesize << endl;)
749  }  }
750    
751    
 namespace  
 {  
752    
     inline int max3(int a, int b, int c)  
     {  
         int t=(a>b?a:b);  
         return (t>c?t:c);  
   
     }  
 }  
753    
754  DataLazy::DataLazy(DataAbstract_ptr mask, DataAbstract_ptr left, DataAbstract_ptr right/*, double tol*/)  DataLazy::DataLazy(DataAbstract_ptr mask, DataAbstract_ptr left, DataAbstract_ptr right/*, double tol*/)
755          : parent(left->getFunctionSpace(), left->getShape()),          : parent(left->getFunctionSpace(), left->getShape()),
# Line 748  DataLazy::DataLazy(DataAbstract_ptr mask Line 797  DataLazy::DataLazy(DataAbstract_ptr mask
797     m_samplesize=getNumDPPSample()*getNoValues();     m_samplesize=getNumDPPSample()*getNoValues();
798     m_children=m_left->m_children+m_right->m_children+m_mask->m_children+1;     m_children=m_left->m_children+m_right->m_children+m_mask->m_children+1;
799     m_height=max3(m_left->m_height,m_right->m_height,m_mask->m_height)+1;     m_height=max3(m_left->m_height,m_right->m_height,m_mask->m_height)+1;
800      
801       // now we need to work out if we need to promote anything
802       if (left->isComplex()!=right->isComplex())
803       {
804           if (left->isComplex())
805           {
806               m_right=makePromote(m_right);
807           }
808           else
809           {
810               m_left=makePromote(m_left);
811           }
812       }
813       m_iscompl=left->isComplex();  
814     LazyNodeSetup();     LazyNodeSetup();
815     SIZELIMIT     SIZELIMIT
816  LAZYDEBUG(cout << "(8)Lazy created with " << m_samplesize << endl;)  LAZYDEBUG(cout << "(8)Lazy created with " << m_samplesize << endl;)

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

  ViewVC Help
Powered by ViewVC 1.1.26