【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版本
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章