Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
rust-xs-test
提交
9dd65d8c
R
rust-xs-test
项目概览
OpenXiangShan
/
rust-xs-test
9 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rust-xs-test
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9dd65d8c
编写于
1月 17, 2021
作者:
H
hustccc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
2e11e244
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
130 addition
and
16 deletion
+130
-16
Cargo.toml
Cargo.toml
+2
-1
src/main.rs
src/main.rs
+81
-14
xscommand/macros/src/lib.rs
xscommand/macros/src/lib.rs
+1
-1
xscommand/src/emu.rs
xscommand/src/emu.rs
+27
-0
xscommand/src/lib.rs
xscommand/src/lib.rs
+1
-0
xscommand/src/numactl.rs
xscommand/src/numactl.rs
+18
-0
未找到文件。
Cargo.toml
浏览文件 @
9dd65d8c
...
...
@@ -12,4 +12,5 @@ simple_logger = "1.11.0"
log
=
"0.4"
threadpool
=
"1.0"
thread-id
=
"3.3.0"
chrono
=
"0.4"
\ No newline at end of file
chrono
=
"0.4"
psutil
=
"3.2.0"
\ No newline at end of file
src/main.rs
浏览文件 @
9dd65d8c
...
...
@@ -7,15 +7,19 @@ extern crate simple_logger;
extern
crate
threadpool
;
extern
crate
thread_id
;
extern
crate
chrono
;
extern
crate
psutil
;
#[allow(unused_imports)]
use
std
::{
fs
,
path
::
Path
,
process
::{
Command
,
exit
},
thread
,
time
::
Duration
,
vec
};
use
simple_logger
::
SimpleLogger
;
#[allow(unused_imports)]
use
xscommand
::{
XSCommand
,
XSCommandErr
,
git
::
Git
,
make
::
Make
,
emu
::
Emu
,
numactl
::
Numactl
,
};
use
threadpool
::
ThreadPool
;
use
chrono
::
prelude
::
*
;
...
...
@@ -83,6 +87,10 @@ fn main() -> ! {
match
git
.excute
(
stdout_f
.to_str
(),
stderr_f
.to_str
())
{
Ok
(
exit_code
)
=>
{
log
::
info!
(
"git with args: {:?} excute return {}"
,
git
.get_args
(),
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
},
Err
(
git_err
)
=>
{
log
::
error!
(
"{}, thread {} exit."
,
git_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -117,6 +125,10 @@ fn main() -> ! {
match
make
.excute
(
stdout_f
.to_str
(),
stderr_f
.to_str
())
{
Ok
(
exit_code
)
=>
{
log
::
info!
(
"make with args: {:?} excute return {}"
,
make
.get_args
(),
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
},
Err
(
make_err
)
=>
{
log
::
error!
(
"{}, thread {} exit."
,
make_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -130,8 +142,8 @@ fn main() -> ! {
{
let
stdout_f
=
workload
.join
(
"stdout.txt"
);
let
stderr_f
=
workload
.join
(
"stderr.txt"
);
let
mut
make
=
Make
::
set_exe
(
"
make
"
);
match
make
.set_args
(
vec!
[
"
emu
"
])
{
let
mut
make
=
Make
::
set_exe
(
"
numactl
"
);
match
make
.set_args
(
vec!
[
"
-C"
,
"0-63"
,
"make"
,
"emu"
,
"EMU_TARCE=1"
,
"SIM_ARGS=
\"
--disable-all
\"
"
,
"EMU_THREADS=8"
,
"-j64
"
])
{
Ok
(
_
)
=>
{},
// do nothing
Err
(
make_err
)
=>
{
log
::
error!
(
"{}, thread {} exit"
,
make_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -152,6 +164,10 @@ fn main() -> ! {
match
make
.excute
(
stdout_f
.to_str
(),
stderr_f
.to_str
())
{
Ok
(
exit_code
)
=>
{
log
::
info!
(
"make with args: {:?} excute return {}"
,
make
.get_args
(),
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
},
Err
(
make_err
)
=>
{
log
::
error!
(
"{}, thread {} exit."
,
make_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -162,7 +178,7 @@ fn main() -> ! {
// make drop here
}
// create ../emu_res dir &&
// emu -I 1000000 -i /bigdata/zyy/checkpoints_profiles/betapoint_profile_06/gcc_200/0/_8000000000_.gz
//
numactl -C []
emu -I 1000000 -i /bigdata/zyy/checkpoints_profiles/betapoint_profile_06/gcc_200/0/_8000000000_.gz
let
res_dir
=
workload
.join
(
"../emu_res"
);
{
if
!
res_dir
.exists
()
{
...
...
@@ -179,14 +195,61 @@ fn main() -> ! {
let
stdout_f
=
res_dir
.join
(
"stdout.txt"
);
let
stderr_f
=
res_dir
.join
(
"stderr.txt"
);
let
emu_path
=
workload
.join
(
"./build/emu"
);
let
mut
emu
=
if
let
Some
(
path
)
=
emu_path
.to_str
()
{
let
emu
=
if
let
Some
(
path
)
=
emu_path
.to_str
()
{
log
::
info!
(
"create emu in {}"
,
path
);
Emu
::
set_exe
(
path
)
path
}
else
{
log
::
info!
(
"no path in emu_path, thread {} exit"
,
thread_id
::
get
());
log
::
error!
(
"no path in emu_path, thread {} exit"
,
thread_id
::
get
());
exit
(
-
1
);
};
let
mut
cpu_percent_collector
=
match
psutil
::
cpu
::
CpuPercentCollector
::
new
()
{
Ok
(
collector
)
=>
collector
,
Err
(
_
)
=>
{
log
::
error!
(
"new CpuPercentCollector error, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
};
let
mut
numactl
=
Numactl
::
set_exe
(
"numactl"
);
let
cpu_percents
=
match
cpu_percent_collector
.cpu_percent_percpu
()
{
Ok
(
percents
)
=>
percents
,
Err
(
_
)
=>
{
log
::
error!
(
"get cpu_percent_percpu error, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
};
let
(
mut
begin
,
mut
end
)
=
(
0
,
0
);
let
mut
count
=
0
;
for
_
in
0
..
3
{
begin
=
0
;
end
=
0
;
for
i
in
0
..
cpu_percents
.len
()
{
if
cpu_percents
[
i
]
>
50.0
{
begin
+=
1
;
end
=
begin
;
}
else
{
end
+=
1
;
}
if
(
end
-
begin
)
>=
7
{
// found 8 free cpus, break
break
;
}
}
if
(
end
-
begin
)
>=
7
{
log
::
info!
(
"found avaiable 8 cpus, ready to run emu."
);
break
;
}
count
+=
1
;
thread
::
sleep
(
Duration
::
from_secs
(
SLEEP_TIME
*
100
));
}
if
count
>=
3
{
log
::
error!
(
"no 8 cpus avaiable, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
};
match
emu
.set_args
(
vec!
[
"-I"
,
"1000000"
,
"-i"
,
EMU_TARGET
])
{
}
let
mut
cpu_ids
=
begin
.to_string
();
cpu_ids
.push_str
(
"-"
);
cpu_ids
.push_str
(
end
.to_string
()
.as_str
());
log
::
info!
(
"avaiable cpus: {}"
,
cpu_ids
);
match
numactl
.set_args
(
vec!
[
"-C"
,
cpu_ids
.as_str
(),
emu
,
"-I"
,
"1000000"
,
"-i"
,
EMU_TARGET
])
{
Ok
(
_
)
=>
{},
// do nothing
Err
(
emu_err
)
=>
{
log
::
error!
(
"{}, thread {} exit"
,
emu_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -194,7 +257,7 @@ fn main() -> ! {
exit
(
-
1
);
}
}
match
emu
.set_workdir
(
workload
.to_str
())
{
match
numactl
.set_workdir
(
workload
.to_str
())
{
Ok
(
_
)
=>
{},
// do nothing
Err
(
emu_err
)
=>
{
log
::
error!
(
"{}, thread {} exit"
,
emu_err
.as_str
(),
thread_id
::
get
());
...
...
@@ -203,12 +266,16 @@ fn main() -> ! {
}
}
// set env `NOOP_HOME` to currnet workload
emu
.exe
.env
(
"NOOP_HOME"
,
workload
.to_path_buf
());
emu
.exe
.env
(
"NEMU_HOME"
,
NEMU_HOME
);
emu
.exe
.env
(
"AM_HOME"
,
AM_HOME
);
match
emu
.excute
(
stdout_f
.to_str
(),
stderr_f
.to_str
())
{
numactl
.exe
.env
(
"NOOP_HOME"
,
workload
.to_path_buf
());
numactl
.exe
.env
(
"NEMU_HOME"
,
NEMU_HOME
);
numactl
.exe
.env
(
"AM_HOME"
,
AM_HOME
);
match
numactl
.excute
(
stdout_f
.to_str
(),
stderr_f
.to_str
())
{
Ok
(
exit_code
)
=>
{
log
::
info!
(
"make with args: {:?} excute return {}"
,
emu
.get_args
(),
exit_code
);
log
::
info!
(
"make with args: {:?} excute return {}"
,
numactl
.get_args
(),
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
);
}
},
Err
(
emu_err
)
=>
{
log
::
error!
(
"{}, thread {} exit."
,
emu_err
.as_str
(),
thread_id
::
get
());
...
...
xscommand/macros/src/lib.rs
浏览文件 @
9dd65d8c
...
...
@@ -17,7 +17,7 @@ pub fn xscommand_derive(input: TokenStream) -> TokenStream {
let
gen
=
quote!
{
impl
<
'a
>
XSCommand
<
'a
,
DefaultErr
>
for
#
name
<
'a
>
{
fn
set_exe
(
path
:
&
str
)
->
Self
{
let
exe
=
Command
::
new
(
stringify!
(
#
name
)
.to_ascii_lowercase
()
);
let
exe
=
Command
::
new
(
path
);
let
args
=
Vec
::
new
();
Self
{
exe
,
...
...
xscommand/src/emu.rs
浏览文件 @
9dd65d8c
...
...
@@ -16,3 +16,30 @@ pub struct Emu<'a> {
work_dir
:
Option
<&
'a
str
>
,
}
#[test]
fn
test_emu_help
()
{
use
std
::
fs
;
use
std
::
path
::
Path
;
let
workload
=
Path
::
new
(
"emu_help_test"
);
if
!
workload
.exists
()
{
// workload not exists, create
fs
::
create_dir
(
workload
)
.unwrap
();
}
let
stdout_file
=
workload
.join
(
"emu_help_stdout.txt"
);
let
stderr_file
=
workload
.join
(
"emu_help_stderr.txt"
);
let
mut
emu
=
Emu
::
set_exe
(
"emu"
);
let
args
=
vec!
[
"--help"
];
emu
.set_args
(
args
)
.unwrap
();
emu
.set_workdir
(
workload
.to_str
())
.unwrap
();
match
emu
.excute
(
stdout_file
.to_str
(),
stderr_file
.to_str
())
{
Ok
(
exit_code
)
=>
{
assert_eq!
(
exit_code
,
0
);
},
Err
(
errtype
)
=>
panic!
(
"ErrType: {:?}"
,
errtype
),
}
// TODO: check the content of `stdout` and `stderr`
// remove a dir after removing all its contents
if
workload
.exists
()
{
fs
::
remove_dir_all
(
workload
)
.unwrap
();
}
}
\ No newline at end of file
xscommand/src/lib.rs
浏览文件 @
9dd65d8c
...
...
@@ -18,6 +18,7 @@ pub mod git;
pub
mod
make
;
pub
mod
just
;
pub
mod
emu
;
pub
mod
numactl
;
extern
crate
xscommand_macros
;
...
...
xscommand/src/numactl.rs
0 → 100644
浏览文件 @
9dd65d8c
/// Numactl XSCommand Implementation
///
use
super
::{
XSCommand
,
DefaultErr
};
use
std
::{
fs
::
File
,
os
::
unix
::
io
::{
FromRawFd
,
IntoRawFd
},
process
::{
Command
,
Stdio
}
};
use
xscommand_macros
::
XSCommand
;
#[derive(XSCommand)]
pub
struct
Numactl
<
'a
>
{
pub
exe
:
Command
,
args
:
Vec
<&
'a
str
>
,
work_dir
:
Option
<&
'a
str
>
,
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录