【OPEN IC】之licenseMonitor:EDA license信息檢索工具

一、簡介

EDA,electronic design automation,即電子設計自動化,是指利用計算機輔助設計軟件,來完成超大規模集成電路芯片的功能設計、綜合、驗證、物理設計等流程的設計方式。EDA位於集成電路產業的最上游,其成本在集成電路設計總成本中佔有較高的比重,全流程的EDA工具價格常常達到千萬甚至過億的水平,出於高效利用和節省成本的考慮,需要實時瞭解EDA工具的license使用情況。
licenseMonitor工具是一款ByteDance開源的EDA license信息實時檢索系統,對IC設計降本增效具有重要的意義。
 

1.1 主要用途

IC工程師是EDA license的主要用戶,其主要的EDA license信息獲取需求有如下幾種:
  1. 某個license feature是否存在。
  2. 某個license feature總數量是多少。
  3. 某個license feature當前被哪些人用了。
  4. 某個license feature的過期日期是哪天。
 
對IC環境管理員而言,還有一些額外的EDA license實時信息需求。
  1. EDA license server及vendor daemon的狀態。(故障警示)
  2. 全量license feature的數量信息。(總量,使用量)
  3. 全量license feature的過期信息。(未過期,即將過期,已經過期)
  4. 全量license feature的使用信息。(誰,什麼時間開始,使用了幾個)
 
licenseMonitor就用於這些EDA license實時信息的獲取。
後續,會根據需求增加EDA license歷史數據保存及分析功能。
 

1.2 工作原理

licenseMonitor的工作流程如下圖所示。
 
絕大多數EDA vendor都是使用FlexNet的lmgrd來管理EDA license server,所以可以通過FlexNet的工具lmstat獲取EDA license信息,樣式如下。
License server status: PORT@HOSTNAME 
    License file(s) on HOSTNAME: LICENSE_FILE: 

HOSTNAME: license server UP (MASTER) v11.16.4 

Vendor daemon status (on HOSTNAME): 

    VENDOR_DAEMON: UP v11.16.4 
Feature usage info: 

Users of FEATURE1: (Total of 1 license issued; Total of 0 licenses in use) 
Users of FEATURE2: (Total of 8 licenses issued; Total of 5 licenses in use) 

  "FEATURE2" v2021.06, vendor: VENDOR_DAEMON, expiry: 28-sep-2022 
  vendor_string: UHD:PERM 
  floating license 

    USER1 EXECUTE_HOST /dev/pts/1 14165.SUBMIT_HOST (v2018.06) (HOSTNAME/PORT 482), start Sat 6/18 11:35, 4 licenses 
    USER2 EXECUTE_HOST /dev/pts/2 52926.SUBMIT_HOST (v2018.06) (HOSTNAME/PORT 2845), start Mon 6/20 15:31 
    ... 

Feature Version #licenses Vendor Expires 
_______ _________ _________ ______ ________ 
FEATURE1 1.0 1 VENDOR_DAEMON 28-Sep-2022 
FEATURE2 2021.06 2 VENDOR_DAEMON 28-sep-2022 
... 
----------------------------------------------------------------------------
 
解析license信息,將其保存爲python的字典,數據結構如下。
license_dic = { 
               'license_files': '', 
               'license_server_status': 'UNKNOWN', 
               'license_server_version': '', 
               'vendor_daemon': { vendor_daemon: { 
                                                  'vendor_daemon_status': 'UP', 
                                                  'vendor_daemon_version': '', 
                                                  'feature': {feature: { 
                                                                        'issued': 0, 
                                                                        'in_use': 0, 
                                                                        'in_use_info_string': [], 
                                                                        'in_use_info': [], 
                                                                       }, 
                                                             }, 
                                                 'expires': {feature: { 
                                                                       'version': '', 
                                                                       'license': '', 
                                                                       'vendor': '', 
                                                                       'expires': '', 
                                                                      }, 
                                                            }, 
                                                 }, 
                                 }, 
               } 
 
最後將這些信息,在圖形工具上結構化展示出來即可,用戶可以方便查找。
 
 

二、環境依賴

2.1 操作系統依賴

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

2.2 python版本依賴

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

2.3 使用環境依賴

使用licenseMonitor是,使用環境需要滿足如下依賴:
  • 可以訪問license server,及當前機器跟license server之間的網絡是通的。
  • 環境中配置有正確的LM_LICENSE_FILE設置,lmstat依賴LM_LICENSE_FILE的設置獲取license信息。
 
 

三、工具安裝及配置

3.1 工具下載

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

3.2 工具安裝

工具安裝之前,首先參照第二章“環境依賴”滿足licenseMonitor的環境依賴關係。
安裝包下的文件和目錄如下。
[liyanqing.1987@n212-206-194 tools]$ cd licenseMonitor/ 
[liyanqing.1987@n212-206-194 licenseMonitor]$ ls 
bin common config data docs install.py LICENSE Notice.txt patch README requirements.txt tools
 
確認python版本正確,並基於安裝包中的requirements.txt安裝python依賴庫。
[root@ic-admin1 licenseMonitor]# pip3 install -r requirements.txt 
Looking in indexes: https://bytedpypi.byted.org/simple/ 
Requirement already satisfied: pexpect==4.8.0 in /ic/software/tools/python3/3.8.8/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (4.8.0) 
Requirement already satisfied: ptyprocess>=0.5 in /ic/software/tools/python3/3.8.8/lib/python3.8/site-packages (from pexpect==4.8.0->-r requirements.txt (line 1)) (0.7.0)
 
在安裝目錄下,使用命令“python3 install.py”安裝licenseMonitor。
[root@ic-admin1 licenseMonitor]# python3 install.py 
>>> Check python version. 
    Required python version : (3, 8) 
    Current python version : (3, 8) 

>>> Generate script "/ic/data/usr/liyanqing.1987/tools/licenseMonitor/bin/license_monitor". 
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/licenseMonitor/tools/config_product_feature_relationship". 
>>> Generate script "/ic/data/usr/liyanqing.1987/tools/licenseMonitor/tools/get_product_feature_relationship". 
>>> Generate config file "/ic/data/usr/liyanqing.1987/tools/licenseMonitor/conf/config.py". 

Done, Please enjoy it.
 

3.3 工具配置

安裝目錄下主要的配置文件爲config/config.py,用於配置工具的一些基本設置和驗證規則。
安裝後默認配置如下,大多數都需要重新配置。
# Specify EDA license administrators. (only administrator can execute license_monitor) 
administrators = "" 

# Set configured LM_LICENSE_FILE for administrators. If False, will get LM_LICENSE_FILE from current terminal. 
show_configured_for_admin = True 

# Specify lmstat path, just like "***/bin". 
lmstat_path = "" 

# Specify lmstat bsub command, just like "bsub -q normal -Is". 
lmstat_bsub_command = "" 

# Specify LM_LICENSE_FILE setting. 
LM_LICENSE_FILE = "" 

# Specify EDA license product-feature relationship file, you can get the file with "tools/get_product_feature_relationship.py". 
product_feature_relationship_file = "" 

# The time interval to fresh license information automatically, unit is "second", default is 300 seconds. 
fresh_interval = 300
 
administrators : 指定管理員,管理員纔可以在licenseMonitor中直接讀取配置的全部LM_LICENSE_FILE設置,其他人則只能從當前環境中讀取LM_LICENSE_FILE配置。
show_configred_for_admin :同上一個設置相關,如果是“True”,則administrators可以讀取配置的全部LM_LICENSE_FILE設置,否則只能從當前環境中讀取LM_LICENSE_FILE配置,默認設置爲“True”。
db_path :預留項,指定數據庫(如果有)位置,沒有可以不填。
lmstat_path :必填項,指定lmstat工具的路徑,截止到bin路徑爲止。
lmstat_bsub_command :IC環境中login server一般會禁掉EDA license port,所以不能執行lmstat命令,所以需要bsub到computing server上執行,此處是指定bsub時候的命令。
LM_LICENSE_FILE :指定license server的相關信息,因爲是給EDA license管理員查看,所以此處最好填上公司全部的license server信息。
product_feature_releationship_file :licenseMonitor本身支持根據EDA license的product和feature的映射管理來做feature檢索,前提是存在yaml格式的映射文件,此處就是用來指定這個映射文件的位置,如果沒有可以不填。
fresh_interval :licenseMonitor默認篩選信息的時候會重新獲取EDA license狀態,fresh_interval是控制上次獲取EDA license狀態後,多長時間內篩選信息不需要重新獲取,默認值爲300s,即5分鐘。不要設置的太過頻繁,以防止頻繁連接license server導致程序卡頓。
 
一個實用的demo配置如下。
# Specify EDA license administrators. (only administrator can execute license_monitor) 
administrators = "luchengxin jiangziyi.1108 liyanqing.1987" 

# Set configured LM_LICENSE_FILE for administrators. If False, will get LM_LICENSE_FILE from current terminal. 
show_configured_for_admin = True 

# Specify the database directory. 
db_path = "/ic/software/cad_data/it/licenseMonitor/db" 

# Specify lmstat path. 
lmstat_path = "/ic/software/synopsys/scl/2021.03/linux64/bin" 

# Specify lmstat bsub command. 
lmstat_bsub_command = "bsub -q normal -Is" 

# Specify LM_LICENSE_FILE setting. 
LM_LICENSE_FILE = "\ 1055@ic-lic02:\ ... 27020@ic-lic03" 

# Specify EDA license product-feature relationship file. 
product_feature_relationship_file = "/ic/software/cad_tools/it/lsfMonitor/config/product_feature_relationship.yaml" 

# The time interval to fresh license information automatically, unit is "second", default is 300 seconds. 
fresh_interval = 300
 
 

四、工具使用

4.1 工具載入

licenseMonitor的主程序是license_monitor,位於licenseMonitor安裝目錄下的bin/license_monitor,安裝後可以直接引用。如果使用環境中配置了modules,則可以通過module load的方式引用license_monitor。
[liyanqing.1987@n212-206-194 licenseMonitor]$ bin/license_monitor * 
[2023-01-06 19:08:45] Loading License information, please wait a moment ...
 

4.2 幫助信息

license_monitor的幫助信息如下。
[liyanqing.1987@n212-206-194 licenseMonitor]$ bin/license_monitor -h 
usage: license_monitor.py [-h] [-f FEATURE] [-u USER] [-t {SERVER,FEATURE,EXPIRES,USAGE}] 

optional arguments: 
  -h, --help show this help message and exit 
  -f FEATURE, --feature FEATURE 
        Specify license feature which you want to see on "LICENSE/EXPIRES/USAGE" tab. 
  -u USER, --user USER Specify the user on "USAGE" tab. 
  -t {SERVER,FEATURE,EXPIRES,USAGE}, --tab {SERVER,FEATURE,EXPIRES,USAGE} 
        Specify current tab, default is "FEATURE" tab.
 
--help : 打印幫助信息。
--feature : 指定LICENSE/EXPIRES/USAGE界面中要檢索的faeture,也可以在圖形界面中指定。
--user : 指定USAGE界面中要檢索的user,也可以在圖形界面中指定。
--tab : 指定打開時的tab頁,默認是LICENSE頁。
 

4.3 功能介紹

4.3.1 查看license server及vendor daemon狀態

打開license_monitor圖形界面後,可以在SERVER頁查看相關信息。
 
如果Server_Status標紅,說明這個server狀態異常。
如果Vendor_Status標紅,說明這個vendor daemon異常。
 

4.3.2 查看feature使用情況

打開license_monitor圖形界面後,可以在FEATURE頁查看相關信息。
 
可以按照“ Show”來篩選,有“ ALL”和“ IN_USE”兩個選項,前者會顯示所有的license feature,後者僅顯示在用的license feature。
可以按照“ Server”來篩選。
可以按照“ Vendor”來篩選。
可以按照“ Feature”來篩選,此處的Feature支持模糊檢索。比如輸入“Verdi”,可以精確地檢索到“Verdi”這個license,如果輸入“verdi”,除了“Verdi”外,還可以檢索到所有和verdi相似的license。
如果“In_Use_License”的數目大於0,點擊對應的數值,可以調到USAGE頁查看這個license feature的usage細節,比如“elec_solve_level1”對應的1。
 

4.3.3 查看expires過期日期

打開license_monitor圖形界面後,可以在EXPIRES頁查看相關信息。
 
篩選功能同FEATURE頁相同。
另外,Expires項會按照不同的顏色來顯示feature不同的expires狀態:
  • 黑色:未過期。
  • 紅色:兩週內過期。
  • 灰色:已過期。
 

4.3.4 查看usage使用細節

打開license_monitor圖形界面後,可以在USAGE頁查看相關信息。
 
篩選功能同FEATURE頁類似,不過除了按照server/vendor/feature篩選外,還可以按照submit_host/execute_host/user篩選。
如果某個feature的Start_Time早於3天前,此處會顯示爲紅色,警示使用過久的license。
 

4.3.5 啓動時直接指定feature/user/tab

比如我希望在license_monitor啓動的時候直接查看liulimin對vcs相關的feature的使用情況,可以通過如下命令行指定。
[liyanqing.1987@n212-206-194 licenseMonitor]$ bin/license_monitor -f vcs -u *** -t USAGE * 
[2023-01-28 16:44:26] Loading License information, please wait a moment ...
 

4.3.6 信息刷新

菜單欄 Setup下有“Fresh”和“Period Fresh”兩項,分別用於一次性刷新和週期性刷新。
 
 

五、輔助工具

出於功能擴展的需求,licenseMonitor自帶一些輔助工具。
 

5.1 config_product_feature_relationship

用於解析指定EDA vendor的liense file,自動獲取product和feature的映射關係。
[liyanqing.1987@n212-206-194 tools]$ ./config_product_feature_relationship -h 
usage: config_product_feature_relationship.py [-h] [-v {arm,cadence,empyrean,keysight,magillem,mentor,NOC,synopsys,TSRAM,xilinx}] [-l LICENSE_FILE] [-o OUTPUT_FILE] 

optional arguments: 
  -h, --help show this help message and exit 
  -v {arm,cadence,empyrean,keysight,magillem,mentor,NOC,synopsys,TSRAM,xilinx}, --vendor {arm,cadence,empyrean,keysight,magillem,mentor,NOC,synopsys,TSRAM,xilinx} 
        Specify vendor. 
  -l LICENSE_FILE, --license_file LICENSE_FILE 
        Specify license file. 
  -o OUTPUT_FILE, --output_file OUTPUT_FILE 
        Specify output file.
 
--VENDOR :指定vendor。
--LICENSE_FILE :指定vendor對應的license file。
--OUTPUT_FILE :指定輸出文件路徑。
 

5.2 get_product_feature_relationship

用於解析指定EDA vendor的liense file獲取license feature信息,然後手工配置指定vendor的EDA license product和feature的映射關係,一般是用於license file中沒有明確product信息的情況。
[liyanqing.1987@n212-206-194 tools]$ ./get_product_feature_relationship -h 
usage: get_product_feature_relationship.py [-h] [-v VENDORS [VENDORS ...]] -l LICENSE_FILES [LICENSE_FILES ...] [-o OUTPUT_FILE] 

optional arguments: 
  -h, --help show this help message and exit 
  -v VENDORS [VENDORS ...], --vendors VENDORS [VENDORS ...] 
        Required argument, specify vendor list, must be the same order of license_files. 
  -l LICENSE_FILES [LICENSE_FILES ...], --license_files LICENSE_FILES [LICENSE_FILES ...] 
        Required argument, specify license files. 
  -o OUTPUT_FILE, --output_file OUTPUT_FILE 
        Output file, yaml format.
 
--VENDOR :指定vendor。
--LICENSE_FILE :指定vendor對應的license file。
--OUTPUT_FILE :指定輸出文件路徑。
 
 

附錄

附1. 變更歷史

日期
版本
變更描述
源代碼變更
2023.1.4
1.0
發佈第一個正式release版本
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章