背景
pgmRT主要负责将数据以图的形式进行软实时传递,准确的说,一个单元是一个结点,一个结点有出边和入边,进行数据的IO。
安装pgmRT,首先要安装litmusRT、liblitmus和boot1.73
步骤
安装环境
按照文章编译安装LitmusRT遇到的问题和动态知识图谱库DynGEM的学习之库的安装与调试中的相关内容编译安装litmusRT、liblitmus和boot1.73
复制库文件
找到头文件asm/unistd_64_x32.h,复制到/usr/local目录下
这一步不是必须的,但如果后面编译pgm抱错的话,就得进行
(base) root@ubuntu:/home/szc# locate asm/unistd_64_x32.h
(base) root@ubuntu:/home/szc# mkdir /usr/include/asm && chmod 777 /usr/include/asm
(base) root@ubuntu:/home/szc/pgm# cp /usr/src/linux-headers-4.4.0-31-generic/arch/x86/include/generated/asm/unistd_64_x32.h /usr/include/asm
(base) root@ubuntu:/home/szc# export LD_LIBRARY_PATH=/usr/local/lib
克隆源码
克隆pgm源码,切入目录
(base) root@ubuntu:/home/szc# git clone https://github.com/GElliott/pgm.git
(base) root@ubuntu:/home/szc# cd pgm
修改源文件
修改一些源文件
Makefile
使能litmus,指定liblitmus路径
# LIBLITMUS -- where to find liblitmus?
LIBLITMUS ?= /home/szc/litmus/liblitmus/
.....
# Comment out 'flags-litmus' to disable Litmus support 取消注释
flags-litmus = -D_USE_LITMUS
tools/pgmrt.h
代码里用了一些没有定义的东西,经过和作者沟通,暂时先注释掉
首先是这俩宏定义,以及它们的使用。现在先顾不上是否运行正确了,编译通过再说
/*#define litmus_pgm_wait(statements) \
enter_pgm_wait(); \
statements \
exit_pgm_wait();*/
// signalling task's priority is unconditionally boosted,
// so just enter a non-preemptive section.
/*#define litmus_pgm_complete(statements) \
enter_pgm_send(); \
statements \
exit_pgm_send();*/
.....
// litmus_pgm_wait(ret = pgm_wait(cfg.node););
....
// litmus_pgm_complete(CheckError(pgm_complete(cfg.node)););
然后是这些字段,这些字段在litmus-4.9.30的rt_task结构里压根儿没定义
// param.phase = cfg.phase_ns;
....
// param.split = cfg.split_factor;
.....
/* if (isSrc && isSink)
param.pgm_type = PGM_SRC_SINK;
else if(isSrc)
param.pgm_type = PGM_SRC;
else if(isSink)
param.pgm_type = PGM_SINK;
else
param.pgm_type = PGM_INTERNAL;
param.pgm_expected_etoe = cfg.expected_etoe;*/
最后把下面这些宏从#ifdef _USE_LITMUS的宏判断中移到外面,因为代码里用到了,而且litmus.h头文件里也没定义这些字段
#define s2ns(s) ((s)*1000000000LL)
#define s2us(s) ((s)*1000000LL)
#define s2ms(s) ((s)*1000LL)
#define ms2ns(ms) ((ms)*1000000LL)
#define ms2us(ms) ((ms)*1000LL)
#define us2ns(us) ((us)*1000LL)
#define ns2s(ns) ((ns)/1000000000LL)
#define ns2ms(ns) ((ns)/1000000LL)
#define ns2us(ns) ((ns)/1000LL)
#define us2ms(us) ((us)/1000LL)
#define us2s(us) ((us)/1000000LL)
#define ms2s(ms) ((ms)/1000LL)
src/pgm.cpp
把下面代码里的nothrow去掉
gGraphs = new (nothrow) struct pgm_graph[PGM_MAX_GRAPHS];
编译与测试
(base) root@ubuntu:/home/szc/pgm# make lib all
然后在当前目录下,就会有一些可执行文件
(base) root@ubuntu:/home/szc/pgm# ll
total 1984
drwxrwxrwx 6 root root 4096 Oct 15 19:20 ./
drwxr-xr-x 19 szc szc 4096 Oct 15 18:37 ../
-rwxr-xr-x 1 root root 37088 Oct 15 19:20 ancestortest*
-rw-r--r-- 1 root root 86 Oct 15 19:20 ancestortest.d
-rw-r--r-- 1 root root 18432 Oct 15 19:20 ancestortest.o
-rwxr-xr-x 1 root root 34448 Oct 15 19:20 backedgetest*
-rw-r--r-- 1 root root 86 Oct 15 19:20 backedgetest.d
-rw-r--r-- 1 root root 13768 Oct 15 19:20 backedgetest.o
-rwxr-xr-x 1 root root 37816 Oct 15 19:20 basictest*
-rw-r--r-- 1 root root 77 Oct 15 19:20 basictest.d
-rw-r--r-- 1 root root 19952 Oct 15 19:20 basictest.o
-rwxr-xr-x 1 root root 33760 Oct 15 19:20 cvtest*
-rw-r--r-- 1 root root 68 Oct 15 19:20 cvtest.d
-rw-r--r-- 1 root root 11488 Oct 15 19:20 cvtest.o
-rwxr-xr-x 1 root root 38624 Oct 15 19:20 datapassingtest*
-rw-r--r-- 1 root root 98 Oct 15 19:20 datapassingtest.d
-rw-r--r-- 1 root root 16768 Oct 15 19:20 datapassingtest.o
-rwxr-xr-x 1 root root 39088 Oct 15 19:20 depthtest*
-rw-r--r-- 1 root root 77 Oct 15 19:20 depthtest.d
-rw-r--r-- 1 root root 27216 Oct 15 19:20 depthtest.o
-rwxr-xr-x 1 root root 33040 Oct 15 19:20 dottest*
-rw-r--r-- 1 root root 71 Oct 15 19:20 dottest.d
-rw-r--r-- 1 root root 16496 Oct 15 19:20 dottest.o
drwxrwxrwx 8 root root 4096 Oct 15 18:23 .git/
-rwxrwxrwx 1 root root 222 Oct 15 18:23 .gitignore*
drwxrwxrwx 2 root root 4096 Oct 15 18:23 include/
-rwxr-xr-x 1 root root 151512 Oct 15 19:20 libpgm.so*
-rwxrwxrwx 1 root root 6188 Oct 15 18:34 Makefile*
-rw-r--r-- 1 root root 502 Oct 15 19:20 pgm.d
-rw-r--r-- 1 root root 196984 Oct 15 19:20 pgm.o
-rwxr-xr-x 1 root root 274584 Oct 15 19:20 pgmrt*
-rw-r--r-- 1 root root 396 Oct 15 19:20 pgmrt.d
-rw-r--r-- 1 root root 426528 Oct 15 19:20 pgmrt.o
-rwxr-xr-x 1 root root 116008 Oct 15 19:20 pingpong*
-rw-r--r-- 1 root root 43 Oct 15 19:20 pingpong.d
-rw-r--r-- 1 root root 238408 Oct 15 19:20 pingpong.o
-rwxrwxrwx 1 root root 4224 Oct 15 18:23 README.md*
-rwxr-xr-x 1 root root 34096 Oct 15 19:20 ringtest*
-rw-r--r-- 1 root root 74 Oct 15 19:20 ringtest.d
-rw-r--r-- 1 root root 12440 Oct 15 19:20 ringtest.o
-rwxr-xr-x 1 root root 33768 Oct 15 19:20 sockstreamtest*
-rw-r--r-- 1 root root 92 Oct 15 19:20 sockstreamtest.d
-rw-r--r-- 1 root root 11592 Oct 15 19:20 sockstreamtest.o
drwxrwxrwx 2 root root 4096 Oct 15 18:23 src/
drwxrwxrwx 2 root root 4096 Oct 15 18:23 tools/
(base) root@ubuntu:/home/szc/pgm#
运行其中一两个测试
如果报错找不到库pgm的话,把当前pgm目录放到LD_LIBRARY_PATH变量里(因为libpgm.so刚被我们编译到pgm目录中)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/szc/pgm/
结语
这个库是运行一个RTSS的基于hog的GPU与CPU实验https://github.com/Yougmark/opencv.git hog的必备条件,以后我会更新一下我复现并分析这个实验的笔记