Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
6be8443d
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
11 个月 前同步成功
通知
1183
Star
3914
Fork
526
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XiangShan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6be8443d
编写于
11月 27, 2020
作者:
Y
Yinan Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ram: reduce printf times
上级
a8359f39
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
13 deletion
+12
-13
src/test/csrc/ram.cpp
src/test/csrc/ram.cpp
+12
-13
未找到文件。
src/test/csrc/ram.cpp
浏览文件 @
6be8443d
...
...
@@ -116,23 +116,28 @@ int readFromGz(void* ptr, const char *file_name) {
}
uint64_t
curr_size
=
0
;
// read 16KB each time
const
uint32_t
chunk_size
=
16384
;
long
*
temp_page
=
new
long
[
chunk_size
];
long
*
pmem_current
=
(
long
*
)
ptr
;
if
((
RAMSIZE
%
chunk_size
)
!=
0
)
{
printf
(
"RAMSIZE must be divisible by chunk_size
\n
"
);
assert
(
0
);
}
uint64_t
*
temp_page
=
new
uint64_t
[
chunk_size
];
uint64_t
*
pmem_current
=
(
uint64_t
*
)
ptr
;
while
(
curr_size
<
RAMSIZE
)
{
uint32_t
bytes_read
=
gzread
(
compressed_mem
,
temp_page
,
chunk_size
);
if
(
bytes_read
==
0
)
{
break
;
}
assert
(
bytes_read
%
sizeof
(
long
)
==
0
);
for
(
uint32_t
x
=
0
;
x
<
bytes_read
/
sizeof
(
long
);
x
++
)
{
assert
(
bytes_read
%
sizeof
(
uint64_t
)
==
0
);
for
(
uint32_t
x
=
0
;
x
<
bytes_read
/
sizeof
(
uint64_t
);
x
++
)
{
if
(
*
(
temp_page
+
x
)
!=
0
)
{
pmem_current
=
(
long
*
)((
uint8_t
*
)
ptr
+
curr_size
+
x
*
sizeof
(
long
));
pmem_current
=
(
uint64_t
*
)((
uint8_t
*
)
ptr
+
curr_size
+
x
*
sizeof
(
uint64_t
));
*
pmem_current
=
*
(
temp_page
+
x
);
}
}
curr_size
+=
bytes_read
;
}
printf
(
"Read %lu bytes from gz stream in total
"
,
curr_size
);
// printf("Read 0x%lx bytes from gz stream in total.\n
", curr_size);
delete
[]
temp_page
;
...
...
@@ -150,17 +155,11 @@ void init_ram(const char *img) {
int
ret
;
if
(
isGzFile
(
img
))
{
printf
(
"
Read from gz file
\n
"
);
printf
(
"
Gzip file detected. Loading image from extracted gz file.
\n
"
);
img_size
=
readFromGz
(
ram
,
img
);
if
(
img_size
>
RAMSIZE
)
{
img_size
=
RAMSIZE
;
}
assert
(
img_size
>=
0
);
}
else
{
printf
(
"Read from bin file
\n
"
);
FILE
*
fp
=
fopen
(
img
,
"rb"
);
if
(
fp
==
NULL
)
{
printf
(
"Can not open '%s'
\n
"
,
img
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录