Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
63c51365
提交
63c51365
5月 02, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Benchmarking stuff
上级
c63a4bc8
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
17 行删除
+35
-17
bench.cc
bin/bench.cc
+13
-5
mapbench.cc
bin/mapbench.cc
+18
-10
xsys.h
include/xsys.h
+1
-0
Makefrag.bench
user/Makefrag.bench
+1
-1
util.h
user/util.h
+2
-1
没有找到文件。
bin/bench.cc
浏览文件 @
63c51365
#include "types.h"
#include "user.h"
#include "amd64.h"
#include "lib.h"
static
u64
time_this
(
const
char
*
av
[])
...
...
@@ -64,17 +65,24 @@ struct TimedExec : public Bench
struct
LoopsBench
:
public
Bench
{
static
const
int
runs
=
1
;
LoopsBench
(
const
char
*
cmd
,
int
nloops
,
int
cpuinc
)
:
Bench
(),
cmd_
(
cmd
),
nloops_
(
nloops
),
cpuinc_
(
cpuinc
)
{}
char
*
runone
(
int
ncore
,
const
char
**
argv
,
char
*
res
,
int
n
)
{
char
cores
[
16
];
u64
min
=
~
0ull
;
char
cores
[
16
];
snprintf
(
cores
,
sizeof
(
cores
),
"%u"
,
ncore
);
argv
[
1
]
=
cores
;
u64
r
=
time_this
(
argv
);
// r in usecs
r
=
(
r
*
(
1000
*
1000
))
/
cpuhz
();
snprintf
(
res
,
n
,
"%u %lu %lu
\n
"
,
ncore
,
r
,
nloops_
);
for
(
int
i
=
0
;
i
<
runs
;
i
++
)
{
u64
r
=
time_this
(
argv
);
// r in usecs
r
=
(
r
*
(
1000
*
1000
))
/
cpuhz
();
min
=
MIN
(
r
,
min
);
}
snprintf
(
res
,
n
,
"%u %lu %lu
\n
"
,
ncore
,
min
,
nloops_
);
return
res
+
strlen
(
res
);
}
...
...
bin/mapbench.cc
浏览文件 @
63c51365
#if defined(LINUX)
#include <pthread.h>
#include "user/util.h"
#include "types.h"
#include <assert.h>
#include <sys/wait.h>
#include <unistd.h>
#else
#include "types.h"
#include "stat.h"
#include "user.h"
...
...
@@ -5,7 +13,8 @@
#include "uspinlock.h"
#include "mtrace.h"
#include "pthread.h"
#endif
#include "xsys.h"
#include <sys/mman.h>
enum
{
readaccess
=
1
};
...
...
@@ -20,8 +29,9 @@ void*
thr
(
void
*
arg
)
{
u64
tid
=
(
u64
)
arg
;
if
(
setaffinity
(
tid
)
<
0
)
fprintf
(
1
,
"setaffinity err
\n
"
);
die
(
"setaffinity err
"
);
pthread_barrier_wait
(
&
bar
);
...
...
@@ -32,13 +42,12 @@ thr(void *arg)
for
(
int
i
=
0
;
i
<
niter
;
i
++
)
{
if
(
verbose
&&
((
i
%
100
)
==
0
))
fprintf
(
1
,
"%d: %d ops
\n
"
,
tid
,
i
);
printf
(
"%d: %d ops
\n
"
,
tid
,
i
);
volatile
char
*
p
=
(
char
*
)
(
0x100000000UL
+
tid
*
npg
*
0x100000
);
if
(
mmap
((
void
*
)
p
,
npg
*
4096
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_FIXED
|
MAP_ANONYMOUS
,
-
1
,
0
)
==
MAP_FAILED
)
{
fprintf
(
1
,
"%d: map failed
\n
"
,
tid
);
exit
();
die
(
"%d: map failed"
,
tid
);
}
if
(
readaccess
)
{
...
...
@@ -47,8 +56,7 @@ thr(void *arg)
}
if
(
munmap
((
void
*
)
p
,
npg
*
4096
)
<
0
)
{
fprintf
(
1
,
"%d: unmap failed
\n
"
,
tid
);
exit
();
die
(
"%d: unmap failed
\n
"
,
tid
);
}
}
return
0
;
...
...
@@ -71,15 +79,15 @@ main(int ac, char **av)
for
(
u64
i
=
0
;
i
<
nthread
;
i
++
)
{
pthread_t
tid
;
pthread_create
(
&
tid
,
0
,
thr
,
(
void
*
)
i
);
if
(
0
)
fprintf
(
1
,
"mapbench[%d]: child %d
\n
"
,
getpid
(),
tid
);
if
(
0
)
printf
(
"mapbench[%d]: child %d
\n
"
,
getpid
(),
tid
);
}
for
(
int
i
=
0
;
i
<
nthread
;
i
++
)
wait
();
x
wait
();
mtdisable
(
"xv6-asharing"
);
// fprintf(1, "mapbench[%d]: done\n", getpid());
// halt();
exit
();
x
exit
();
}
include/xsys.h
浏览文件 @
63c51365
...
...
@@ -14,6 +14,7 @@ static inline void xwait()
#define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR);
#define xcreat(name) open((name), O_CREATE|O_RDWR, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0)
#define mtenable_type(x, y) do { } while (0)
#define mtdisable(x) do { } while(0)
#else // Must be xv6
...
...
user/Makefrag.bench
浏览文件 @
63c51365
...
...
@@ -23,4 +23,4 @@ $(O)/%: $(O)/user/%.o
.PRECIOUS: $(O)/user/%.o
-include $(O)/user/*.d
ALL := $(O)/filebench $(O)/dirbench
ALL := $(O)/filebench $(O)/dirbench
$(O)/mapbench
user/util.h
浏览文件 @
63c51365
...
...
@@ -32,7 +32,7 @@ edie(const char* errstr, ...)
exit
(
EXIT_FAILURE
);
}
static
inline
void
static
inline
int
setaffinity
(
int
c
)
{
cpu_set_t
cpuset
;
...
...
@@ -40,6 +40,7 @@ setaffinity(int c)
CPU_SET
(
c
,
&
cpuset
);
if
(
sched_setaffinity
(
0
,
sizeof
(
cpuset
),
&
cpuset
)
<
0
)
edie
(
"setaffinity, sched_setaffinity failed"
);
return
0
;
}
static
inline
uint64_t
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论