src/InsertHWBuffers.cpp
// Create dispatch which names what the consumers are for each buffer
// Note that currently only the source and destination names are used
Create dispatch which names what the consumers are for each buffer
Note that currently only the source and destination names are used
Create dispatch which names what the consumers are for each buffer Note that currently only the source and destination names are used
Stmt create_hwbuffer_dispatch_call(const HWBuffer& kernel, int min_fifo_depth = 0) {
    Expr stream_var = Variable::make(Handle(), kernel.name + ".stencil.stream");
    vector<Expr> dispatch_args({stream_var, (int)kernel.dims.size()});
    for (size_t i = 0; i < kernel.dims.size(); i++) {
        dispatch_args.push_back(kernel.dims[i].input_chunk); 
        dispatch_args.push_back(kernel.ldims[i].logical_size);
    }
    dispatch_args.push_back((int)kernel.ostreams.size());
    for (const auto& p : kernel.ostreams) {
      auto& ostream = p.second;
      auto cptr = ostream.hwref;
      (void) cptr;
      dispatch_args.push_back(p.first);
      dispatch_args.push_back(0); 
      for (size_t i = 0; i < kernel.dims.size(); i++) {
        dispatch_args.push_back(0);
        dispatch_args.push_back(0);
        dispatch_args.push_back(0);
      }
    }
    return Evaluate::make(Call::make(Handle(), "dispatch_stream", dispatch_args, Call::Intrinsic));
}
Stmt create_hwbuffer_dispatch_call ( const HWBuffer & kernel , int min_fifo_depth = 0 ) { Expr stream_var = Variable :: make ( Handle ( ) , kernel . name + " " ) ; vector < Expr > dispatch_args ( { stream_var , ( int ) kernel . dims . size ( ) } ) ; for ( size_t i = 0 ; i < kernel . dims . size ( ) ; i ++ ) { dispatch_args . push_back ( kernel . dims [ i ] . input_chunk ) ; dispatch_args . push_back ( kernel . ldims [ i ] . logical_size ) ; } dispatch_args . push_back ( ( int ) kernel . ostreams . size ( ) ) ; for ( const auto & p : kernel . ostreams ) { auto & ostream = p . second ; auto cptr = ostream . hwref ; ( void ) cptr ; dispatch_args . push_back ( p . first ) ; dispatch_args . push_back ( 0 ) ; for ( size_t i = 0 ; i < kernel . dims . size ( ) ; i ++ ) { dispatch_args . push_back ( 0 ) ; dispatch_args . push_back ( 0 ) ; dispatch_args . push_back ( 0 ) ; } } return Evaluate :: make ( Call :: make ( Handle ( ) , " " , dispatch_args , Call :: Intrinsic ) ) ; }
Create dispatch which names what the consumers are for each buffer
Note that currently only the source and destination names are used
Create dispatch which names what the consumers are for each buffer Note that currently only the source and destination names are used
//std::cout << "creating dispatch from " << kernel.name << " of " //          << kernel.dims.size() << " dims" << std::endl; // dispatch the stream into seperate streams for each of its consumers // syntax: //   dispatch_stream(stream_name, num_of_dimensions, //                   stencil_size_dim_0, stencil_step_dim_0, store_extent_dim_0, //                   [stencil_size_dim_1, stencil_step_dim_1, store_extent_dim_1, ...] //                   num_of_consumers, //                   consumer_0_name, fifo_0_depth, //                   consumer_0_offset_dim_0, consumer_0_extent_dim_0, //                   [consumer_0_offset_dim_1, consumer_0_extent_dim_1, ...] //                   [consumer_1_name, ...]) //dispatch_args.push_back(kernel.dims[i].output_stencil); // move for one of each stream //std::cout << "   going to " << kernel.ostreams.size() << " consumers: "; //std::cout << p.first << "(" << cptr->ldims.size() << " dims)" << ", \n"; //internal_assert(kernel.consumer_fifo_depths.count(p.first)); //dispatch_args.push_back(std::max(min_fifo_depth, kernel.consumer_fifo_depths.find(p.first)->second)); // assume a 0 fifo_depth //internal_assert(p.second->dims.size() == kernel.dims.size()); FIXME, should this be the case? //for (size_t i = 0; i < cptr->ldims.size(); i++) { //internal_assert(cptr->ldims.size() == ostream.odims.size()) << kernel.name << " ldims=" << cptr->ldims.size() << " while odims=" << ostream.odims.size(); //dispatch_args.push_back(i >= ostream.odims.size() ? 0 : ostream.odims.at(i).output_stencil); //dispatch_args.push_back(i >= cptr->ldims.size() ? 0 : cptr->ldims.at(i).logical_min); //dispatch_args.push_back(i >= cptr->ldims.size() ? 0 : cptr->ldims.at(i).logical_size);