FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

// This program demonstrates how to create a pipeline scheduling framework // that propagates a series of integers and adds one to the result at each // stage, using a range of pipes provided by the application. // // The pipeline has the following structure: // // o -> o -> o // | | | // v v v // o -> o -> o // | | | // v v v // o -> o -> o // | | | // v v v // o -> o -> o // // Then, the program resets the pipeline to a new range of five pipes. // // o -> o -> o -> o -> o // | | | | | // v v v v v // o -> o -> o -> o -> o // | | | | | // v v v v v // o -> o -> o -> o -> o // | | | | | // v v v v v // o -> o -> o -> o -> o #include #include int main() { tf::Taskflow taskflow("pipeline"); tf::Executor executor; const size_t num_lines = 4; // create data storage std::array buffer; // define the pipe callable auto pipe_callable = [&buffer] (tf::Pipeflow& pf) mutable { switch(pf.pipe()) { // first stage generates only 5 scheduling tokens and saves the // token number into the buffer. case 0: { if(pf.token() == 5) { pf.stop(); } else { printf("stage 1: input token = %zu\n", pf.token()); buffer[pf.line()] = pf.token(); } return; } break; // other stages propagate the previous result to this pipe and // increment it by one default: { printf( "stage %zu: input buffer[%zu] = %zu\n", pf.pipe(), pf.line(), buffer[pf.line()] ); buffer[pf.line()] = buffer[pf.line()] + 1; } break; } }; // create a vector of three pipes std::vector< tf::Pipe > pipes; for(size_t i=0; i

Back | FazBrowse Home | New Git URL