###### tags: `ISPD2024` # NTHU-Route 2.0 (A Fast and Robust Detailed-Routability-Driven Global Router) ## A、 環境 ### 1. Experimental Machines - Run on ic56 or ic53 - Evaluate on ic21, ic22, ic51 (To use Innovus) ### 2. Build Tools - To build our global router - GCC >= 9.3.0 (Only available on ic21, ic22, ic51, and ic55 in CAD server) - To build TritonRoute-WXL - CMake ver. >= ? (I built it on ic51) - GCC >= 9.3.0 - To build the triton route preprocessing - python3 (`alias python3 /usr/local/bin/python3.9`)(ic51) ### 3. Pre-requisite Library - Boost >= 1.77.0 (盡量用1.77.0) ### 4. 我的資料夾結構 ![image](https://hackmd.io/_uploads/B1uttco4T.png) ![image](https://hackmd.io/_uploads/HJo3jw246.png) <br> ## B、 怎麼跑? ### **1. 解壓縮NTHU route 2.0** 資料夾架構會長這樣 ![image](https://hackmd.io/_uploads/ryiSPE54T.png) - Code 有兩個版本 1. ASP-DAC 2024 版 - 與投稿 ASP-DAC 2024 論文 consistent 2. 論文版 - 與論文 consistent - 將 Thesis/src/router/MM_mazeroute.cpp 中的 compiler flag ```#GAMER``` 打開可得 *Parallelized* 版本,註解掉可得 *Sequential* 版本 (與 ICCAD 2023 投稿論文 consistent) ### - ASP-DAC 2024 版本和 Thesis 版本 (*Sequential*) 差異 - 2D Capacity Reduction 用隔壁兩個 Gcells congestion 平均來打折 edge capacity. - Maze routing 找到 sink 不會 break. - Capacity Reduction 參數不一樣 <br> ### **2. 下載Boost** 請參考[此篇](https://hackmd.io/@UbF8C-LxTnWp5f9RWqynYw/ryeLvX5Vp) <br> ### 3. 利用Triton route來產生initial congestion map以及netlist - 進入`Thesis/TritonRoute-WXL/build/gen_cmap_netlist.py` - 改成以下 ```python3= import subprocess import os import sys testcase = sys.argv[1] print('testcase= ', testcase) benchmark_path = "/users/student/mr111/mfhsieh22/ISPD2024/benchmarks/nangate45" print(f"Running {testcase}...") # year, caseNum = testcase.split('_') dir_path = f"{benchmark_path}/triton_preprocess/{testcase}" if not os.path.exists(dir_path): os.makedirs(dir_path) with open(f"{dir_path}/param.txt", 'w') as f: f.write(f"lef:{benchmark_path}/lef/Nangate.lef" + '\n') f.write(f"def:{benchmark_path}/def/{testcase}.def" + '\n') f.write(f"threads:128" + '\n') f.write(f"cmap_file:{dir_path}/cmap.txt" + '\n') f.write(f"netlist_file:{dir_path}/netlist.txt" + '\n') subprocess.run([f"/users/student/mr111/mfhsieh22/ISPD2024/NTHU-route-2.0/MFHsieh/Thesis/TritonRoute-WXL/build/TritonRoute", f"{dir_path}/param.txt"]) ``` <br> ### **4. 更改code的內容 (以Thesis為例)** 1. **Thesis/src/Makefile** - 更改`BoostLibDir`以及`BoostIncDir`為自己boost的路徑 2. **Thesis/src/grab/parser.cpp** - 更改`netlist_file`為自己TritonRoute的initial congestion map的路徑 ![image](https://hackmd.io/_uploads/ryPgbkZBT.png) - 更改`cmap_file`為自己TritonRoute的pin access information的路徑 ![image](https://hackmd.io/_uploads/BkjzZJZBa.png) 3. **Thesis/src/router/route.cpp** 4. - 將`TESTCASE_NAME = getTestCaseName(ap.get_lef_def()[0]);`更改為`TESTCASE_NAME = getTestCaseName(ap.get_lef_def()[1]);` <br> ### **5. 創立/benchmarks/nangate45/param資料夾** - 按照`param_{TESTCASE_NAME}.txt`的規則來創建每一個benchmarks的param.txt - 內容: ```txt= rcong_min:0.7 rcong_diff:0.3 rcongV_min:0.5 rcongV_diff:0.3 rcongH_min:0.5 rcongH_diff:0.3 rcongNonZeroV_min:0.5 rcongNonZeroV_diff:0.3 rcongNonZeroH_min:0.5 rcongNonZeroH_diff:0.3 init_reduct:0.8 ``` ![image](https://hackmd.io/_uploads/rkdiWjbH6.png) <br> ### **6. 建立環境變數** 1. **創建~/.cshrc (因為是tcsh,但是只有在mobaxterm才能source它,不知道為甚麼)** ```shell= setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:"/usr/local/lib" setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:"/users/student/mr111/mfhsieh22/boost_1_77_0/stage/lib/" if ( $?CPLUS_INCLUDE_PATH ) then setenv CPLUS_INCLUDE_PATH "${CPLUS_INCLUDE_PATH}:/users/student/mr111/mfhsieh22/boost_1_77_0" else setenv CPLUS_INCLUDE_PATH "/users/student/mr111/mfhsieh22/boost_1_77_0" endif ``` <br> ### **7. To build the program** 1. 在Thesis/src中執行 ```makefile= make clean make -j <number of core> ``` - 若不specify number of core,default=1 - 執行檔 ```route``` 生出來會在 Thesis/bin/ <br> ### **8. To run the executable** #### **1. To generate global routing results** - In Thesis/bin/: ``` ./route --input test --def path/to/input.def --lef path/to/input.lef --guide path/to/guide --param path/to/parameter_file ``` - Input 有兩個: - ispd1X_testX.input.def - ispd1X_testX.input.lef - Output 有一個 (Global routing guide) - ispd1X_testX.input.guide - ```--inptu test``` 可能可以不用打,但我沒改(後面解釋) - 也可以使用 ```run.py```, ```run_tune.py```, and ```runAll.py``` 來跑,會比較方便。(需要 Python3) <br> #### **2. To generate detail routing results ([github](https://github.com/ABKGroup/TritonRoute-WXL))** - In Thesis/TritonRoute-WXL/build/: ``` ./run_tune.py $testcase_name ``` - ```$testcase_name``` can be: 18_5, 18_8, 18_10, 19_7, 19_8, 19_9, 18_5m, 18_8m, 18_10m, 19_7m, 19_8m and 19_9m ### **9. How to Evaluate** - 要在可以跑 Innovus 的機器上跑 - In Thesis/bin/: ``` ./eval_tune.py $testcase_name ``` - 可參考 ```eval_tune.py``` 內的寫法 - 需要有 [ICCAD 2019](http://iccad-contest.org/2019/problems.html) 比賽提供的 evaluation script. (路徑記得改) <br> ## C、Future Works ### Major - 自動化調參數 (e.g., ML), 目前每個 testcase 的參數寫在 ```bin/``` 資料夾下, 例如 $ispd18\_test5$ 的 parameter file 是 ```param_18_5.txt``` - 不同參數對結果影響很大,可能可以調出更好的參數(手動(參考 bin/tune.py) or 自動(ML)) - 目前每個 testcase 的每條 Gedge or Gcell 打折用一樣參數,可能可以不同 - GAMER 可以嘗試做在 GPU 上 - 可參考 src/router/sum.cpp 裡面有 intrarow parallelism 實作(沒有採用) - Layer assignment 的 DP update 可能可以換成 CUGR 2.0 的 complexity 較低的演算法 - 但我實作出來沒有比較快,可能是我寫不好,可參考 Layerassignment.cpp 裡的 #DAC2023 compiler flag. - 跑出來結果非 *metal5* testcases 會不一樣,我不知道為什麼,可能是我實作錯,我已盡量讓它 behavior 和 COLA 一樣. - 和 Innovus 比較,觀察 Innovus 是不是可以都做出無 DRC - 加速其他 bottleneck ### Minor - 跑 GR command 裡的 ```--input test``` 可能可以省略。原本的 layer assignment 會先寫一個 ```test.input``` file 再讀進來再轉後成最後的 guide 寫檔。我把這步簡化只寫一次檔,所以應該不用 ```--input test``` 的 option. - 原本 GARY 用 CUGR 的 Rsyn 來 parse .lef 和 .def 檔案,但現在直接用 TritonRoute-WXL 的 inputs,所以有關 Rsyn 的 ```database```, ```grDatabase``` 應都不需要。但 code 還是會跑 Rsyn. - 目前 code 還是有用到 ```database``` 和 ```grDatabase``` 的東西。但都是一些常數,例如 layer direction, gCellStep 等等。 - 將 TritonRoute-WXL 的 input parsing 寫進 code, 而不是像現在這樣讀檔。 - 整理 code, 現在 code base 裡可能有滿多不會用到的東西。 - 可能可以考慮調 src/router/parameter.cpp 裡的參數,例如讓 maze routing 不要做這麽多 iteratinos 節省時間 - 可以考慮調 *Parallelized* 版本 (使用 GAMER 加速) 的 capacity reduction 參數,分數可能可以更好,且可以弄到沒有 DRC,我沒有調,目前用與投稿 ICCAD 2023 版本相同參數。 <br> ## D、ISPD Related Work ### 1. 怎麼快速地跑NTHU Route 2.0 - 進入`/NTHU_Route-2.0/MFHsieh/Thesis/bin`,並且執行以下指令: ```shell= ./route.sh ``` <br> ### 2. 怎麼跑ISPD2024的evaluation script? #### (a) 先跑makefile #### (b) 修改`evaluation.sh` ```shell= data_list=("ariane133_51") input_path="/users/student/mr111/mfhsieh22/ISPD24/benchmarks/nangate45/Simple_inputs" output_path="/users/student/mr111/mfhsieh22/ISPD24/benchmarks/nangate45/guide" for data in "${data_list[@]}" do # run the whole framework echo "data: $data" ./evaluator $input_path/$data.cap $input_path/$data.net $output_path/$data/$data.PR_output done ``` #### (c) 執行shell script ```linux= ./evaluation.sh ``` <br> ### 3. 怎麼修改NTHU Route的code #### (a) 不要讓guide的Gcell有乘上Step ``` * route.cpp -> Layer_assignment(ap.get_guide()) -> generate_all_output(fout) -> generate_output(i, fout) -> rectToGuide(x1, y1, x2, y2, layer) (This way perhaps for rectToGuide) -> viaToGuide(int x, int y, int layer1, int layer2) ``` ![image](https://hackmd.io/_uploads/SyP-gRa4p.png) ![image](https://hackmd.io/_uploads/S1f01C6V6.png) ![image](https://hackmd.io/_uploads/rJXkl0aEa.png) ![image](https://hackmd.io/_uploads/B1mlgRaE6.png) <br> ### 3. 將很粗的net分割成1單位 **(i) 要先找出每一個metal layer的direction** * 可以從.cap檔來得到(0: horizontal, 1:vertical) * ariane133_51 * 0 1 0 1 0 1 0 1 0 1 * ariane133_68 * 0 1 0 1 0 1 0 1 0 1 * bsg_chip * 0 1 0 1 0 1 0 1 0 1 * mempool_group * 0 1 0 1 0 1 0 1 0 1 * mempool_tile * 0 1 0 1 0 1 0 1 0 1 * nvdla.cap * 0 1 0 1 0 1 0 1 0 1