Example #1
0
 std::string GetOpVecInfo(const OpRcPtrVec & ops)
 {
     std::ostringstream os;
     os << "Size " << ops.size() << std::endl;
     
     for(OpRcPtrVec::size_type i = 0, size = ops.size(); i < size; ++i)
     {
         os << "Index " << i << " -- " << *ops[i] << std::endl;
         os << "      supportsGPUShader: " << ops[i]->supportsGpuShader() << std::endl;
         os << "      cacheID " << ops[i]->getCacheID() << std::endl;
     }
     
     return os.str();
 }
Example #2
0
 void FinalizeOpVec(OpRcPtrVec & ops)
 {
     for(OpRcPtrVec::size_type i = 0, size = ops.size(); i < size; ++i)
     {
         ops[i]->finalize();
     }
 }
Example #3
0
 bool IsOpVecNoOp(const OpRcPtrVec & ops)
 {
     for(OpRcPtrVec::size_type i = 0, size = ops.size(); i < size; ++i)
     {
         if(!ops[i]->isNoOp()) return false;
     }
     
     return true;
 }
Example #4
0
 std::string SerializeOpVec(const OpRcPtrVec & ops, int indent)
 {
     std::ostringstream os;
     
     for(OpRcPtrVec::size_type i = 0, size = ops.size(); i < size; ++i)
     {
         os << pystring::mul(" ", indent);
         os << "Op " << i << ": " << *ops[i] << " ";
         os << ops[i]->getCacheID() << " supports_gpu:" << ops[i]->supportsGpuShader();
         os << "\n";
     }
     
     return os.str();
 }
Example #5
0
 void FinalizeOpVec(OpRcPtrVec & ops, bool optimize)
 {
     // TODO: Add envvar to force disable optimizations
     
     if(optimize)
     {
         OptimizeOpVec(ops);
     }
     
     for(OpRcPtrVec::size_type i = 0, size = ops.size(); i < size; ++i)
     {
         ops[i]->finalize();
     }
 }
Example #6
0
 int CombineOps(OpRcPtrVec & opVec)
 {
     int count = 0;
     int firstindex = 0; // this must be a signed int
     
     OpRcPtrVec tmpops;
     
     while(firstindex < static_cast<int>(opVec.size()-1))
     {
         ConstOpRcPtr first = opVec[firstindex];
         ConstOpRcPtr second = opVec[firstindex+1];
         
         if(first->canCombineWith(second))
         {
             tmpops.clear();
             first->combineWith(tmpops, second);
             
             // tmpops may have any number of ops in it. (0, 1, 2, ...)
             // (size 0 would occur potentially iff the combination 
             // results in a no-op)
             //
             // No matter the number, we need to swap them in for the
             // original ops
             
             // Erase the initial two ops we've combined
             opVec.erase(opVec.begin() + firstindex,
                 opVec.begin() + firstindex + 2);
             
             // Insert the new ops (which may be empty) at
             // this location
             std::copy(tmpops.begin(), tmpops.end(),
                 std::inserter(opVec, opVec.begin() + firstindex));
             
             // Decrement firstindex by 1,
             // to backstep and reconsider the A, A' case.
             // See RemoveInverseOps for the full discussion of
             // why this is appropriate
             firstindex = std::max(0, firstindex-1);
             
             // We've done something so increment the count!
             ++count;
         }
         else
         {
             ++firstindex;
         }
     }
     
     return count;
 }