Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
rust-xs-test
提交
03b3f68e
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 搜索 >>
提交
03b3f68e
编写于
1月 22, 2021
作者:
H
hustccc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add max instruction config
上级
7bd96274
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
21 deletion
+37
-21
config.toml
config.toml
+1
-0
src/config.rs
src/config.rs
+9
-0
src/main.rs
src/main.rs
+23
-19
xscommand/src/numactl.rs
xscommand/src/numactl.rs
+4
-2
未找到文件。
config.toml
浏览文件 @
03b3f68e
...
...
@@ -5,6 +5,7 @@ sleep_time = 120
[emu]
thread_num
=
8
max_instr
=
1000000
noop_home
=
"/home/ccc/XiangShan"
nemu_home
=
"/home/ccc/NEMU"
am_home
=
"/home/ccc/nexus-am"
...
...
src/config.rs
浏览文件 @
03b3f68e
...
...
@@ -20,6 +20,7 @@ pub struct HookConfig {
#[derive(Debug,
Deserialize)]
pub
struct
EmuConfig
{
thread_num
:
Option
<
usize
>
,
max_instr
:
Option
<
usize
>
,
noop_home
:
Option
<
String
>
,
nemu_home
:
Option
<
String
>
,
am_home
:
Option
<
String
>
,
...
...
@@ -74,6 +75,14 @@ impl Config {
}
}
pub
fn
max_instr
(
&
self
)
->
Option
<
usize
>
{
if
let
Some
(
config
)
=
&
self
.emu
{
config
.max_instr
}
else
{
None
}
}
pub
fn
thread_num
(
&
self
)
->
Option
<
usize
>
{
if
let
Some
(
config
)
=
&
self
.emu
{
config
.thread_num
...
...
src/main.rs
浏览文件 @
03b3f68e
...
...
@@ -44,6 +44,7 @@ const IMG_LIST: &str = "/bigdata/zyy/checkpoints_profiles/betapoint_profile_06/"
const
THREAD_NUM
:
usize
=
8
;
const
NEMU_HOME
:
&
str
=
"/home/ccc/NEMU"
;
const
AM_HOME
:
&
str
=
"/home/ccc/nexus-am"
;
const
MAX_INSTR
:
usize
=
1000000
;
fn
main
()
->
!
{
println!
(
"Hello, rust-xs-test!"
);
...
...
@@ -63,7 +64,7 @@ fn main() -> ! {
continue
;
}
let
config
=
Arc
::
clone
(
&
config
);
pool
.execute
(
move
||
{
pool
.execute
(
move
||
{
// TODO: return code when thread exit
let
time
=
get_workload_name
();
let
work_root
=
if
let
Some
(
dir
)
=
config
.work_root
()
{
dir
}
else
{
WORK_ROOT
};
let
work_root
=
Path
::
new
(
work_root
);
...
...
@@ -75,7 +76,7 @@ fn main() -> ! {
log
::
error!
(
"Failed in creating workload {:?} with msg
{} , thread {} exit."
,
workload
,
msg
,
thread_id
::
get
());
// TODO: specify exit code
exit
(
-
1
)
;
return
;
},
}
}
...
...
@@ -91,12 +92,12 @@ fn main() -> ! {
log
::
info!
(
"git clone {} exit with {}"
,
repo_url
,
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit code not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
},
Err
(
err_code
)
=>
{
log
::
error!
(
"git clone {} error with {}, thread {} exit."
,
repo_url
,
err_code
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
xs_home
=
workload
.join
(
url2path
(
repo_url
));
...
...
@@ -107,12 +108,12 @@ fn main() -> ! {
log
::
info!
(
"make init in {:?} exit with {}"
,
xs_home
,
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit code not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
},
Err
(
err_code
)
=>
{
log
::
error!
(
"make init in {:?} error with {}, thread {} exit."
,
xs_home
,
err_code
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
// if use existing XiangShan proj, git pull
...
...
@@ -121,12 +122,12 @@ fn main() -> ! {
log
::
info!
(
"git pull in {:?} exit with {}"
,
xs_home
,
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit code not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
},
Err
(
err_code
)
=>
{
log
::
error!
(
"git pull in {:?} error with {}, thread {} exit."
,
xs_home
,
err_code
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
// change the ram size
...
...
@@ -135,7 +136,7 @@ fn main() -> ! {
Ok
(
content
)
=>
content
,
Err
(
_
)
=>
{
log
::
error!
(
"failed to read ram.h, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
};
let
new_contents
:
Vec
<&
str
>
=
ram_h_contents
.lines
()
.map
(|
f
|
{
...
...
@@ -152,7 +153,7 @@ fn main() -> ! {
Ok
(
ram_f
)
=>
ram_f
,
Err
(
_
)
=>
{
log
::
error!
(
"failed to open ram.h, thread {} exit"
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
};
let
mut
buf_writer
=
BufWriter
::
new
(
f
);
...
...
@@ -161,14 +162,14 @@ fn main() -> ! {
Ok
(
_
)
=>
{},
Err
(
_
)
=>
{
log
::
error!
(
"BufWriter write line error, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
match
buf_writer
.write
(
b
"
\n
"
)
{
Ok
(
_
)
=>
{},
Err
(
_
)
=>
{
log
::
error!
(
"BufWriter write
\\
n error, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
}
...
...
@@ -182,12 +183,12 @@ fn main() -> ! {
log
::
info!
(
"make emu in {:?} exit with {}"
,
xs_home
,
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit code not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
},
Err
(
err_code
)
=>
{
log
::
error!
(
"make emu in {:?} error with {}, thread {} exit."
,
xs_home
,
err_code
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
// create ./emu_res dir &&
...
...
@@ -200,7 +201,7 @@ fn main() -> ! {
log
::
error!
(
"Failed in creating res_dir {:?} with msg
{} , thread {} exit."
,
res_dir
,
msg
,
thread_id
::
get
());
// TODO: specify exit code
exit
(
-
1
)
;
return
;
},
}
}
...
...
@@ -212,13 +213,14 @@ fn main() -> ! {
path
}
else
{
log
::
error!
(
"no path in emu_path, thread {} exit"
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
};
let
img_list
=
if
let
Some
(
dir
)
=
config
.img_list
()
{
dir
}
else
{
IMG_LIST
};
let
tasks
=
tasks
::
tasks_list
(
img_list
);
use
rand
::
Rng
;
let
mut
task_id
=
rand
::
thread_rng
();
let
img
=
tasks
[
task_id
.gen_range
(
0
..
tasks
.len
())]
.as_str
();
let
max_instr
=
if
let
Some
(
max
)
=
config
.max_instr
()
{
max
}
else
{
MAX_INSTR
};
match
Numactl
::
run_emu
(
xs_home
.to_str
(),
stdout_f
.to_str
(),
...
...
@@ -227,18 +229,19 @@ fn main() -> ! {
img
,
nemu_home
,
am_home
,
thread_num
thread_num
,
max_instr
)
{
Ok
(
exit_code
)
=>
{
log
::
info!
(
"run emu in {:?} exit with {}"
,
xs_home
,
exit_code
);
if
exit_code
!=
0
{
log
::
error!
(
"exit code not zero, thread {} exit."
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
},
Err
(
err_code
)
=>
{
log
::
error!
(
"run emu in {:?} error with {}, thread {} exit."
,
xs_home
,
err_code
,
thread_id
::
get
());
exit
(
-
1
)
;
return
;
}
}
log
::
info!
(
"thread {} return 0"
,
thread_id
::
get
());
...
...
@@ -292,6 +295,7 @@ fn test_read_config() {
assert_eq!
(
conf
.sleep_time
(),
Some
(
120
));
assert_eq!
(
conf
.img_list
(),
Some
(
"/bigdata/zyy/checkpoints_profiles/betapoint_profile_06"
));
assert_eq!
(
conf
.thread_num
(),
Some
(
8
));
assert_eq!
(
conf
.max_instr
(),
Some
(
1000000
));
assert_eq!
(
conf
.nemu_home
(),
Some
(
"/home/ccc/NEMU"
));
assert_eq!
(
conf
.am_home
(),
Some
(
"/home/ccc/nexus-am"
));
}
\ No newline at end of file
xscommand/src/numactl.rs
浏览文件 @
03b3f68e
...
...
@@ -44,7 +44,8 @@ impl<'a> Numactl<'a> {
img_path
:
&
str
,
nemu_home
:
&
str
,
am_home
:
&
str
,
thread_num
:
usize
)
->
Result
<
i32
,
i32
>
{
thread_num
:
usize
,
max_instr
:
usize
)
->
Result
<
i32
,
i32
>
{
let
mut
numactl
=
Numactl
::
new
(
"numactl"
);
let
mut
cpu_percent_collector
=
match
psutil
::
cpu
::
CpuPercentCollector
::
new
()
{
Ok
(
collector
)
=>
collector
,
...
...
@@ -98,7 +99,8 @@ impl<'a> Numactl<'a> {
cpu_ids
.push_str
(
"-"
);
cpu_ids
.push_str
(
end
.to_string
()
.as_str
());
log
::
info!
(
"avaiable cpus: {}"
,
cpu_ids
);
numactl
.set_args
(
vec!
[
"-C"
,
cpu_ids
.as_str
(),
emu_path
,
"-I"
,
"1000000"
,
"-i"
,
img_path
]);
let
max_instr
=
max_instr
.to_string
();
numactl
.set_args
(
vec!
[
"-C"
,
cpu_ids
.as_str
(),
emu_path
,
"-I"
,
max_instr
.as_str
(),
"-i"
,
img_path
]);
if
let
Err
(
err
)
=
numactl
.set_workdir
(
workload
)
{
return
Err
(
err
.err_code
());
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录