annotate TaskManager/Changelog @ 10:7aa4c006e4be

*** empty log message ***
author gongo
date Wed, 06 Feb 2008 18:31:30 +0900
parents
children b658f8ca4408
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
1 2008-02-06 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
2
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
3 * kernel/spe/*.cpp: new と placement new
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
4 現在、spe kernel のタスクは、切り替わる毎に
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
5 new/delete を繰り返しています。今はこれでいいんだけど、
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
6 速度的にも、いずれは直さないといけないと思うわけで。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
7 で、予め allocate された領域を利用した placement new を使えば
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
8 new よりもそれなりに早くなるっぽい。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
9 例題として、与えられた回数分 new/delete を繰り返すプログラムと、
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
10 同じ回数分、placement new したときの速度の比較
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
11
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
12 for (int i = 0; i < num; i++) {
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
13
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
14 < task = new Task;
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
15 < task->init(i);
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
16 < task->printID();
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
17 < delete task;
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
18 ---
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
19 > task = new(buff) Task; // buff = malloc(BUFF_SIZE);
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
20 > task->init(id);
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
21 > task->printID(id);
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
22 }
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
23
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
24 placement new では、delete の必要は無い。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
25 その中で新たに allocate してるなら必要かもしれないが。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
26 速度比較は以下。no_new が placement new で、ln_new が new/delete 。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
27
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
28 % ./a.out 10 // 10 回
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
29 no_new: time: 0.012135(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
30 ln_new: time: 0.003572(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
31
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
32 % ./a.out 100
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
33 no_new: time: 0.022453(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
34 ln_new: time: 0.018989(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
35
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
36 % ./a.out 1000
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
37 no_new: time: 0.115277(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
38 ln_new: time: 0.136335(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
39
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
40 % ./a.out 10000
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
41 no_new: time: 1.056156(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
42 ln_new: time: 1.322709(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
43
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
44 % ./a.out 100000
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
45 no_new: time: 10.622221(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
46 ln_new: time: 13.362414(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
47
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
48 % ./a.out 1000000
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
49 no_new: time: 109.436496(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
50 ln_new: time: 136.956872(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
51
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
52 10、100 回だと負けてるが、まあ無視しよう(ぇ
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
53 回数が多くなるにつれて、ほんの少しだが no_new が勝ってる。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
54 どうなんだろうね。ちなみに printID を無くすと
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
55
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
56 % ./a.out 1000000
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
57 no_new: time: 0.008512(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
58 ln_new: time: 27.100296(msec)
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
59
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
60 I/O に左右され過ぎ。まあそんなもんだろうけどさ。
7aa4c006e4be *** empty log message ***
gongo
parents:
diff changeset
61