Hey everyone, for learning and researching purposes I'm trying to build a
simple custom routing algorithm in gem5/garnet between only two routers.
And use the custom routing algorithm in simulation command
But always i'm getting "Segmentation fault"

The following diagram represents what I'm trying to simulate.
[image: TwoRoutersSimple.jpg]


The names of each router are"routers0", "routers1" respectively.

The following is the full simulation command I'm trying to execute
sudo build/NULL/gem5.debug configs/example/garnet_synth_traffic.py
--injectionrate=0.02 --synthetic=uniform_random --network=garnet
--num-cpus=2 --num-dirs=2 --topology=TRouters --sim-cycles=10000000
--routing-algorithm=2

My routing is very simple, and i have tried to learn from the Mesh_XY
routing and imitate it, and modified the following function "int RoutingUnit
::outportComputeCustom(RouteInfo route, int inport, PortDirection
inport_dirn)" in file *src/mem/ruby/network/garnet/RoutingUnit.cc*
The following is my custom routing function

int RoutingUnit::outportComputeCustom(RouteInfo route, int inport,
PortDirection inport_dirn) {
PortDirection outport_dirn = "Unknown";
    if(route.dest_router == 0)
    {
        std::cout << "Destination Router: 0" << std::endl;
        outport_dirn = "routers0";
    }
    else
    {
        std::cout << "Destination Router: 1" << std::endl;
        outport_dirn = "routers1";
    }

    return m_outports_dirn2idx[outport_dirn];
}

And I have configured a python script that will create the network with all
nodes, internal links, external links, and routers.

Each time I tried to run the simulation the output was "Segmentation fault".

with some investigation into the code, i found that there are two built in
maps attached to each router, m_outports_dirn2idx and m_outports_idx2dirn
I iterated over the previous maps, and the following is the output for
*routers1 *
*Map from dir to index*
Local       1
routers0  0
routers1  2
*Map from index to dir*
0 Local
1 Local
2 routers1

If someone has some knowledge about garnet, I hope you can help me out !

Best Regards,
*Eng. Karim Soliman*
Teaching Assistant
Computer Engineering Department
Pharos University in Alexandria (P.U.A)
from m5.params import *
from m5.objects import *

from common import FileSystemConfig

from topologies.BaseTopology import SimpleTopology


class TRouters(SimpleTopology):
    description = "Two Routers Simple topology"
    
    def __init__(self, controllers):
        self.nodes = controllers
    
    def makeTopology(self, options, network, IntLink, ExtLink, Router):
        nodes = self.nodes
        
        num_routers = options.num_cpus
        
        link_latency = options.link_latency
        router_latency = options.router_latency
        
        
        # External Code -- Ceating two routers only working in different two time dmains
        
         # create the routers and configure the routers
        routers = [
            Router(router_id = i, _name="R_"+str(i), latency = router_latency)
            for i in range(num_routers)
        ]
        network.routers = routers
        
        for router in routers:
            print(f"Router [{router.router_id}]: {router._name}")
        
        # get the count of the controls per router and the remainder controls
        
        cntrls_per_router, remainder = divmod(len(nodes), num_routers)
        
        network_nodes = []
        remainder_nodes = []
        
        for node_index in range(len(nodes)):
            if node_index < (len(nodes) - remainder):
                network_nodes.append(nodes[node_index])
            else:
                remainder_nodes.append(nodes[node_index])
                
                
        # create the External Links and configure the links 
        # external links must be connected to nodes aka controllers
        
        link_count = 0
        
        ext_links = []
        for (i, n) in enumerate(network_nodes):
            cntrl_level, router_id = divmod(i, num_routers)
            assert cntrl_level < cntrls_per_router
            ext_links.append(ExtLink(
                link_id = link_count,
                ext_node = n,
                int_node = routers[router_id],
                latency = link_latency
            ))
            link_count += 1
            
        network.ext_links = ext_links
        # create the Internal Links and configure the links
        L0 = IntLink(
            link_id = link_count,
            latency = link_latency,
            src_node = routers[0],
            dst_node = routers[1],
            src_outport = "routers0",
            dst_inport = "routers1",
            weight = 1
        )
        print(f"{routers[0]} --> {routers[1]}")
        # update link_count for the next link_id
        link_count += 1
        
        L1 = IntLink(
            link_id = link_count,
            latency = link_latency,
            src_node = routers[1],
            dst_node = routers[0],
            src_outport = "routers1",
            dst_inport = "routers0",
            weight = 1
        )
        print(f"{routers[1]} --> {routers[0]}")
        # connect routers & internal links & external links to the routers
        
        network.int_links = [L0, L1]
        
        for router in network.routers:
            print(f"Router [{router.router_id}]: {router._name}")
        
        # DEBUG SOME OUTPUTS
        
        print("==========HOLA==========")
        print(f"# of cntrls_per_router = {cntrls_per_router}")
        print(f"# of router_latency = {router_latency}")
        print(f"# of link_latency = {link_latency}")
        print(f"# of link_count = {link_count}")
        print(f"# of routers = {len(routers)}")
        print(f"# of nodes = {len(nodes)}")
        print(f"# of internal links = {len(network.int_links)}")
        print(f"# of external links = {len(ext_links)}\n")
        
        
    def registerTopology(self, options):
        for i in range(options.num_cpus):
            FileSystemConfig.register_node(
                [i], MemorySize(options.mem_size) // options.num_cpus, i
            )
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to