├── ICN_lab ├── lab2 │ ├── results │ │ ├── tornado.png │ │ ├── neighbor.png │ │ ├── uniform_random.png │ │ ├── flattenedbutterfly_neighbor.txt │ │ ├── mesh_neighbor.txt │ │ ├── mesh_tornado.txt │ │ ├── flattenedbutterfly_tornado.txt │ │ ├── flattenedbutterfly_uniform_random.txt │ │ └── mesh_uniform_random.txt │ ├── pictures │ │ ├── picture1.png │ │ └── picture2.png │ ├── scripts │ │ ├── draw.py │ │ └── lab2.sh │ ├── README.md │ └── FlattenedButterfly.py └── lab1 │ ├── results │ ├── Figure_1.png │ ├── Figure_2.png │ ├── uniform_random.txt │ └── shuffle.txt │ ├── scripts │ ├── lab1_shuffle.sh │ ├── lab1_uniform_random.sh │ └── draw.py │ └── README.md ├── my_scripts ├── build_opt.sh ├── build_debug.sh └── extract_network_stats.sh └── README.md /ICN_lab/lab2/results/tornado.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab2/results/tornado.png -------------------------------------------------------------------------------- /ICN_lab/lab1/results/Figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab1/results/Figure_1.png -------------------------------------------------------------------------------- /ICN_lab/lab1/results/Figure_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab1/results/Figure_2.png -------------------------------------------------------------------------------- /ICN_lab/lab2/pictures/picture1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab2/pictures/picture1.png -------------------------------------------------------------------------------- /ICN_lab/lab2/pictures/picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab2/pictures/picture2.png -------------------------------------------------------------------------------- /ICN_lab/lab2/results/neighbor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab2/results/neighbor.png -------------------------------------------------------------------------------- /ICN_lab/lab2/results/uniform_random.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinchen13/gem5-noc/HEAD/ICN_lab/lab2/results/uniform_random.png -------------------------------------------------------------------------------- /my_scripts/build_opt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # path 4 | folder_to_check="./build/Garnet_standalone" 5 | 6 | if [ -d "$folder_to_check" ]; then 7 | echo "deleting existing build dir..." 8 | rm -rf "$folder_to_check" 9 | 10 | echo "done" 11 | else 12 | echo "no existing build dir" 13 | fi 14 | 15 | scons ./build/Garnet_standalone/gem5.opt PROTOCOL=Garnet_standalone -j8 16 | -------------------------------------------------------------------------------- /my_scripts/build_debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # path 4 | folder_to_check="./build/Garnet_standalone" 5 | 6 | if [ -d "$folder_to_check" ]; then 7 | echo "deleting existing build dir..." 8 | rm -rf "$folder_to_check" 9 | 10 | echo "done" 11 | else 12 | echo "no existing build dir" 13 | fi 14 | 15 | scons ./build/Garnet_standalone/gem5.debug PROTOCOL=Garnet_standalone -j8 16 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/flattenedbutterfly_neighbor.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 7505.632040 3 | 7505.632040 4 | 7505.632040 5 | 7505.632040 6 | 7505.632040 7 | 7505.632040 8 | 7505.632040 9 | 7505.632040 10 | 7505.632040 11 | 7505.632040 12 | 7505.632040 13 | 7505.632040 14 | 7505.632040 15 | 7505.632040 16 | 7505.632040 17 | 7505.632040 18 | 7505.632040 19 | 7505.632040 20 | 7505.632040 21 | 7505.632040 22 | 7505.632040 23 | 7505.632040 24 | 7505.632040 25 | 7505.632040 26 | 7505.632040 27 | 7505.632040 28 | 7505.632040 29 | 7505.632040 30 | 7505.632040 31 | 7505.632040 32 | 7505.632040 33 | 7505.632040 34 | 7505.632040 35 | 7505.632040 36 | 7505.632040 37 | 7505.632040 38 | 7505.632040 39 | 7505.632040 40 | 7505.632040 41 | 7505.632040 42 | 7505.632040 43 | 7505.632040 44 | 7505.632040 45 | 7505.632040 46 | 7505.632040 47 | 7505.632040 48 | 7505.632040 49 | 7505.632040 50 | 7505.632040 51 | -------------------------------------------------------------------------------- /ICN_lab/lab1/results/uniform_random.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 7810.262530 3 | 7831.578947 4 | 7805.068752 5 | 7842.596308 6 | 7864.869126 7 | 7860.876452 8 | 7873.412698 9 | 7922.355626 10 | 7894.632818 11 | 7975.188268 12 | 7965.424386 13 | 7954.933649 14 | 7993.648575 15 | 7987.085288 16 | 8031.768611 17 | 8076.240959 18 | 8048.803247 19 | 8123.991891 20 | 8153.105059 21 | 8207.434385 22 | 8247.578876 23 | 8286.632344 24 | 8318.103478 25 | 8382.853360 26 | 8479.689538 27 | 8525.984108 28 | 8627.444083 29 | 8682.410654 30 | 8841.806906 31 | 9123.413873 32 | 9752.925396 33 | 10334.824518 34 | 12121.998600 35 | 19438.075135 36 | 27721.919456 37 | 32294.141740 38 | 41891.934366 39 | 49063.216535 40 | 62356.462949 41 | 69142.540603 42 | 76669.652752 43 | 82071.867918 44 | 85411.374114 45 | 92511.284642 46 | 101377.555312 47 | 103852.749334 48 | 112715.050012 49 | 117582.158749 50 | 124693.769441 51 | -------------------------------------------------------------------------------- /ICN_lab/lab1/results/shuffle.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 6541.831097 3 | 6547.504026 4 | 6569.919786 5 | 6592.983855 6 | 6599.137255 7 | 6602.444474 8 | 6619.652331 9 | 6615.202603 10 | 6628.427065 11 | 6643.541238 12 | 6663.263839 13 | 6684.708977 14 | 6709.267700 15 | 6739.891574 16 | 6772.092046 17 | 6816.721764 18 | 6872.019115 19 | 6945.759066 20 | 7044.257925 21 | 7207.070507 22 | 7554.408545 23 | 8621.085859 24 | 12959.744731 25 | 22271.283484 26 | 33559.110647 27 | 43686.660698 28 | 52868.815936 29 | 59710.278859 30 | 66451.263828 31 | 73365.640878 32 | 78077.000917 33 | 81531.616841 34 | 84621.707666 35 | 88421.274631 36 | 92163.298694 37 | 95656.070488 38 | 104180.083795 39 | 106862.538518 40 | 114726.748971 41 | 116404.510584 42 | 118313.258158 43 | 123674.982292 44 | 128127.731069 45 | 125656.282766 46 | 135450.856665 47 | 139572.653744 48 | 141802.559567 49 | 134882.749004 50 | 140151.645036 51 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/mesh_neighbor.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 8273.466834 3 | 8299.334812 4 | 8279.514997 5 | 8282.809024 6 | 8282.458564 7 | 8297.846639 8 | 8309.270448 9 | 8327.093983 10 | 8333.915840 11 | 8343.212056 12 | 8362.035393 13 | 8372.378905 14 | 8388.797484 15 | 8403.976787 16 | 8423.780999 17 | 8446.051649 18 | 8471.254806 19 | 8491.262713 20 | 8524.057885 21 | 8556.922206 22 | 8590.433348 23 | 8646.499185 24 | 8709.330962 25 | 8783.184215 26 | 8881.099864 27 | 9003.190255 28 | 9165.611618 29 | 9376.156680 30 | 9667.624791 31 | 10164.283768 32 | 11067.666430 33 | 13283.363767 34 | 20286.329109 35 | 64127.095182 36 | 126200.595932 37 | 189546.550525 38 | 253082.110445 39 | 314814.620355 40 | 370855.248328 41 | 422718.609718 42 | 473861.957890 43 | 523820.671262 44 | 569957.431024 45 | 613556.082490 46 | 656394.558909 47 | 696038.756268 48 | 733928.281652 49 | 768928.638506 50 | 802724.175494 51 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/mesh_tornado.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 8273.466834 3 | 8299.334812 4 | 8279.514997 5 | 8282.809024 6 | 8282.458564 7 | 8297.846639 8 | 8309.270448 9 | 8327.093983 10 | 8333.915840 11 | 8343.212056 12 | 8362.035393 13 | 8372.378905 14 | 8388.797484 15 | 8403.976787 16 | 8423.780999 17 | 8446.051649 18 | 8471.254806 19 | 8491.262713 20 | 8524.057885 21 | 8556.922206 22 | 8590.433348 23 | 8646.499185 24 | 8709.330962 25 | 8783.184215 26 | 8881.099864 27 | 9003.190255 28 | 9165.611618 29 | 9376.156680 30 | 9667.624791 31 | 10164.283768 32 | 11067.666430 33 | 13283.363767 34 | 20286.329109 35 | 64127.095182 36 | 126200.595932 37 | 189546.550525 38 | 253082.110445 39 | 314814.620355 40 | 370855.248328 41 | 422718.609718 42 | 473861.957890 43 | 523820.671262 44 | 569957.431024 45 | 613556.082490 46 | 656394.558909 47 | 696038.756268 48 | 733928.281652 49 | 768928.638506 50 | 802724.175494 51 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/flattenedbutterfly_tornado.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 7505.632040 3 | 7515.362686 4 | 7527.760051 5 | 7536.860502 6 | 7546.013810 7 | 7556.664216 8 | 7568.259693 9 | 7580.331865 10 | 7590.089460 11 | 7600.561125 12 | 7613.640268 13 | 7625.851766 14 | 7641.457396 15 | 7652.392947 16 | 7671.867147 17 | 7692.741492 18 | 7712.619672 19 | 7736.267384 20 | 7767.390657 21 | 7800.465497 22 | 7836.341829 23 | 7892.501573 24 | 7954.514364 25 | 8030.444934 26 | 8128.310675 27 | 8250.078538 28 | 8411.842044 29 | 8622.075006 30 | 8912.814784 31 | 9408.883206 32 | 10313.502999 33 | 12528.711938 34 | 19535.579345 35 | 63382.796023 36 | 125465.347744 37 | 188818.610594 38 | 252361.000996 39 | 314101.230278 40 | 370147.871981 41 | 422008.188409 42 | 473155.917815 43 | 523119.450496 44 | 569260.235126 45 | 612862.548828 46 | 655704.477163 47 | 695352.163462 48 | 733245.342548 49 | 768249.211238 50 | 802033.766526 51 | -------------------------------------------------------------------------------- /ICN_lab/lab1/scripts/lab1_shuffle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # init 4 | value=0.02 # loop times 5 | echo "average packet latency" > m5out/shuffle.txt 6 | 7 | # loop 8 | for ((i=0; i<=48; i++)) 9 | do 10 | # run simulation and save the result 11 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 12 | --network=garnet \ 13 | --num-cpus=64 \ 14 | --num-dirs=64 \ 15 | --topology=Mesh_XY \ 16 | --mesh-rows=8 \ 17 | --sim-cycles=1000000 \ 18 | --inj-vnet=0 \ 19 | --injectionrate=$value \ 20 | --synthetic=shuffle 21 | 22 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/shuffle.txt 23 | # grep "average_packet_latency" m5out/stats.txt | sed 's/system.ruby.network.average_packet_latency\s*/average_packet_latency = /' >> m5out/shuffle.txt 24 | 25 | # value = value + 0.02 26 | value=$(echo "$value + 0.02" | bc) 27 | done 28 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/flattenedbutterfly_uniform_random.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 8273.354232 3 | 8273.854962 4 | 8328.899766 5 | 8306.279809 6 | 8330.342577 7 | 8358.256593 8 | 8379.509901 9 | 8386.850394 10 | 8421.776784 11 | 8441.150470 12 | 8466.779312 13 | 8479.663945 14 | 8519.279027 15 | 8572.119909 16 | 8604.023061 17 | 8671.575731 18 | 8728.953493 19 | 8805.208880 20 | 8870.408298 21 | 8977.416016 22 | 9097.463963 23 | 9245.983364 24 | 9401.365188 25 | 9641.950874 26 | 9979.091092 27 | 10485.354790 28 | 11156.599032 29 | 12177.804725 30 | 14979.896112 31 | 25212.865965 32 | 78108.634634 33 | 141195.185723 34 | 216452.053230 35 | 290497.753604 36 | 344070.101106 37 | 409025.727418 38 | 462829.820526 39 | 516951.011306 40 | 567086.380701 41 | 621365.581231 42 | 666732.418880 43 | 711078.403473 44 | 749623.305532 45 | 794514.301750 46 | 826337.850148 47 | 864865.389809 48 | 896721.751676 49 | 929213.775394 50 | 962102.489110 51 | -------------------------------------------------------------------------------- /ICN_lab/lab2/results/mesh_uniform_random.txt: -------------------------------------------------------------------------------- 1 | average packet latency 2 | 9795.611285 3 | 9778.466921 4 | 9863.481592 5 | 9800.891294 6 | 9866.135308 7 | 9883.233846 8 | 9906.213259 9 | 9936.288416 10 | 9998.009220 11 | 10024.093722 12 | 10067.847115 13 | 10087.522254 14 | 10136.944981 15 | 10267.827529 16 | 10336.377696 17 | 10478.208897 18 | 10619.705817 19 | 10831.066196 20 | 10923.113800 21 | 11359.920286 22 | 11885.913174 23 | 12667.065629 24 | 14392.665792 25 | 17019.574636 26 | 35767.864440 27 | 93427.994801 28 | 172989.601516 29 | 251228.872098 30 | 334207.732256 31 | 399593.625250 32 | 471229.615337 33 | 516096.964963 34 | 590450.003745 35 | 637230.704365 36 | 708327.880584 37 | 753347.368552 38 | 802481.317969 39 | 843309.255388 40 | 894603.334665 41 | 936125.843455 42 | 979974.285500 43 | 1000816.740110 44 | 1042157.373450 45 | 1082074.923050 46 | 1105995.246294 47 | 1136496.287345 48 | 1157112.992741 49 | 1193837.444813 50 | 1224207.107904 51 | -------------------------------------------------------------------------------- /ICN_lab/lab1/scripts/lab1_uniform_random.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # init 4 | value=0.02 # loop times 5 | echo "average packet latency" > m5out/uniform_random.txt 6 | 7 | # loop 8 | for ((i=0; i<=48; i++)) 9 | do 10 | # run simulation and save the result 11 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 12 | --network=garnet \ 13 | --num-cpus=64 \ 14 | --num-dirs=64 \ 15 | --topology=Mesh_XY \ 16 | --mesh-rows=8 \ 17 | --sim-cycles=1000000 \ 18 | --inj-vnet=0 \ 19 | --injectionrate=$value \ 20 | --synthetic=uniform_random 21 | 22 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/uniform_random.txt 23 | # grep "average_packet_latency" m5out/stats.txt | sed 's/system.ruby.network.average_packet_latency\s*/average_packet_latency = /' >> m5out/uniform_random.txt 24 | 25 | # value = value + 0.02 26 | value=$(echo "$value + 0.02" | bc) 27 | done 28 | -------------------------------------------------------------------------------- /ICN_lab/lab2/scripts/draw.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import math 4 | 5 | injection_rate = np.arange(0.02, 1, 0.02).tolist() 6 | 7 | topology = ["mesh", "flattenedbutterfly"] 8 | traffic = ["uniform_random", "tornado", "neighbor"] 9 | curve_1 = [] 10 | curve_2 = [] 11 | 12 | for traf in traffic: 13 | # read from files: mesh 14 | curve_1.clear() 15 | f_1 = open("./results/" + topology[0] + "_" + traf + ".txt") 16 | line = f_1.readline() # drop "average packet latency" 17 | line = f_1.readline() 18 | while(line): 19 | print(line, end = '') 20 | curve_1.append(math.log(float(line))) 21 | line = f_1.readline() 22 | f_1.close() 23 | # read from files: flattenedbutterfly 24 | curve_2.clear() 25 | f_2 = open("./results/" + topology[1] + "_" + traf + ".txt") 26 | line = f_2.readline() # drop "average packet latency" 27 | line = f_2.readline() 28 | while(line): 29 | print(line, end = '') 30 | curve_2.append(math.log(float(line))) 31 | line = f_2.readline() 32 | f_2.close() 33 | # plot and save the fig 34 | plt.plot(injection_rate[0:-10], curve_1[0:-10], label='Mesh_XY - '+traf, marker='o') 35 | plt.plot(injection_rate[0:-10], curve_2[0:-10], label='FlattenedButterfly - '+traf, marker='o') 36 | plt.title("average packet latency VS injection rate") 37 | plt.xlabel('injection rate') 38 | plt.ylabel('log(average packet latency)') 39 | plt.legend() 40 | plt.savefig("./results/" + traf + ".png") 41 | plt.clf() 42 | -------------------------------------------------------------------------------- /my_scripts/extract_network_stats.sh: -------------------------------------------------------------------------------- 1 | echo > m5out/network_stats.txt 2 | grep "packets_injected::total" m5out/stats.txt | sed 's/system.ruby.network.packets_injected::total\s*/packets_injected = /' >> m5out/network_stats.txt 3 | grep "packets_received::total" m5out/stats.txt | sed 's/system.ruby.network.packets_received::total\s*/packets_received = /' >> m5out/network_stats.txt 4 | grep "average_packet_queueing_latency" m5out/stats.txt | sed 's/system.ruby.network.average_packet_queueing_latency\s*/average_packet_queueing_latency = /' >> m5out/network_stats.txt 5 | grep "average_packet_network_latency" m5out/stats.txt | sed 's/system.ruby.network.average_packet_network_latency\s*/average_packet_network_latency = /' >> m5out/network_stats.txt 6 | grep "average_packet_latency" m5out/stats.txt | sed 's/system.ruby.network.average_packet_latency\s*/average_packet_latency = /' >> m5out/network_stats.txt 7 | grep "flits_injected::total" m5out/stats.txt | sed 's/system.ruby.network.flits_injected::total\s*/flits_injected = /' >> m5out/network_stats.txt 8 | grep "flits_received::total" m5out/stats.txt | sed 's/system.ruby.network.flits_received::total\s*/flits_received = /' >> m5out/network_stats.txt 9 | grep "average_flit_queueing_latency" m5out/stats.txt | sed 's/system.ruby.network.average_flit_queueing_latency\s*/average_flit_queueing_latency = /' >> m5out/network_stats.txt 10 | grep "average_flit_network_latency" m5out/stats.txt | sed 's/system.ruby.network.average_flit_network_latency\s*/average_flit_network_latency = /' >> m5out/network_stats.txt 11 | grep "average_flit_latency" m5out/stats.txt | sed 's/system.ruby.network.average_flit_latency\s*/average_flit_latency = /' >> m5out/network_stats.txt 12 | grep "average_hops" m5out/stats.txt | sed 's/system.ruby.network.average_hops\s*/average_hops = /' >> m5out/network_stats.txt 13 | echo >> m5out/network_stats.txt 14 | cat m5out/network_stats.txt -------------------------------------------------------------------------------- /ICN_lab/lab1/scripts/draw.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | injection_rate = np.arange(0.02, 1, 0.02).tolist() 5 | uniform_random = [7810.262530, 6 | 7831.578947, 7 | 7805.068752, 8 | 7842.596308, 9 | 7864.869126, 10 | 7860.876452, 11 | 7873.412698, 12 | 7922.355626, 13 | 7894.632818, 14 | 7975.188268, 15 | 7965.424386, 16 | 7954.933649, 17 | 7993.648575, 18 | 7987.085288, 19 | 8031.768611, 20 | 8076.240959, 21 | 8048.803247, 22 | 8123.991891, 23 | 8153.105059, 24 | 8207.434385, 25 | 8247.578876, 26 | 8286.632344, 27 | 8318.103478, 28 | 8382.853360, 29 | 8479.689538, 30 | 8525.984108, 31 | 8627.444083, 32 | 8682.410654, 33 | 8841.806906, 34 | 9123.413873, 35 | 9752.925396, 36 | 10334.824518, 37 | 12121.998600, 38 | 19438.075135, 39 | 27721.919456, 40 | 32294.141740, 41 | 41891.934366, 42 | 49063.216535, 43 | 62356.462949, 44 | 69142.540603, 45 | 76669.652752, 46 | 82071.867918, 47 | 85411.374114, 48 | 92511.284642, 49 | 101377.555312, 50 | 103852.749334, 51 | 112715.050012, 52 | 117582.158749, 53 | 124693.769441] 54 | shuffle = [6541.831097, 55 | 6547.504026, 56 | 6569.919786, 57 | 6592.983855, 58 | 6599.137255, 59 | 6602.444474, 60 | 6619.652331, 61 | 6615.202603, 62 | 6628.427065, 63 | 6643.541238, 64 | 6663.263839, 65 | 6684.708977, 66 | 6709.267700, 67 | 6739.891574, 68 | 6772.092046, 69 | 6816.721764, 70 | 6872.019115, 71 | 6945.759066, 72 | 7044.257925, 73 | 7207.070507, 74 | 7554.408545, 75 | 8621.085859, 76 | 12959.744731, 77 | 22271.283484, 78 | 33559.110647, 79 | 43686.660698, 80 | 52868.815936, 81 | 59710.278859, 82 | 66451.263828, 83 | 73365.640878, 84 | 78077.000917, 85 | 81531.616841, 86 | 84621.707666, 87 | 88421.274631, 88 | 92163.298694, 89 | 95656.070488, 90 | 104180.083795, 91 | 106862.538518, 92 | 114726.748971, 93 | 116404.510584, 94 | 118313.258158, 95 | 123674.982292, 96 | 128127.731069, 97 | 125656.282766, 98 | 135450.856665, 99 | 139572.653744, 100 | 141802.559567, 101 | 134882.749004, 102 | 140151.645036] 103 | 104 | plt.plot(injection_rate, uniform_random, label='uniform_random', marker='o') 105 | plt.plot(injection_rate, shuffle, label='shuffle', marker='o') 106 | 107 | plt.title('average packet latency VS injection rate') 108 | plt.xlabel('injection rate') 109 | plt.ylabel('average packet latency') 110 | 111 | plt.legend() 112 | plt.show() 113 | -------------------------------------------------------------------------------- /ICN_lab/lab1/README.md: -------------------------------------------------------------------------------- 1 | # Running Synthetic Traffic through a Network 2 | 3 | ## Uniform Random Traffic 4 | run uniform random traffic at increasing injection rates through a 8x8 Mesh NoC for 1000000 cycles, and plot the latency-throughput curve 5 | 6 | command to run: 7 | ```sh 8 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 9 | --network=garnet \ 10 | --num-cpus=64 \ 11 | --num-dirs=64 \ 12 | --topology=Mesh_XY \ 13 | --mesh-rows=8 \ 14 | --sim-cycles=1000000 \ 15 | --inj-vnet=0 \ 16 | --injectionrate=0.02 \ 17 | --synthetic=uniform_random 18 | ``` 19 | 20 | extract ststs by scripts: 21 | ``` 22 | packets_injected = 10 (Unspecified) 23 | packets_received = 4 (Unspecified) 24 | average_packet_queueing_latency = 1000 (Unspecified) 25 | average_packet_network_latency = 5250 (Unspecified) 26 | average_packet_latency = 6250 (Unspecified) 27 | flits_injected = 10 (Unspecified) 28 | flits_received = 4 (Unspecified) 29 | average_flit_queueing_latency = 1000 (Unspecified) 30 | average_flit_network_latency = 5250 (Unspecified) 31 | average_flit_latency = 6250 (Unspecified) 32 | average_hops = 3.750000 (Unspecified) 33 | ``` 34 | 35 | - the `injection rate` is in units of **packets/node/cycle** 36 | - the units for `average_packet_latency` is in **cycles** 37 | - `average_packet_latency` = `average_packet_queueing_latency` + `average_packet_network_latency` 38 | - the injected and received packets will be slightly off since the simulation stops at 10,000 cycles at which point some packets are still in the network 39 | 40 | Increase the `injection rate` at intervals of 0.02, till it reaches 0.5. This will give a total of 25 data points. 41 | For each data point, add the `average_packet_latency` value in [uniform_random.txt](./results/uniform_random.txt) one after the other. 42 | 43 | run the script: [lab1_uniform_random.sh](./scripts/lab1_uniform_random.sh), get the result 44 | 45 | ## Shuffle Traffic 46 | run shuffle traffic at increasing injection rates through a 8x8 Mesh NoC for 1000000 cycles, and plot the latency-throughput curve. change `--synthetic` to shuffle, run [lab1_shuffle.sh](./scripts/lab1_shuffle.sh) create [shuffle.txt](./results/shuffle.txt) 47 | 48 | ## Analysis 49 | draw pictures with [draw.py](./scripts/draw.py) 50 | 51 | #### Which of the two traffic patterns has a lower low-load latency: shuffle 52 | ![Figure_2.png](./results/Figure_2.png) 53 | 54 | #### Which of the two traffic patterns has a higher throughput: uniform random 55 | ![Figure_1.png](./results/Figure_1.png) -------------------------------------------------------------------------------- /ICN_lab/lab2/README.md: -------------------------------------------------------------------------------- 1 | # Topology Comparison 2 | - construct new topologis 3 | - compare a Mesh (called Mesh_XY in Garnet), Flattened-Butterfly, for network performance 4 | - design space exploration: run a suite of simulations for of these three topologies and plot the results 5 | 6 | ## Flattened Butterfly Topology 7 | #### papers 8 | - Kim et al., “Flattened Butterfly: A Cost-Efficient Topology for High-Radix Networks”, 9 | ISCA 2007 10 | - Kim et al., “Flattened Butterfly Topology for On-Chip Networks”, MICRO 2007 11 | 12 | #### tips 13 | - focus just on the topology (don’t worry about the routing and flow-control aspects discussed in the paper) 14 | - do not need to implement the concentration factor (4 nodes connected to one Router) used in the paper(assume Garnet’s default one traffic injector per router) 15 | 16 | #### steps 17 | 1. Create [FlattenedButterfly.py](./FlattenedButterfly.py) in `$gem5/configs/topologies` 18 | - take a look at `Mesh_XY.py` for reference 19 | - all links are uni-directional – i.e., we need to add links in both directions 20 | - notice a link weight of “1” on the x-links and “2” on the y-links for deadlock avoidance. use the same allocation in the topologies 21 | - the router ids used in Mesh_XY code follow the following numbering scheme (0 to 15) 22 | ![num-scheme.png](./pictures/picture1.png) 23 | 24 | - the link of 4*4 Flattened-Butterfly is shown below(the routers within a row are fully connected, as are the routers 25 | within a column) 26 | ![Flattened-Butterfly](./pictures/picture2.png) 27 | 28 | 2. print all the links that are created every time a simulation is run for debugging 29 | 3. testing: i.e. inject one (or more fixed number of) packet(s) into the network from a specific source to a specific destination 30 | 4. run this topology by specifying `--topology=FlattenedButterfly` 31 | 32 | ## Configuration 33 | #### traffic description 34 | - all packets are 64-bits wide: the number of flits in every packet = (packet_size / link width) 35 | - run Uniform Random(`--synthetic=uniform_random`), Tornado(`--synthetic=tornado`) and Neighbor(`--synthetic=neighbor`) traffic pattern for all the designs; the details of each traffic pattern can be seen in `src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc` 36 | - start at a (packet) injection rate of 0.02, and keep incrementing in intervals of 0.02 till the network saturates 37 | 38 | #### requirements 39 | for each (configuration, traffic pattern) pair, plot the average packet latency vs. injection rate for both topologies on the same graph: Mesh and Flattened Butterfly 40 | 41 | Sample run command is shown below: 42 | ```sh 43 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 44 | --network=garnet \ 45 | --num-cpus=16 \ 46 | --num-dirs=16 \ 47 | --topology=Mesh_XY \ 48 | --mesh-rows=4 \ 49 | --sim-cycles=5000000 \ 50 | --inj-vnet=0 \ 51 | --router-latency=2 \ 52 | --injectionrate=0.02 \ 53 | --synthetic=uniform_random \ 54 | --link-width-bits=32 55 | ``` 56 | 57 | ## Analysis 58 | run [lab2.sh](./scripts/lab2.sh) and save the fig (in [./results/](./results/)) 59 | 60 | ### uniform_random 61 | ![uniform_random.png](./results/uniform_random.png) 62 | 63 | ### tornado 64 | ![tornado.png](./results/tornado.png) 65 | 66 | ### neighbor 67 | ![neighbor.png](./results/neighbor.png) 68 | -------------------------------------------------------------------------------- /ICN_lab/lab2/scripts/lab2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # init 4 | value=0.02 # loop times 5 | echo "average packet latency" > m5out/mesh_uniform_random.txt 6 | echo "average packet latency" > m5out/flattenedbutterfly_uniform_random.txt 7 | echo "average packet latency" > m5out/mesh_tornado.txt 8 | echo "average packet latency" > m5out/flattenedbutterfly_tornado.txt 9 | echo "average packet latency" > m5out/mesh_neighbor.txt 10 | echo "average packet latency" > m5out/flattenedbutterfly_neighbor.txt 11 | 12 | # loop 13 | for ((i=0; i<=48; i++)) 14 | do 15 | # mesh + uniform_random 16 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 17 | --network=garnet \ 18 | --num-cpus=16 \ 19 | --num-dirs=16 \ 20 | --topology=Mesh_XY \ 21 | --mesh-rows=4 \ 22 | --sim-cycles=5000000 \ 23 | --inj-vnet=0 \ 24 | --router-latency=2 \ 25 | --injectionrate=$value \ 26 | --synthetic=uniform_random \ 27 | --link-width-bits=32 28 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/mesh_uniform_random.txt 29 | 30 | # flattenedbutterfly + uniform_random 31 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 32 | --network=garnet \ 33 | --num-cpus=16 \ 34 | --num-dirs=16 \ 35 | --topology=FlattenedButterfly \ 36 | --mesh-rows=4 \ 37 | --sim-cycles=5000000 \ 38 | --inj-vnet=0 \ 39 | --router-latency=2 \ 40 | --injectionrate=$value \ 41 | --synthetic=uniform_random \ 42 | --link-width-bits=32 43 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/flattenedbutterfly_uniform_random.txt 44 | 45 | # mesh + tornado 46 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 47 | --network=garnet \ 48 | --num-cpus=16 \ 49 | --num-dirs=16 \ 50 | --topology=Mesh_XY \ 51 | --mesh-rows=4 \ 52 | --sim-cycles=5000000 \ 53 | --inj-vnet=0 \ 54 | --router-latency=2 \ 55 | --injectionrate=$value \ 56 | --synthetic=tornado \ 57 | --link-width-bits=32 58 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/mesh_tornado.txt 59 | 60 | # flattenedbutterfly + tornado 61 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 62 | --network=garnet \ 63 | --num-cpus=16 \ 64 | --num-dirs=16 \ 65 | --topology=FlattenedButterfly \ 66 | --mesh-rows=4 \ 67 | --sim-cycles=5000000 \ 68 | --inj-vnet=0 \ 69 | --router-latency=2 \ 70 | --injectionrate=$value \ 71 | --synthetic=tornado \ 72 | --link-width-bits=32 73 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/flattenedbutterfly_tornado.txt 74 | 75 | # mesh + neighbor 76 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 77 | --network=garnet \ 78 | --num-cpus=16 \ 79 | --num-dirs=16 \ 80 | --topology=Mesh_XY \ 81 | --mesh-rows=4 \ 82 | --sim-cycles=5000000 \ 83 | --inj-vnet=0 \ 84 | --router-latency=2 \ 85 | --injectionrate=$value \ 86 | --synthetic=neighbor \ 87 | --link-width-bits=32 88 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/mesh_neighbor.txt 89 | 90 | # flattenedbutterfly + neighbor 91 | ./build/Garnet_standalone/gem5.opt configs/example/garnet_synth_traffic.py \ 92 | --network=garnet \ 93 | --num-cpus=16 \ 94 | --num-dirs=16 \ 95 | --topology=FlattenedButterfly \ 96 | --mesh-rows=4 \ 97 | --sim-cycles=5000000 \ 98 | --inj-vnet=0 \ 99 | --router-latency=2 \ 100 | --injectionrate=0.02 \ 101 | --synthetic=neighbor \ 102 | --link-width-bits=32 103 | grep "average_packet_latency" m5out/stats.txt | awk '{print $2}' >> m5out/flattenedbutterfly_neighbor.txt 104 | 105 | # value = value + 0.02 106 | value=$(echo "$value + 0.02" | bc) 107 | done 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NoC simulation with gem5(a simple tutorial for Garnet) 2 | Run and modify Garnet as a stand-alone in gem5. Garnet models the interconnection network in gem5. It is cyclic accurate, implements the micro-architecture of on-chip router, and uses gem5 ruby memory system for topology and routing 3 | 4 | ## Purposes 5 | - 熟练使用体系结构模拟器 gem5 进行建模 6 | - 深入理解高性能体系结构的建模,NoC与Cache coherence 7 | 8 | ## Compile and first run 9 | To run Garnet as a stand-alone, compile it with the following command 10 | 11 | ```sh 12 | scons build/Garnet_standalone/gem5.debug PROTOCOL=Garnet_standalone -j9 13 | ``` 14 | 15 | Run gem5 using the `garnet_synth_traffic.py` configuration file with default configuration parameters 16 | 17 | ```sh 18 | ./build/Garnet_standalone/gem5.debug configs/example/garnet_synth_traffic.py 19 | ``` 20 | 21 | ## Configuration parameters 22 | In general, all the configurations can be found in `config/` folder. most of the configuration parameters related to Garnet can be found in the following files and folders 23 | - `configs/common/Options.py`: general configration parameters (i.e. number CPUs, directories, memory size, ... etc.) 24 | - `configs/network/Network.py`: network configuration parameters (i.e. router & link latency, routing algorithm, topology... etc.) 25 | - `configs/topologies/`: topologies are defined here 26 | - `configs/example/garnet_synth_traffic.py`: template file, include configuration parameters related to a single run (i.e. traffic pattern type, injection rate, number of simulation cycles, ... etc.) 27 | 28 | Change any default value of any configuration parameter directly in the related configuration file or change it from command line as follows: `./build/Garnet_standalone/gem5.debug configs/example/garnet_synth_traffic.py [--configuration_name=value]`, e.g. 29 | 30 | ```sh 31 | ./build/Garnet_standalone/gem5.debug configs/example/garnet_synth_traffic.py \ 32 | --ruby --ruby-clock=1GHz \ 33 | --sys-clock=1GHz \ 34 | --mem-type=SimpleMemory \ 35 | --num-cpus=16 \ 36 | --num-dirs=16 \ 37 | --synthetic=bit_complement --injectionrate=0.200 --sim-cycles=100000 --num-packets-max=30000 --inj-vnet=2 \ 38 | --network=garnet --topology=Mesh_XY --mesh-rows=4 --vcs-per-vnet=2 --link-latency=1 --router-latency=1 \ 39 | --routing-algorithm=1 40 | ``` 41 | 42 | ### system configuration 43 | - [--num-cpus=16] number of CPU = 16, the number of source (injection) nodes in the network 44 | - [--num-dirs=16] number of cache directories = 16, the number of destination (ejection) nodes in the network 45 | - [--network=garnet] configure the network as garnet network 46 | - [--topology=Mesh_XY] use `Mesh_XY.py` topology in `configs/topologies/` 47 | - [--mesh-rows=4] number of rows in the network layout 48 | 49 | ### network configuration 50 | - [--router-latency] number of pipeline stages in the garnet router. Has to be >= 1. Can be over-ridden on a per router basis in the topology file 51 | - [--link-latency] latency of each link in the network. Has to be >= 1. Can be over-ridden on a per link basis in the topology file 52 | - [--vcs-per-vnet=2] number of VCs per vitrual network 53 | - [--link-width-bits] width in bits for all links inside the garnet network. Default = 128. 54 | 55 | ### traffic injecion 56 | - [--sim-cycles=100000] run simulation for 100000 cycles 57 | - [--synthetic=bit_complement] traffic pattern: ‘uniform_random’, ‘tornado’, ‘bit_complement’, ‘bit_reverse’, ‘bit_rotation’, ‘neighbor’, ‘shuffle’, and ‘transpose’ 58 | - [--injectionrate=0.200] injection rate 59 | - [--num-packets-max] maximum number of packets to be injected by each cpu node. Default value is -1 (keep injecting till sim-cycles) 60 | - [--single-sender-id] only inject from this sender. To send from all nodes, set to -1 61 | - [--single-dest-id] only send to this destination. To send to all destinations as specified by the synthetic traffic pattern, set to -1 62 | - [--inj-vnet] only inject in this vnet (0, 1 or 2). 0 and 1 are 1-flit, 2 is 5-flit. Set to -1 to inject randomly in all vnets 63 | 64 | ## Garnet source file 65 | Garnet is written in C++ and uses python to pass the configuration parameters to the C++ objects. All the files are available in `src/mem/ruby/network/garnet/`. In this folder, the NoC and the router micro-architecture is implemented 66 | 67 | Scons is a modern software construct tool (similar to Make); it's scripts are written in python. In gem5, any folder that includes a Scons script file will be compiled into gem5 according to the scripts content 68 | 69 | Take the Scons script in Garnet folder as an example. This script is located in `src/mem/ruby/network/garnet/Sconscript`. The script is strightforward: to add source file, say `x.cc`, simple add `Source('x.cpp')` in the Scons script 70 | 71 | ## Debug tips 72 | ### Inject one (or more fixed number of) packet(s) into the network from a specific source to a specific destination 73 | 74 | This can be done by the following command-line options 75 | ```sh 76 | --num-packets-max= \ 77 | --single-sender-id= \ 78 | --single-dest-id= 79 | ``` 80 | e.g. 81 | ```sh 82 | ./build/Garnet_standalone/gem5.debug configs/example/garnet_synth_traffic.py \ 83 | --ruby --ruby-clock=1GHz \ 84 | --sys-clock=1GHz \ 85 | --mem-type=SimpleMemory \ 86 | --num-cpus=16 \ 87 | --num-dirs=16 \ 88 | --synthetic=bit_complement --injectionrate=0.200 --sim-cycles=100000 --inj-vnet=2 \ 89 | --network=garnet --topology=Mesh_XY --mesh-rows=4 --vcs-per-vnet=2 --link-latency=1 --router-latency=1 \ 90 | --routing-algorithm=1 \ 91 | --num-packets-max=3 --single-sender-id=1 --single-dest-id=7 92 | ``` 93 | 94 | ### Print debug messages 95 | Debug messages throughout the Garnet code are in the following format: 96 | `DPRINTF(RubyNetwork, "Debug message is here and is printing value %d", variable)` 97 | 98 | We can add our own debug messages across the code to track the progress of a flit. To print the debug messages, add `--debug-flags=RubyNetwork` as follows: 99 | 100 | ```sh 101 | ./build/Garnet_standalone/gem5.debug --debug-flags=RubyNetwork configs/example/garnet_synth_traffic.py \ 102 | --ruby --ruby-clock=1GHz \ 103 | --sys-clock=1GHz \ 104 | --mem-type=SimpleMemory \ 105 | --num-cpus=16 \ 106 | --num-dirs=16 \ 107 | --synthetic=bit_complement --injectionrate=0.200 --sim-cycles=100000 --inj-vnet=2 \ 108 | --network=garnet --topology=Mesh_XY --mesh-rows=4 --vcs-per-vnet=2 --link-latency=1 --router-latency=1 \ 109 | --routing-algorithm=1 \ 110 | --num-packets-max=1 --single-sender-id=1 --single-dest-id=2 111 | ``` 112 | 113 | ## Useful scripts 114 | - [build_debug.sh](./my_scripts/build_debug.sh): build Garnet_standalone (debug version) 115 | - [build_opt.sh](./my_scripts/build_opt.sh): build Garnet_standalone (opt version) 116 | - [extract_network_stats.sh](./my_scripts/extract_network_stats.sh) extract network stats 117 | 118 | ## Advanced labs 119 | Acknowledgment: the labs come from Tushar Krishna, School of ECE, Georgia Institute of Technology, Interconnection Networks for High-Performance Systems (ECE 6115 / CS 8803 - ICN), Spring 2020 120 | - [lab1. Running Synthetic Traffic through a Network](./ICN_lab/lab1/) 121 | - [lab2. Topology Comparison](./ICN_lab/lab2/) 122 | -------------------------------------------------------------------------------- /ICN_lab/lab2/FlattenedButterfly.py: -------------------------------------------------------------------------------- 1 | from m5.params import * 2 | from m5.objects import * 3 | 4 | from common import FileSystemConfig 5 | 6 | from topologies.BaseTopology import SimpleTopology 7 | 8 | class FlattenedButterfly(SimpleTopology): 9 | description = 'FlattenedButterfly' 10 | 11 | def __init__(self, controllers): 12 | self.nodes = controllers 13 | 14 | # Makes a generic FlattenedButterfly assuming an equalt number of cache and 15 | # directory cntrls 16 | # Since there will be links of unequal length, therefore thus each link will 17 | # assign an increasing number of latency based on the distance from it's neighour 18 | 19 | def makeTopology(self, options, network, IntLink, ExtLink, Router): 20 | nodes = self.nodes 21 | 22 | # These parameters will be set form the command line 23 | link_latency = options.link_latency # used by simple and garnet 24 | router_latency = options.router_latency # only used by garnet 25 | 26 | cpu_per_router = 1 # one traffic injector per router 27 | num_routers = int(options.num_cpus / cpu_per_router) 28 | num_rows = options.mesh_rows 29 | 30 | # There must be an evenly divisible number of cntrls to routers 31 | # Also, obviously the number of rows must be <= the number of routers 32 | cntrls_per_router, remainder = divmod(len(nodes), num_routers) 33 | assert num_rows > 0 and num_rows <= num_routers 34 | num_columns = int(num_routers / num_rows) 35 | assert num_columns * num_rows == num_routers 36 | 37 | # Create the router in the FlattenedButterfly 38 | routers = [ 39 | Router(router_id=i, latency=router_latency) 40 | for i in range(num_routers) 41 | ] 42 | network.routers = routers 43 | 44 | # print('num_columns: %d' %(num_columns)) 45 | # print('num_rows: %d' %(num_rows)) 46 | 47 | # link counter to set unique link ids 48 | link_count = 0 49 | 50 | # Add all but the remainder nodes to the list of nodes to be uniformly 51 | # distributed across the network 52 | network_nodes = [] 53 | remainder_nodes = [] 54 | for node_index in range(len(nodes)): 55 | if node_index < (len(nodes) - remainder): 56 | network_nodes.append(nodes[node_index]) 57 | else: 58 | remainder_nodes.append(nodes[node_index]) 59 | 60 | # copy from Mesh_XY.py 61 | # Connect each node to the appropriate router 62 | ext_links = [] 63 | for (i, n) in enumerate(network_nodes): 64 | cntrl_level, router_id = divmod(i, num_routers) 65 | assert cntrl_level < cntrls_per_router 66 | ext_links.append( 67 | ExtLink( 68 | link_id=link_count, 69 | ext_node=n, 70 | int_node=routers[router_id], 71 | latency=link_latency, 72 | ) 73 | ) 74 | link_count += 1 75 | 76 | # Connect the remainding nodes to router 0. These should only be 77 | # DMA nodes. 78 | for (i, node) in enumerate(remainder_nodes): 79 | assert node.type == "DMA_Controller" 80 | assert i < remainder 81 | ext_links.append( 82 | ExtLink( 83 | link_id=link_count, 84 | ext_node=node, 85 | int_node=routers[0], 86 | latency=link_latency, 87 | ) 88 | ) 89 | link_count += 1 90 | network.ext_links = ext_links 91 | 92 | # create the FlattenedButterfly links. First row (east-west) links then column (north-south) links 93 | int_links = [] 94 | 95 | # print('creating east(out)-west(in) links:') 96 | for row in range(num_rows): 97 | for col in range(num_columns): 98 | west_in = col + (row * num_columns) 99 | for i in range((west_in + 1), (row * num_columns + num_columns)): 100 | assert(i < (row * num_columns + num_columns)) 101 | east_out = i 102 | # print("router(" + str(east_out) + ") -> " + "router(" + str(west_in) + ")") 103 | int_links.append(IntLink(link_id=link_count, 104 | src_node=routers[east_out], 105 | dst_node=routers[west_in], 106 | src_outport="East", 107 | dst_inport="West", 108 | latency=1, 109 | weight=1)) 110 | link_count += 1 111 | 112 | # print('creating west(out)-east(in) links:') 113 | for row in range(num_rows): 114 | for col in range(num_columns): 115 | west_out = col + (row * num_columns) 116 | for i in range((west_out + 1), (row * num_columns + num_columns)): 117 | assert(i < (row * num_columns + num_columns)) 118 | east_in = i 119 | # print("router(" + str(west_out) + ") -> " + "router(" + str(east_in) + ")") 120 | int_links.append(IntLink(link_id=link_count, 121 | src_node=routers[west_out], 122 | dst_node=routers[east_in], 123 | src_outport="West", 124 | dst_inport="East", 125 | latency=1, 126 | weight=1)) 127 | link_count += 1 128 | 129 | # print('creating north(out)-south(in) links:') 130 | for col in range(num_columns): 131 | for row in range(num_rows): 132 | north_out = col + (row * num_columns) 133 | for i in range(col, north_out, num_columns): 134 | south_in = i 135 | # print("router(" + str(north_out) + ") -> " + "router(" + str(south_in) + ")") 136 | int_links.append(IntLink(link_id=link_count, 137 | src_node=routers[north_out], 138 | dst_node=routers[south_in], 139 | src_outport="North", 140 | dst_inport="South", 141 | latency=1, 142 | weight=2)) 143 | link_count += 1 144 | 145 | # print('creating south(out)-north(in) links:') 146 | for col in range(num_columns): 147 | for row in range(num_rows): 148 | north_in = col + (row * num_columns) 149 | for i in range(col, north_in, num_columns): 150 | south_out = i 151 | # print("router(" + str(south_out) + ") -> " + "router(" + str(north_in) + ")") 152 | int_links.append(IntLink(link_id=link_count, 153 | src_node=routers[south_out], 154 | dst_node=routers[north_in], 155 | src_outport="South", 156 | dst_inport="North", 157 | latency=1, 158 | weight=2)) 159 | link_count += 1 160 | network.int_links = int_links 161 | 162 | # Register nodes with filesystem 163 | def registerTopology(self, options): 164 | for i in range(options.num_cpus): 165 | FileSystemConfig.register_node( 166 | [i], MemorySize(options.mem_size) // options.num_cpus, i 167 | ) --------------------------------------------------------------------------------