【OPEN IC】之emuMonitor:硬件仿真器palladium/zebu信息檢索工具

最新工具手冊請參照 https://github.com/bytedance/emuMonitor/blob/master/docs/emuMonitor_user_manual.pdf

 

一、簡介

硬件仿真器(hardware emulator)是爲了克服芯片設計中軟件仿真和FPGA原型驗證的不足,通過廠商指定的流程,將RTL映射到各自的硬件仿真平臺上,從而在支持豐富debug功能的前提下實現了芯片的硬件化仿真。
當前比較主流的硬件仿真器有cadence的palladium和synopsys的zebu,實現方式有定製化cpu和FPGA兩種方式,各自的使用流程上也有一些差異。
 
硬件仿真器價格昂貴,整套價格以千萬計,一般只有較具經濟實力的超大規模集成電路設計廠商纔會購買。爲了更好地使用,需要蒐集和分析硬件仿真器的使用信息,並根據歷史記錄合理配置和分配,以提升其使用效率,降低經濟成本,emuMonitor正是爲滿足這一目的而開發。
下面以palladium爲例,emuMonitor中palladium的信息採集和信息展示流程如下圖所示。
 
可以通過Cadence提供的工具“test_server”獲取palladium的使用信息,其樣式如下。
Emulator: BD02_emu Hardware: Palladium Z1 Configmgr:
V21.02.201.s005System Status: ONLINE
Rack 0 has 2 clusters
Cluster 0 has 6 logic drawers CCD: ONLINE
Logic drawer 0 has 8 domains Logic drawer: ONLINE
Domain Owner PID T-Pod Design ElapTime ReservedKey
0.0 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.1 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.2 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.3 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.4 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.5 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.6 <user> n212-207-138:215761 -- -- emu_top 00:44:06 --
0.7 <user> n212-207-138:215761 -- -- emu_top 00:44:06 -- ...
 
解析palladium使用信息,將其保存爲python的字典,可以作爲歷史記錄,同時可以根據每個Domain有無使用統計實時使用率信息。
最後將這些信息,在圖形工具上結構化展示出來即可,用戶可以方便查找。
 
 

二、環境依賴

2.1 操作系統依賴

emuMonitor的開發和測試操作系統爲 CentOS Linux release 7.9.2009 (Core),這也是IC設計常用的操作系統版本之一。
centos6/centos7/centos8,及對應的redhat版本應該都可以運行,主要的潛在風險在於系統庫版本差異可能會影響部分組件的運行。
建議在centos7.9操作系統下使用。
 

2.2 python版本依賴

emuMonitor基於python開發,其開發和測試的python版本爲 python3.8.8,推薦使用 Anaconda3-2021.05以解決庫依賴問題。
不同版本的python可能會有python庫版本問題,按照系統要求安裝對應版本的python庫即可解決。
 

2.3 使用環境依賴

使用emuMonitor是,使用環境主要需要滿足如下依賴:
  • For palladium:環境中已安裝cadence的工具test_server,且執行test_server的機器允許用戶ssh登錄。
  • For zebu:環境中已安裝synopsys的工具zRscManager,且可進行sysstat與sysreport查詢。
 
 

三、工具安裝及配置

3.1 工具下載

emuMonitor的github路徑位於 https://github.com/bytedance/emuMonitor。
 
可以採用 “git clone https://github.com/bytedance/emuMonitor.git”的方式拉取源代碼。
[liyanqing@personal_pc test]$ git clone https://github.com/bytedance/emuMonitor.git
Cloning into 'emuMonitor'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 38 (delta 2), reused 38 (delta 2), pack-reused 0
Unpacking objects: 100% (38/38), done.
 
也可以在emuMonitor的github界面上,Code -> Download ZIP的方式拉取代碼包。
 

3.2 工具安裝

工具安裝之前,首先參照第二章“環境依賴”滿足emuMonitor的環境依賴關係。
安裝包下的文件和目錄如下。
[liyanqing.1987@ic-admin2 tools]$ cd emuMonitor-master/
[liyanqing.1987@ic-admin2 emuMonitor-master]$ ls bin
common config db docs install.py lib LICENSE README requirements.txt test tools
 
確認python版本正確,並基於安裝包中的requirements.txt安裝python依賴庫。(python庫安裝一般需要使用root賬號)
[root@ic-admin2 emuMonitor-master]# pip3 install -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting matplotlib==3.3.4 (from -r requirements.txt (line 1))
Downloading https://bytedpypi.byted.org/packages/pypi/matplotlib/matplotlib-3.3.4-cp36-cp36m-manylinux1_x86_64.whl (11.5MB) 100% |████████████████████████████████| 11.5MB 69.3MB/s ...
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.1->matplotlib==3.3.4->-r requirements.txt (line 1))
Installing collected packages: kiwisolver, cycler, pyparsing, pillow, matplotlib, sip, PyQt5, ptyprocess, pexpect
Running setup.py install for pillow ... done
Successfully installed PyQt5-5.10.1 cycler-0.11.0 kiwisolver-1.3.1 matplotlib-3.3.4 pexpect-4.6.0 pillow-8.4.0 ptyprocess-0.7.0 pyparsing-3.1.1 sip-4.19.8
 
在安裝目錄下,使用命令“python3 install.py”安裝emuMonitor。(公共軟件安裝一般需要使用root賬號,當然,僅本人使用用私人賬號安裝亦可)
[root@ic-admin2 emuMonitor-master]# python3 install.py
>>> Check python version.
    Required python version : (3, 8)
    Current python version : (3, 8)
 
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/bin/pmonitor".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/bin/psample".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/bin/zmonitor".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/tools/patch".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/test/pmonitor_test".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/test/psample_test".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/test/zmonitor_test".
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/test/gen_test_db".
>>> Generate config file "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/config.py".
>>> Generate config file "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/test/test_config/test_config.py".
 
Done, Please enjoy it.
 

3.3 工具配置

安裝目錄下主要的配置文件爲config/config.py,用於配置工具的一些基本設置和驗證規則。
安裝後默認配置如下,大多數都需要重新配置。
######## For Palladium ########
# Specify the database directory.
db_path = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/db"
 
# Specify test_server path for Palladium Z1.
Z1_test_server = ""
 
# Specify test_server path for Palladium Z2.
Z2_test_server = ""
 
# Specify test_server execute hosts for Palladium Z1, make sure you can ssh the host without password.
Z1_test_server_host = ""
 
# Specify test_server execute hosts for Palladium Z2, make sure you can ssh the host without password.
Z2_test_server_host = ""
 
# Specify project list file.
project_list_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_list"
 
# Specify project & execute_host relationship file.
project_execute_host_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_execute_host"
 
# Specify project & user relationship file.
project_user_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_user"
 
# Specify which are the primary factors when getting project information, it could be one or serveral items between "user/execute_host/submit_host".
project_primary_factors = "user execute_host"
 
 
######## For Zebu ########
# Specify zRscManager path for Zebu.
zRscManager = ""
 
# Specify zebu system directory.
ZEBU_SYSTEM_DIR = ""
 
# Specify check status command.
check_status_command = zRscManager + " -nc -sysstat " + ZEBU_SYSTEM_DIR + " -pid ; rm ZEBU_GLOBAL_SYSTEM_DIR_global_mngt.db"
 
# Specify check report command.
check_report_command = zRscManager + " -nc -sysreport " + ZEBU_SYSTEM_DIR + " -from FROMDATE -to TODATE -noheader -fields 'opendate, closedate, modulesList, user, pid, pc' -nofilter ; rm ZEBU_GLOBAL_SYSTEM_DIR_global_mngt.db"
 
db_path : 指定數據路徑,默認在palladiumMonitor安裝目錄下的db目錄。
Z1_test_server :爲Palladium Z1指定工具test_server的路徑,一般用vxe工具下的test_server。
Z2_test_server :爲Palladium Z2指定工具test_server的路徑,一般用wxe工具下的test_server。
Z1_test_server_host :指定在哪臺機器上執行test_server命令,會ssh上去獲取palladium Z1的使用信息。
Z2_test_server_host :指定在哪臺機器上執行test_server命令,會ssh上去獲取palladium Z2的使用信息。
project_list_file :指定project的配置文件路徑,用於pmonitor COST頁費用分攤。
project_submit_host_file :指定palladium submit_host跟project對應關係的配置文件路徑,用於pmonitor COST頁費用分攤。
project_user_file :指定palladium user跟project對應關係的配置文件路徑,用於pmonitor COST頁費用分攤。
project_primary_factors :palladium在不同project上的項目分攤,優先依賴那些因素分攤,默認順序是“user execute_host submit_host”,也就是說,先按照palladium的user判斷這個palladium是哪個project使用的,如果不能判斷,再依次按照execute_host和submit_host來判斷。
 
zRscManager:指定工具zRscManager的路徑。
ZEBU_SYSTEM_DIR:指定zebu系統日誌的路徑
check_status_command:sysstat查詢命令。
check_report_command:stsreport查詢命令。
 
一個實用的demo配置如下。
######## For Palladium ########
# Specify the database directory.
db_path = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/db"
 
# Specify test_server path for Palladium Z1.
Z1_test_server = "/ic/software/cadence/vxe/22.04/bin/test_server"
 
# Specify test_server path for Palladium Z2.
Z2_test_server = "/ic/software/cadence/wxe/21.00.s007/bin/test_server"
 
# Specify test_server execute hosts for Palladium Z1, make sure you can ssh the host without password.
Z1_test_server_host = "10.212.207.136"
 
# Specify test_server execute hosts for Palladium Z2, make sure you can ssh the host without password.
Z2_test_server_host = "10.232.129.12"
 
# Specify project list file.
project_list_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_list"
 
# Specify project & execute_host relationship file.
project_execute_host_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_execute_host"
 
# Specify project & user relationship file.
project_user_file = "/ic/data/usr/liyanqing.1987/tools/emuMonitor-master/config/project_user"
 
# Specify which are the primary factors when getting project information, it could be one or serveral items between "user/execute_host/submit_host".
project_primary_factors = "user execute_host"
 
 
######## For Zebu ########
# Specify zRscManager path for Zebu.
zRscManager = "/ic/software/synopsys/zebu/Q-2020.03-SP1-4/bin/zRscManager"
 
# Specify zebu system directory.
ZEBU_SYSTEM_DIR = "/ic/data/usr/emu/common/ZEBU_SYSTEM_DIR"
 
# Specify check status command.
check_status_command = zRscManager + " -nc -sysstat " + ZEBU_SYSTEM_DIR + " -pid ; rm ZEBU_GLOBAL_SYSTEM_DIR_global_mngt.db"
 
# Specify check report command.
check_report_command = zRscManager + " -nc -sysreport " + ZEBU_SYSTEM_DIR + " -from FROMDATE -to TODATE -noheader -fields 'opendate, closedate, modulesList, user, pid, pc' -nofilter ; rm ZEBU_GLOBAL_SYSTEM_DIR_global_mngt.db"
 
 

四、工具使用

emuMonitor包含palladium和zebu兩套監控系統。
palladium:包含psample, pmonitor兩個程序,前者是數據採集程序,用於獲取和存儲palladium使用信息及使用率信息,後者用於展示palladium實時使用信息、歷史使用信息、使用率信息和計費分攤信息。
zebu: 包含zmonitor程序, 用於展示zebu實時使用信息、歷史使用信息和使用率信息。
 

4.1 psample:palladium信息採樣程序

psample位於palladiumMonitor安裝目錄下的bin/psample,安裝後可以直接引用。如果使用環境中配置了modules,則可以通過module load的方式引用psample。
 

4.1.1 幫助信息

psample的幫助信息如下所示。
[liyanqing.1987@n212-206-207 palladiumMonitor]$ bin/psample -h
usage: psample.py [-h] [-H {Z1,Z2}]
 
optional arguments:
    -h, --help show this help message and exit
    -H {Z1,Z2}, --hardware {Z1,Z2}
                Specify hardware, it could be "Z1" or "Z2", default is "Z1".
 
--hareware:指定硬件型號,只能從“Z1”和“Z2”中選擇,默認爲“Z1”。
 

4.1.2 採樣範例

下面給與一個palladium Z1採樣的一個範例。
首先,登錄到可以執行test_server並獲取palladium使用信息的機器,此處爲10.212.207.136。
[liyanqing.1987@personal_pc palladiumMonitor]$ ssh 10.212.207.136
Last login: Thu Mar 16 14:50:38 2023 from n212-206-207
 
執行“psample -H Z1”來採樣。
[liyanqing.1987@n212-207-136 palladiumMonitor]$ bin/psample -H Z1
>>> Sampling palladium usage information ...
    Sample Time : 20230316_145600
    Hardware : Palladium Z1
    Emulator : BD02_emu
    Status : ONLINE
    Utilization : 0.83
 
然後可以在config.db_path下找到utilization記錄和採樣數據。
[ic_admin@n212-207-136 db]$ tail -n 1 Z1/BD02_emu/utilization 20230316
145600 : 0.83
[ic_admin@n212-207-136 db]$ ls Z1/BD02_emu/2023/03/16/
... 100002 120001 140002 145600
 

4.2 pmonitor:palladium信息展示程序

4.2.1 工具載入

pmonitor位於palladiumMonitor安裝目錄下的bin/pmonitor,安裝後可以直接引用。如果使用環境中配置了modules,則可以通過module load的方式引用pmonitor。
[liyanqing.1987@personal_pc palladiumMonitor]$ bin/pmonitor
 

4.2.2 CURRENT頁

CURRENT頁用於展示palladium實時的使用信息。
Hardware和Host設定後,點擊Check按鈕,可以展示palladium的實時使用信息。Hardware只有Z1和Z2可選,選定後,Host會根據config.py中的設置自動填充。
 
palladium實時使用信息如下所示。
 
Rack/Cluster/Logi_Drawer/Domain/Onwer/PID/T-Pod/Design則可以用來對展示的palladium使用信息做篩選。
 

4.2.3 HISTORY頁

HISTORY頁用於加載bsample採樣的歷史使用信息數據。
 
Hardware/Emulator/Year/Month/Day/Time是篩選的6個層級,6者有聯動關係,前者指定後,後者會自動填充可選值。
 

4.2.4 UTILIZATION頁

UTILIZATION頁基於歷史數據統計指定palladium設備的使用率信息。
所謂使用率信息,對於瞬時值而言,是指 已用domain數目/總domain數目;對於統計值而言,是累計瞬時使用率的平均值。
 
使用率摘取,需要指定Hardware/Emulator/Start_Date/End_Date幾個維度。
Start_Date默認爲一個月前,End_Date默認爲今天,兩者的調節範圍均爲 10年前 - 今天。
選定Hardware後,會自動填充可選的Emulator項,並出現使用率統計信息。
 
其中每天的使用率,是基於當天多次採樣的使用率算出來的日均值。最上部的“Average Utilization”值,則是所選日期的所有采樣使用率算出來的均值。
 

4.2.5 COST頁面

COST頁面根據用戶定義的計費分攤信息, 包括項目信息, 項目與host對應關係信息, 項目與user對應關係信息等, 顯示項目計費分攤的詳細信息。
Start_Date默認爲一個月前,End_Date默認爲今天,兩者的調節範圍均爲 10年前 - 今天。
 
表格中展示每個palladium emulator在統計時間段內的被採集到的次數,以及每個項目針對此emulator採樣次數佔總採樣次數的比例。需要說明的是,有些emulator的使用信息無法根據用戶的config/project_***配置文件獲取project信息,這樣的使用時長都被歸到了“others”項目中,理論上這種時長都需要被分配至已知項目才合理,否則無法分攤。
計費分攤信息支持export當前的表格爲一個excel文檔:
 
Excel的內容和COST頁面單元格內容一致。
 

4.3 zmonitor: zebu信息展示程序

4.3.1 工具載入

用戶在命令行輸入zmonitor就可以啓動工具。
[liyanqing.1987@personal_pc ~]$>zmonitor
 

4.3.2 CURRENT頁

CURRENT頁顯示當前zebu各module的使用情況和任務信息。
 
用戶可以在界面上方的篩選欄進行條件篩選後,顯示篩選後的信息, 也可以點擊Refresh刷新實時狀態信息。
 

4.3.3 HISTORY頁

History頁用於對歷史使用記錄進行查詢。用戶可以查詢到在過去任何一個時間段zebu的使用情況。
支持用戶通過指定過濾條件進行篩選,得到自己期望的信息。
 

4.3.4 UTILIZATION頁

UTILIZATION頁顯示指定日期時間範圍內的使用率信息,即在一天內zebu被使用的時間除以總時間。
默認會顯示近一個月整個zebu服務器的使用率信息,計算方式爲各個module使用率之和/module數量。
 
同時也支持用戶選擇指定的module及日期,點擊Search button生成對應的使用率折線圖。
 
 

五、技術支持

本工具爲開源工具,由開源社區維護,可以提供如下類型的技術支持:
  • 部署和使用技術指導。
  • 接收bug反饋並修復。
  • 接收功能修改建議。(需審覈和排期)
 
獲取技術支持的方式包括:
  • 通過Contact郵箱聯繫開發者。
  • 加入官方技術支持羣。
 
 

附錄

附1. 變更歷史

日期
版本
變更描述
2023.9.4
1.0
發佈第一個正式release版本
 
 
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章