| 561 | } |
| 562 | |
| 563 | void |
| 564 | raft::map::inline_join( split_stack_t &split_stack, |
| 565 | kernels_t &groups, |
| 566 | kernels_t &temp_groups, |
| 567 | kpair * const next ) |
| 568 | { |
| 569 | /** need to get the count **/ |
| 570 | std::size_t count( 0 ); |
| 571 | /** |
| 572 | * for every kernel in each group, join that |
| 573 | * group's kernels to a single destination and |
| 574 | * "join" |
| 575 | */ |
| 576 | auto joinfunc( [&]( up_group_t &group, kpair *n ) |
| 577 | { |
| 578 | auto it( group->begin() ); |
| 579 | for( auto port_it( n->dst->input.begin() ); |
| 580 | port_it != n->dst->input.end(); ++port_it ) |
| 581 | { |
| 582 | n->src = (*it); |
| 583 | n->dst_name = port_it.name(); |
| 584 | n->has_dst_name = true; |
| 585 | joink( n ); |
| 586 | ++it; |
| 587 | } |
| 588 | |
| 589 | }); |
| 590 | |
| 591 | for( auto &group : groups ) |
| 592 | { |
| 593 | /** |
| 594 | * need to add exception for too many |
| 595 | * output ports for source, or too |
| 596 | * few input ports for destination |
| 597 | */ |
| 598 | |
| 599 | if( count <= 0 ) |
| 600 | { |
| 601 | temp_groups.push_back( up_group_t( new group_t() ) ); |
| 602 | count = split_stack.top(); |
| 603 | } |
| 604 | if( temp_groups[ 0 ]->size() == 0 ) |
| 605 | { |
| 606 | /** use first kernel **/ |
| 607 | temp_groups.back()->emplace_back( next->dst ); |
| 608 | /** |
| 609 | * take all kernels from first group, attach |
| 610 | * to current dst. kernel |
| 611 | */ |
| 612 | joinfunc( group, next ); |
| 613 | } |
| 614 | else |
| 615 | { |
| 616 | /** |
| 617 | * we need to clone a kernel |
| 618 | */ |
| 619 | auto *temp_groups_k( next->dst->clone() ); |
| 620 | next->dst = temp_groups_k; |