src/InsertHWBuffers.cpp
// Add realize and read_stream calls arround hwinput
Add realize and read_stream calls arround hwinput
Add realize and read_stream calls arround hwinput
Stmt add_hwinput_stencil(Stmt s, const HWBuffer &kernel, const HWBuffer &input) {
    string stencil_name = input.name + ".stencil";
    string stream_name = stencil_name + ".stream";
    Expr stream_var = Variable::make(Handle(), stream_name);
    Expr stencil_var = Variable::make(Handle(), stencil_name);
    vector<Expr> args({stream_var, stencil_var});
    if (input.name != kernel.name) {
        args.push_back(kernel.name);
    }
    Stmt read_call = Evaluate::make(Call::make(Handle(), "read_stream", args, Call::Intrinsic));
    Stmt producer = ProducerConsumer::make_produce(stencil_name, read_call);
    Stmt consumer = ProducerConsumer::make_consume(stencil_name, s);
    Stmt pc = Block::make(producer, consumer);
    Region bounds;
    internal_assert(input.ostreams.count(kernel.name) > 0);
    for (const auto &dim : input.ostreams.at(kernel.name).odims) {
      bounds.push_back(Range(0, dim.output_block));
    }
    s = Realize::make(stencil_name, input.func.output_types(), MemoryType::Auto, bounds, const_true(), pc);
    return s;
}
Stmt add_hwinput_stencil ( Stmt s , const HWBuffer & kernel , const HWBuffer & input ) { string stencil_name = input . name + " " ; string stream_name = stencil_name + " " ; Expr stream_var = Variable :: make ( Handle ( ) , stream_name ) ; Expr stencil_var = Variable :: make ( Handle ( ) , stencil_name ) ; vector < Expr > args ( { stream_var , stencil_var } ) ; if ( input . name != kernel . name ) { args . push_back ( kernel . name ) ; } Stmt read_call = Evaluate :: make ( Call :: make ( Handle ( ) , " " , args , Call :: Intrinsic ) ) ; Stmt producer = ProducerConsumer :: make_produce ( stencil_name , read_call ) ; Stmt consumer = ProducerConsumer :: make_consume ( stencil_name , s ) ; Stmt pc = Block :: make ( producer , consumer ) ; Region bounds ; internal_assert ( input . ostreams . count ( kernel . name ) > 0 ) ; for ( const auto & dim : input . ostreams . at ( kernel . name ) . odims ) { bounds . push_back ( Range ( 0 , dim . output_block ) ) ; } s = Realize :: make ( stencil_name , input . func . output_types ( ) , MemoryType :: Auto , bounds , const_true ( ) , pc ) ; return s ; }
Add realize and read_stream calls arround hwinput
Add realize and read_stream calls arround hwinput
// syntax for read_stream() // read_stream(src_stream, dest_stencil, [consumer_name]) // for non-output kernel, we add an additional argument //std::cout << "let's see some inputs\n"; // create a realization of the stencil image //std::cout << input.name << " to " << kernel.name << " has " << input.ostreams.count(kernel.name) << std::endl; //std::cout << "created the realize\n";