src/mem/ruby/network/garnet/NetworkInterface.cc
// Embed the protocol message into flits
Embed the protocol message into flits
Embed the protocol message into flits
bool
NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet)
{
    Message *net_msg_ptr = msg_ptr.get();
    NetDest net_msg_dest = net_msg_ptr->getDestination();
    std::vector<NodeID> dest_nodes = net_msg_dest.getAllDest();
    OutputPort *oPort = getOutportForVnet(vnet);
    assert(oPort);
    int num_flits = (int)divCeil((float) m_net_ptr->MessageSizeType_to_int(
        net_msg_ptr->getMessageSize()), (float)oPort->bitWidth());
    DPRINTF(RubyNetwork, "Message Size:%d vnet:%d bitWidth:%d\n",
        m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize()),
        vnet, oPort->bitWidth());
    for (int ctr = 0; ctr < dest_nodes.size(); ctr++) {
        int vc = calculateVC(vnet);
        if (vc == -1) {
            return false ;
        }
        MsgPtr new_msg_ptr = msg_ptr->clone();
        NodeID destID = dest_nodes[ctr];
        Message *new_net_msg_ptr = new_msg_ptr.get();
        if (dest_nodes.size() > 1) {
            NetDest personal_dest;
            for (int m = 0; m < (int) MachineType_NUM; m++) {
                if ((destID >= MachineType_base_number((MachineType) m)) &&
                    destID < MachineType_base_number((MachineType) (m+1))) {
                    personal_dest.clear();
                    personal_dest.add((MachineID) {(MachineType) m, (destID -
                        MachineType_base_number((MachineType) m))});
                    new_net_msg_ptr->getDestination() = personal_dest;
                    break;
                }
            }
            net_msg_dest.removeNetDest(personal_dest);
            net_msg_ptr->getDestination().removeNetDest(personal_dest);
        }
        RouteInfo route;
        route.vnet = vnet;
        route.net_dest = new_net_msg_ptr->getDestination();
        route.src_ni = m_id;
        route.src_router = oPort->routerID();
        route.dest_ni = destID;
        route.dest_router = m_net_ptr->get_router_id(destID, vnet);
        route.hops_traversed = -1;
        m_net_ptr->increment_injected_packets(vnet);
        m_net_ptr->update_traffic_distribution(route);
        for (int i = 0; i < num_flits; i++) {
            m_net_ptr->increment_injected_flits(vnet);
            flit *fl = new flit(i, vc, vnet, route, num_flits, new_msg_ptr,
                m_net_ptr->MessageSizeType_to_int(
                net_msg_ptr->getMessageSize()),
                oPort->bitWidth(), curTick());
            fl->set_src_delay(curTick() - msg_ptr->getTime());
            niOutVcs[vc].insert(fl);
        }
        m_ni_out_vcs_enqueue_time[vc] = curTick();
        outVcState[vc].setState(ACTIVE_, curTick());
    }
    return true ;
}
bool NetworkInterface :: flitisizeMessage ( MsgPtr msg_ptr , int vnet ) { Message * net_msg_ptr = msg_ptr . get ( ) ; NetDest net_msg_dest = net_msg_ptr -> getDestination ( ) ; std :: vector < NodeID > dest_nodes = net_msg_dest . getAllDest ( ) ; OutputPort * oPort = getOutportForVnet ( vnet ) ; assert ( oPort ) ; int num_flits = ( int ) divCeil ( ( float ) m_net_ptr -> MessageSizeType_to_int ( net_msg_ptr -> getMessageSize ( ) ) , ( float ) oPort -> bitWidth ( ) ) ; DPRINTF ( RubyNetwork , " \n " , m_net_ptr -> MessageSizeType_to_int ( net_msg_ptr -> getMessageSize ( ) ) , vnet , oPort -> bitWidth ( ) ) ; for ( int ctr = 0 ; ctr < dest_nodes . size ( ) ; ctr ++ ) { int vc = calculateVC ( vnet ) ; if ( vc == -1 ) { return false ; } MsgPtr new_msg_ptr = msg_ptr -> clone ( ) ; NodeID destID = dest_nodes [ ctr ] ; Message * new_net_msg_ptr = new_msg_ptr . get ( ) ; if ( dest_nodes . size ( ) > 1 ) { NetDest personal_dest ; for ( int m = 0 ; m < ( int ) MachineType_NUM ; m ++ ) { if ( ( destID >= MachineType_base_number ( ( MachineType ) m ) ) && destID < MachineType_base_number ( ( MachineType ) ( m + 1 ) ) ) { personal_dest . clear ( ) ; personal_dest . add ( ( MachineID ) { ( MachineType ) m , ( destID - MachineType_base_number ( ( MachineType ) m ) ) } ) ; new_net_msg_ptr -> getDestination ( ) = personal_dest ; break ; } } net_msg_dest . removeNetDest ( personal_dest ) ; net_msg_ptr -> getDestination ( ) . removeNetDest ( personal_dest ) ; } RouteInfo route ; route . vnet = vnet ; route . net_dest = new_net_msg_ptr -> getDestination ( ) ; route . src_ni = m_id ; route . src_router = oPort -> routerID ( ) ; route . dest_ni = destID ; route . dest_router = m_net_ptr -> get_router_id ( destID , vnet ) ; route . hops_traversed = -1 ; m_net_ptr -> increment_injected_packets ( vnet ) ; m_net_ptr -> update_traffic_distribution ( route ) ; for ( int i = 0 ; i < num_flits ; i ++ ) { m_net_ptr -> increment_injected_flits ( vnet ) ; flit * fl = new flit ( i , vc , vnet , route , num_flits , new_msg_ptr , m_net_ptr -> MessageSizeType_to_int ( net_msg_ptr -> getMessageSize ( ) ) , oPort -> bitWidth ( ) , curTick ( ) ) ; fl -> set_src_delay ( curTick ( ) - msg_ptr -> getTime ( ) ) ; niOutVcs [ vc ] . insert ( fl ) ; } m_ni_out_vcs_enqueue_time [ vc ] = curTick ( ) ; outVcState [ vc ] . setState ( ACTIVE_ , curTick ( ) ) ; } return true ; }
Embed the protocol message into flits
Embed the protocol message into flits
// gets all the destinations associated with this message. // Number of flits is dependent on the link bandwidth available. // This is expressed in terms of bytes/cycle or the flit size // loop to convert all multicast messages into unicast messages // this will return a free output virtual channel // calculating the NetDest associated with this destID // removing the destination from the original message to reflect // that a message with this particular destination has been // flitisized and an output vc is acquired // Embed Route into the flits // NetDest format is used by the routing table // Custom routing algorithms just need destID // initialize hops_traversed to -1 // so that the first router increments it to 0