Hello everyone, I rewrote the XY routing algorithm to the YX routing algorithm,
I rewrote RoutingUnit.cc and Mesh_YX.py.
The files have been rewritten as follows.
Mesh_YX.py
class Mesh_YX(SimpleTopology):
description = "Mesh_YX"
def init(self, controllers):
self.nodes = controllers
# Makes a generic mesh
# assuming an equal number of cache and directory cntrls
def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes
num_routers = options.num_cpus
num_rows = options.mesh_rows
num_columns = int(num_routers / num_rows)
# default values for link latency and router latency.
# Can be over-ridden on a per link/router basis
link_latency = options.link_latency # used by simple and garnet
router_latency = options.router_latency # only used by garnet
# There must be an evenly divisible number of cntrls to routers
# Also, obviously the number or rows must be <= the number of routers
cntrls_per_router, remainder = divmod(len(nodes), num_routers)
assert num_columns > 0 and num_columns <= num_routers
assert num_columns * num_rows == num_routers
# Create the routers in the mesh
routers = [
Router(router_id=i, latency=router_latency)
for i in range(num_routers)
]
network.routers = routers
# link counter to set unique link ids
link_count = 0
# Add all but the remainder nodes to the list of nodes to be uniformly
# distributed across the network.
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])
# Connect each node to the appropriate router
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
# Connect the remainding nodes to router 0. These should only be
# DMA nodes.
for i, node in enumerate(remainder_nodes):
assert node.type == "DMA_Controller"
assert i < remainder
ext_links.append(
ExtLink(
link_id=link_count,
ext_node=node,
int_node=routers[0],
latency=link_latency,
)
)
link_count += 1
network.ext_links = ext_links
# Create the mesh links.
int_links = []
# North output to South input links (weight = 2)
for col in range(num_columns):
for row in range(num_rows):
if row + 1 < num_rows:
north_out = col + (row * num_columns)
south_in = col + ((row + 1) * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[north_out],
dst_node=routers[south_in],
src_outport="North",
dst_inport="South",
latency=link_latency,
weight=1,
)
)
link_count += 1
# South output to North input links (weight = 2)
for col in range(num_columns):
for row in range(num_rows):
if row + 1 < num_rows:
north_in = col + (row * num_columns)
south_out = col + ((row + 1) * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[south_out],
dst_node=routers[north_in],
src_outport="South",
dst_inport="North",
latency=link_latency,
weight=1,
)
)
link_count += 1
# East output to West input links (weight = 1)
for row in range(num_rows):
for col in range(num_columns):
if col + 1 < num_columns:
east_out = col + (row * num_columns)
west_in = (col + 1) + (row * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[east_out],
dst_node=routers[west_in],
src_outport="East",
dst_inport="West",
latency=link_latency,
weight=2,
)
)
link_count += 1
# West output to East input links (weight = 1)
for row in range(num_rows):
for col in range(num_columns):
if col + 1 < num_columns:
east_in = col + (row * num_columns)
west_out = (col + 1) + (row * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[west_out],
dst_node=routers[east_in],
src_outport="West",
dst_inport="East",
latency=link_latency,
weight=2,
)
)
link_count += 1
network.int_links = int_links
# Register nodes with filesystem
def registerTopology(self, options):
for i in range(options.num_cpus):
FileSystemConfig.register_node(
[i], MemorySize(options.mem_size) // options.num_cpus, i
)
RoutingUnit.CC
int
RoutingUnit::outportComputeYX(RouteInfo route,
int inport,
PortDirection inport_dirn)
{
PortDirection outport_dirn = "Unknown";
[[maybe_unused]] int num_rows = m_router->get_net_ptr()->getNumRows();
int num_cols = m_router->get_net_ptr()->getNumCols();
assert(num_rows > 0 && num_cols > 0);
int my_id = m_router->get_id();
int my_x = my_id % num_cols;
int my_y = my_id / num_cols;
int dest_id = route.dest_router;
int dest_x = dest_id % num_cols;
int dest_y = dest_id / num_cols;
int x_hops = abs(dest_x - my_x);
int y_hops = abs(dest_y - my_y);
bool x_dirn = (dest_x >= my_x);
bool y_dirn = (dest_y >= my_y);
// already checked that in outportCompute() function
assert(!(x_hops == 0 && y_hops == 0));
if (y_hops > 0) {
if (y_dirn) {
assert(inport_dirn == "Local" || inport_dirn == "North");
outport_dirn = "South";
} else {
assert(inport_dirn == "Local" || inport_dirn == "South");
outport_dirn = "North";
}
}
else if (x_hops > 0) {
if (x_dirn) {
// "Local" or "South" or "West" or "East"
assert(inport_dirn != "West");
outport_dirn = "West";
} else {
// "Local" or "North" or "West" or "East"
assert(inport_dirn != "East");
outport_dirn = "East";
}
}
else {
// x_hops == 0 and y_hops == 0
// this is not possible
// already checked that in outportCompute() function
panic("x_hops == y_hops == 0");
}
return m_outports_dirn2idx[outport_dirn];
}
and this is my command line.
#!/bin/bash
gem5path=/home/zr/gem5
spec2006path=$gem5path/CPU2006
outdir=/home/zr/gem5/m5out429
bench=429.mcf
ben_suffix=run/run_base_ref_amd64-m64-gcc42-nn.0000
exe=mcf_base.amd64-m64-gcc42-nn
$gem5path/build/X86/gem5.opt
--outdir=$outdir
$gem5path/configs/example/se.py
-c "$spec2006path/$bench/$ben_suffix/$exe"
--ruby
--network=garnet
--num-cpus=64
--num-dirs=64
--num-l2caches=64
--topology=Mesh_YX
--routing-algorithm=2
--mesh-rows=8
the following bug appeared.
system.remote_gdb: Listening for connections on port 7000
**** REAL SIMULATION ****
src/sim/simulate.cc:199: info: Entering event queue @ 0. Starting simulation...
gem5 has encountered a segmentation fault!
I would like to ask everyone, Why did this error occur. Thank you very much for your help.
Y阿Z阿
1765197550@qq.com
Hello everyone, I rewrote the XY routing algorithm to the YX routing algorithm,
I rewrote RoutingUnit.cc and Mesh_YX.py.
The files have been rewritten as follows.
Mesh_YX.py
class Mesh_YX(SimpleTopology):
description = "Mesh_YX"
def __init__(self, controllers):
self.nodes = controllers
# Makes a generic mesh
# assuming an equal number of cache and directory cntrls
def makeTopology(self, options, network, IntLink, ExtLink, Router):
nodes = self.nodes
num_routers = options.num_cpus
num_rows = options.mesh_rows
num_columns = int(num_routers / num_rows)
# default values for link latency and router latency.
# Can be over-ridden on a per link/router basis
link_latency = options.link_latency # used by simple and garnet
router_latency = options.router_latency # only used by garnet
# There must be an evenly divisible number of cntrls to routers
# Also, obviously the number or rows must be <= the number of routers
cntrls_per_router, remainder = divmod(len(nodes), num_routers)
assert num_columns > 0 and num_columns <= num_routers
assert num_columns * num_rows == num_routers
# Create the routers in the mesh
routers = [
Router(router_id=i, latency=router_latency)
for i in range(num_routers)
]
network.routers = routers
# link counter to set unique link ids
link_count = 0
# Add all but the remainder nodes to the list of nodes to be uniformly
# distributed across the network.
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])
# Connect each node to the appropriate router
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
# Connect the remainding nodes to router 0. These should only be
# DMA nodes.
for i, node in enumerate(remainder_nodes):
assert node.type == "DMA_Controller"
assert i < remainder
ext_links.append(
ExtLink(
link_id=link_count,
ext_node=node,
int_node=routers[0],
latency=link_latency,
)
)
link_count += 1
network.ext_links = ext_links
# Create the mesh links.
int_links = []
# North output to South input links (weight = 2)
for col in range(num_columns):
for row in range(num_rows):
if row + 1 < num_rows:
north_out = col + (row * num_columns)
south_in = col + ((row + 1) * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[north_out],
dst_node=routers[south_in],
src_outport="North",
dst_inport="South",
latency=link_latency,
weight=1,
)
)
link_count += 1
# South output to North input links (weight = 2)
for col in range(num_columns):
for row in range(num_rows):
if row + 1 < num_rows:
north_in = col + (row * num_columns)
south_out = col + ((row + 1) * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[south_out],
dst_node=routers[north_in],
src_outport="South",
dst_inport="North",
latency=link_latency,
weight=1,
)
)
link_count += 1
# East output to West input links (weight = 1)
for row in range(num_rows):
for col in range(num_columns):
if col + 1 < num_columns:
east_out = col + (row * num_columns)
west_in = (col + 1) + (row * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[east_out],
dst_node=routers[west_in],
src_outport="East",
dst_inport="West",
latency=link_latency,
weight=2,
)
)
link_count += 1
# West output to East input links (weight = 1)
for row in range(num_rows):
for col in range(num_columns):
if col + 1 < num_columns:
east_in = col + (row * num_columns)
west_out = (col + 1) + (row * num_columns)
int_links.append(
IntLink(
link_id=link_count,
src_node=routers[west_out],
dst_node=routers[east_in],
src_outport="West",
dst_inport="East",
latency=link_latency,
weight=2,
)
)
link_count += 1
network.int_links = int_links
# Register nodes with filesystem
def registerTopology(self, options):
for i in range(options.num_cpus):
FileSystemConfig.register_node(
[i], MemorySize(options.mem_size) // options.num_cpus, i
)
RoutingUnit.CC
int
RoutingUnit::outportComputeYX(RouteInfo route,
int inport,
PortDirection inport_dirn)
{
PortDirection outport_dirn = "Unknown";
[[maybe_unused]] int num_rows = m_router->get_net_ptr()->getNumRows();
int num_cols = m_router->get_net_ptr()->getNumCols();
assert(num_rows > 0 && num_cols > 0);
int my_id = m_router->get_id();
int my_x = my_id % num_cols;
int my_y = my_id / num_cols;
int dest_id = route.dest_router;
int dest_x = dest_id % num_cols;
int dest_y = dest_id / num_cols;
int x_hops = abs(dest_x - my_x);
int y_hops = abs(dest_y - my_y);
bool x_dirn = (dest_x >= my_x);
bool y_dirn = (dest_y >= my_y);
// already checked that in outportCompute() function
assert(!(x_hops == 0 && y_hops == 0));
if (y_hops > 0) {
if (y_dirn) {
assert(inport_dirn == "Local" || inport_dirn == "North");
outport_dirn = "South";
} else {
assert(inport_dirn == "Local" || inport_dirn == "South");
outport_dirn = "North";
}
}
else if (x_hops > 0) {
if (x_dirn) {
// "Local" or "South" or "West" or "East"
assert(inport_dirn != "West");
outport_dirn = "West";
} else {
// "Local" or "North" or "West" or "East"
assert(inport_dirn != "East");
outport_dirn = "East";
}
}
else {
// x_hops == 0 and y_hops == 0
// this is not possible
// already checked that in outportCompute() function
panic("x_hops == y_hops == 0");
}
return m_outports_dirn2idx[outport_dirn];
}
and this is my command line.
#!/bin/bash
gem5path=/home/zr/gem5
spec2006path=$gem5path/CPU2006
outdir=/home/zr/gem5/m5out429
bench=429.mcf
ben_suffix=run/run_base_ref_amd64-m64-gcc42-nn.0000
exe=mcf_base.amd64-m64-gcc42-nn
$gem5path/build/X86/gem5.opt \
--outdir=$outdir \
$gem5path/configs/example/se.py \
-c "$spec2006path/$bench/$ben_suffix/$exe" \
--ruby \
--network=garnet \
--num-cpus=64 \
--num-dirs=64 \
--num-l2caches=64 \
--topology=Mesh_YX \
--routing-algorithm=2 \
--mesh-rows=8
the following bug appeared.
system.remote_gdb: Listening for connections on port 7000
**** REAL SIMULATION ****
src/sim/simulate.cc:199: info: Entering event queue @ 0. Starting simulation...
gem5 has encountered a segmentation fault!
I would like to ask everyone, Why did this error occur. Thank you very much for your help.
Y阿Z阿
1765197550@qq.com