Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
5bea4897
提交
5bea4897
2月 21, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cilk compile fixes
上级
c5573403
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
17 行删除
+13
-17
cilk.cc
kernel/cilk.cc
+13
-17
没有找到文件。
kernel/cilk.cc
浏览文件 @
5bea4897
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
#include "queue.h"
#include "queue.h"
#include "proc.hh"
#include "proc.hh"
#include "mtrace.h"
#include "mtrace.h"
#include "qlock.h"
#define NSLOTS (1 << CILKSHIFT)
#define NSLOTS (1 << CILKSHIFT)
...
@@ -44,7 +43,7 @@ struct cilkqueue {
...
@@ -44,7 +43,7 @@ struct cilkqueue {
struct
cilkthread
*
thread
[
NSLOTS
];
struct
cilkthread
*
thread
[
NSLOTS
];
volatile
int
head
__mpalign__
;
volatile
int
head
__mpalign__
;
qlock_t
lock
;
struct
spinlock
lock
;
volatile
int
tail
;
volatile
int
tail
;
__padout__
;
__padout__
;
}
__mpalign__
;
}
__mpalign__
;
...
@@ -65,8 +64,8 @@ struct cilkstat {
...
@@ -65,8 +64,8 @@ struct cilkstat {
__padout__
;
__padout__
;
}
__mpalign__
;
}
__mpalign__
;
struct
cilkqueue
queue
[
NCPU
]
__mpalign__
;
st
atic
st
ruct
cilkqueue
queue
[
NCPU
]
__mpalign__
;
struct
cilkstat
stat
[
NCPU
]
__mpalign__
;
st
atic
st
ruct
cilkstat
stat
[
NCPU
]
__mpalign__
;
static
struct
cilkqueue
*
static
struct
cilkqueue
*
cilk_cur
(
void
)
cilk_cur
(
void
)
...
@@ -107,18 +106,17 @@ __cilk_push(struct cilkqueue *q, struct cilkthread *t)
...
@@ -107,18 +106,17 @@ __cilk_push(struct cilkqueue *q, struct cilkthread *t)
static
struct
cilkthread
*
static
struct
cilkthread
*
__cilk_pop
(
struct
cilkqueue
*
q
)
__cilk_pop
(
struct
cilkqueue
*
q
)
{
{
struct
qnode
qn
;
int
i
;
int
i
;
ql_lock
(
&
q
->
lock
,
&
qn
);
acquire
(
&
q
->
lock
);
i
=
q
->
head
;
i
=
q
->
head
;
if
((
i
-
q
->
tail
)
==
0
)
{
if
((
i
-
q
->
tail
)
==
0
)
{
ql_unlock
(
&
q
->
lock
,
&
qn
);
release
(
&
q
->
lock
);
return
0
;
return
0
;
}
}
i
=
(
i
-
1
)
&
(
NSLOTS
-
1
);
i
=
(
i
-
1
)
&
(
NSLOTS
-
1
);
q
->
head
--
;
q
->
head
--
;
ql_unlock
(
&
q
->
lock
,
&
qn
);
release
(
&
q
->
lock
);
cilk_stat
()
->
pop
++
;
cilk_stat
()
->
pop
++
;
return
q
->
thread
[
i
];
return
q
->
thread
[
i
];
...
@@ -127,18 +125,17 @@ __cilk_pop(struct cilkqueue *q)
...
@@ -127,18 +125,17 @@ __cilk_pop(struct cilkqueue *q)
static
struct
cilkthread
*
static
struct
cilkthread
*
__cilk_steal
(
struct
cilkqueue
*
q
)
__cilk_steal
(
struct
cilkqueue
*
q
)
{
{
struct
qnode
qn
;
int
i
;
int
i
;
ql_lock
(
&
q
->
lock
,
&
qn
);
acquire
(
&
q
->
lock
);
i
=
q
->
tail
;
i
=
q
->
tail
;
if
((
i
-
q
->
head
)
==
0
)
{
if
((
i
-
q
->
head
)
==
0
)
{
ql_unlock
(
&
q
->
lock
,
&
qn
);
release
(
&
q
->
lock
);
return
0
;
return
0
;
}
}
i
=
i
&
(
NSLOTS
-
1
);
i
=
i
&
(
NSLOTS
-
1
);
q
->
tail
++
;
q
->
tail
++
;
ql_unlock
(
&
q
->
lock
,
&
qn
);
release
(
&
q
->
lock
);
cilk_stat
()
->
steal
++
;
cilk_stat
()
->
steal
++
;
return
q
->
thread
[
i
];
return
q
->
thread
[
i
];
...
@@ -161,9 +158,8 @@ __cilk_run(struct cilkthread *th)
...
@@ -161,9 +158,8 @@ __cilk_run(struct cilkthread *th)
// Guarantees some core will at some point execute the work.
// Guarantees some core will at some point execute the work.
// The current core might execute the work immediately.
// The current core might execute the work immediately.
void
void
cilk_push
(
void
*
rip
,
u64
arg0
,
u64
arg1
)
cilk_push
(
void
(
*
fn
)(
uptr
,
uptr
)
,
u64
arg0
,
u64
arg1
)
{
{
void
(
*
fn
)(
uptr
,
uptr
)
=
(
void
(
*
)(
uptr
,
uptr
))
rip
;
struct
cilkthread
*
th
;
struct
cilkthread
*
th
;
th
=
(
struct
cilkthread
*
)
kalloc
();
th
=
(
struct
cilkthread
*
)
kalloc
();
...
@@ -171,7 +167,7 @@ cilk_push(void *rip, u64 arg0, u64 arg1)
...
@@ -171,7 +167,7 @@ cilk_push(void *rip, u64 arg0, u64 arg1)
fn
(
arg0
,
arg1
);
fn
(
arg0
,
arg1
);
return
;
return
;
}
}
th
->
rip
=
(
uptr
)
rip
;
th
->
rip
=
(
uptr
)
fn
;
th
->
arg0
=
arg0
;
th
->
arg0
=
arg0
;
th
->
arg1
=
arg1
;
th
->
arg1
=
arg1
;
th
->
frame
=
cilk_frame
();
th
->
frame
=
cilk_frame
();
...
@@ -281,7 +277,7 @@ testcilk(void)
...
@@ -281,7 +277,7 @@ testcilk(void)
s
=
rdtsc
();
s
=
rdtsc
();
cilk_start
();
cilk_start
();
for
(
i
=
0
;
i
<
iters
;
i
++
)
for
(
i
=
0
;
i
<
iters
;
i
++
)
cilk_push
(
(
void
*
)
__test_stub
,
i
,
i
);
cilk_push
(
__test_stub
,
i
,
i
);
cilk_end
();
cilk_end
();
e
=
rdtsc
();
e
=
rdtsc
();
cprintf
(
"testcilk: %lu
\n
"
,
(
e
-
s
)
/
iters
);
cprintf
(
"testcilk: %lu
\n
"
,
(
e
-
s
)
/
iters
);
...
@@ -306,6 +302,6 @@ initcilk(void)
...
@@ -306,6 +302,6 @@ initcilk(void)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
ql_init
(
&
queue
[
i
].
lock
,
"queue lock"
);
initlock
(
&
queue
[
i
].
lock
,
"queue lock"
,
LOCKSTAT_CILK
);
}
}
#endif // CILKENABLE
#endif // CILKENABLE
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论