src/InsertHWBuffers.cpp
// Determine if a hwbuffer is needed (based on stride == stencil_size, and multiple uses)
Determine if a hwbuffer is needed (based on stride == stencil_size, and multiple uses)
Determine if a hwbuffer is needed ( based on stride == stencil_size and multiple uses )
bool need_hwbuffer(const HWBuffer &kernel) {
  if (kernel.is_output) {
    return false;
  } else {
    return true;
  }
    bool ret = false;
    for (const auto& ostream_pair : kernel.ostreams) {
      const auto& ostream = ostream_pair.second;
      internal_assert(ostream.odims.size() == kernel.dims.size());
      for (size_t i=0; i<ostream.odims.size(); ++i) {
        const auto& odim = ostream.odims.at(i);
        const auto& input_chunk = kernel.dims.at(i).input_chunk;
        if (to_int(odim.output_stencil) != to_int(input_chunk)) {
          ret = true;
          break;
        }
      }
      for (const auto& stride_pair : ostream.stride_map) {
        if (stride_pair.second.is_inverse) {
        }
        if (stride_pair.second.is_inverse) {
          return true;
        }
      }
    }
           return true;
       }
    if (kernel.num_accum_iters > 0) {
      std::cout << "creating accumulation for " << kernel.name << " with "  << kernel.num_accum_iters << " iterations" << std::endl;
      ret = true;
    }
    std::cout << kernel.name << " is needs_hwbuffer=" << ret << std::endl;
    return ret;
}
bool need_hwbuffer ( const HWBuffer & kernel ) { if ( kernel . is_output ) { return false ; } else { return true ; } bool ret = false ; for ( const auto & ostream_pair : kernel . ostreams ) { const auto & ostream = ostream_pair . second ; internal_assert ( ostream . odims . size ( ) == kernel . dims . size ( ) ) ; for ( size_t i = 0 ; i < ostream . odims . size ( ) ; ++ i ) { const auto & odim = ostream . odims . at ( i ) ; const auto & input_chunk = kernel . dims . at ( i ) . input_chunk ; if ( to_int ( odim . output_stencil ) != to_int ( input_chunk ) ) { ret = true ; break ; } } for ( const auto & stride_pair : ostream . stride_map ) { if ( stride_pair . second . is_inverse ) { } if ( stride_pair . second . is_inverse ) { return true ; } } } if ( kernel . num_accum_iters > 0 ) { } return ret ; }
Determine if a hwbuffer is needed (based on stride == stencil_size, and multiple uses)
Determine if a hwbuffer is needed ( based on stride == stencil_size and multiple uses )
// let's not do any optimization // check if we need a hwbuffer //std::cout << "checking if kernel " << kernel.name << " needs a hwbuffer...\n"; //std::cout << " this buffer has num_accum=" << kernel.num_accum_iters << " num_ostreams=" << kernel.ostreams.size() << std::endl; //std::cout << "kernel " << ostream.name << " has size=" << odim.output_stencil << " step=" << input_chunk << std::endl; //std::cout << stride_pair.first << " has stride="; //std::cout << "1/"; //std::cout << stride_pair.second.stride << "\n"; // check if there are loops that repeat //   for (const auto& stride_pair : kernel.stride_map) { //     //std::cout << stride_pair.first << " has stride="; //     if (stride_pair.second.is_inverse) { //       //std::cout << "1/"; //     } //     //std::cout << stride_pair.second.stride << "\n"; // //     if (stride_pair.second.is_inverse) { //       return true; //     } //   } //std::cout << "creating accumulation for " << kernel.name << " with "  << kernel.num_accum_iters << " iterations" << std::endl; //ret = true; //std::cout << kernel.name << " is needs_hwbuffer=" << ret << std::endl;