void test_one_serial( SType &my_split, tbb::flow::graph &g) { typedef typename SType::input_type TType; static const int SIZE = tbb::flow::tuple_size<TType>::value; sink_node_helper<SIZE, SType>::add_sink_nodes(my_split,g); typedef TType q3_input_type; tbb::flow::queue_node< q3_input_type > q3(g); tbb::flow::make_edge( q3, my_split ); // fill the queue with its value one-at-a-time flags.clear(); for (int i = 0; i < Count; ++i ) { TType v; tuple_helper<SIZE>::set_element(v, i); ASSERT(my_split.try_put(v), NULL); flags.push_back(false); } g.wait_for_all(); sink_node_helper<SIZE,SType>::check_sink_values(); sink_node_helper<SIZE, SType>::remove_sink_nodes(my_split); }
void run_continue_nodes( int p, tbb::flow::graph& g, tbb::flow::continue_node< OutputType >& n ) { fake_continue_sender fake_sender; for (size_t i = 0; i < N; ++i) { n.register_predecessor( fake_sender ); } for (size_t num_receivers = 1; num_receivers <= MAX_NODES; ++num_receivers ) { harness_counting_receiver<OutputType> *receivers = new harness_counting_receiver<OutputType>[num_receivers]; harness_graph_executor<tbb::flow::continue_msg, OutputType>::execute_count = 0; for (size_t r = 0; r < num_receivers; ++r ) { tbb::flow::make_edge( n, receivers[r] ); } NativeParallelFor( p, parallel_puts<tbb::flow::continue_msg>(n) ); g.wait_for_all(); // 2) the nodes will receive puts from multiple predecessors simultaneously, size_t ec = harness_graph_executor<tbb::flow::continue_msg, OutputType>::execute_count; ASSERT( (int)ec == p, NULL ); for (size_t r = 0; r < num_receivers; ++r ) { size_t c = receivers[r].my_count; // 3) the nodes will send to multiple successors. ASSERT( (int)c == p, NULL ); } } }
void test_one_serial( OType &my_or, tbb::flow::graph &g) { last_index_seen.clear(); for(int ii=0; ii < SIZE; ++ii) last_index_seen.push_back(-1); typedef TType q3_input_type; tbb::flow::queue_node< q3_input_type > q3(g); q3_input_type v; ASSERT((my_or).register_successor( q3 ), NULL); // fill each queue with its value one-at-a-time for (int i = 0; i < Count; ++i ) { serial_queue_helper<SIZE,OType>::put_one_queue_val(i,my_or); } g.wait_for_all(); for (int i = 0; i < Count * SIZE; ++i ) { g.wait_for_all(); ASSERT(q3.try_get( v ), "Error in try_get()"); { serial_queue_helper<SIZE,OType>::check_queue_value(v); } } ASSERT(!q3.try_get( v ), "extra values in output queue"); for(int ii=0; ii < SIZE; ++ii) last_index_seen[ii] = -1; // fill each queue completely before filling the next. serial_queue_helper<SIZE, OType>::fill_one_queue(Count,my_or); g.wait_for_all(); for (int i = 0; i < Count*SIZE; ++i ) { g.wait_for_all(); ASSERT(q3.try_get( v ), "Error in try_get()"); { serial_queue_helper<SIZE,OType>::check_queue_value(v); } } ASSERT(!q3.try_get( v ), "extra values in output queue"); }
double bm_queue_node(tbb::flow::graph& g, int nIter) { tbb::flow::queue_node<my_type> first_queue(g); my_type v(nSize); tbb::tick_count t0 = tbb::tick_count::now(); //using queue_node for (int i = 0; i < nIter; ++i) first_queue.try_put(v); g.wait_for_all(); return (tbb::tick_count::now() - t0).seconds(); }
//! Dummy executing broadcast_node; "nIter" calls; Returns time in seconds. double bm_broadcast_node(tbb::flow::graph& g, int nIter) { tbb::flow::queue_node<my_type> my_queue(g); tbb::flow::broadcast_node<my_type> my_broadcast_node(g); make_edge(my_broadcast_node, my_queue); my_type v(nSize); const tbb::tick_count t0 = tbb::tick_count::now(); //using broadcast_node for (int i = 0; i < nIter; ++i) my_broadcast_node.try_put(v); //barrier sync g.wait_for_all(); return (tbb::tick_count::now() - t0).seconds(); }
//! Dummy executing split_node, "nIter" calls; Returns time in seconds. double bm_split_node(tbb::flow::graph& g, int nIter) { my_type v1(nSize); tbb::flow::queue_node<my_type> my_queue1(g); tbb::flow::tuple<my_type> my_tuple(1); tbb::flow::split_node< tbb::flow::tuple<my_type> > my_split_node(g); make_edge(tbb::flow::get<0>(my_split_node.output_ports()), my_queue1); const tbb::tick_count t0 = tbb::tick_count::now(); //using split_node for (int i = 0; i < nIter; ++i) my_split_node.try_put(my_tuple); //barrier sync g.wait_for_all(); return (tbb::tick_count::now() - t0).seconds(); }
bool wait_try_get( tbb::flow::graph &g, tbb::flow::sequencer_node<T> &q, T &value ) { g.wait_for_all(); return q.try_get(value); }