Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Cell/spe/CellDmaManager.cc @ 271:f872cc000fe0
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 04 Jun 2009 00:06:37 +0900 |
parents | 0f3acc4080a8 6bb8725e60ae |
children | 3e9c0039e15c |
rev | line source |
---|---|
61 | 1 #include <stdio.h> |
88 | 2 #include <stdlib.h> |
59 | 3 #include "CellDmaManager.h" |
4 | |
249 | 5 unsigned int CellDmaManager::wait_time, CellDmaManager::busy_time; |
6 unsigned long long CellDmaManager::global_busy_time, CellDmaManager::global_wait_time; | |
7 | |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
8 /** |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
9 * DMA Load |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
10 * |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
11 * @param[in] buf Buffer of Load Data |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
12 * @param[in] addr Address of Load Data at Main Memory |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
13 * @param[in] size Size of Load Data |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
14 * @param[in] mask DMA tag |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
15 */ |
59 | 16 void |
88 | 17 CellDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) |
59 | 18 { |
88 | 19 if (size == 0) return ; |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
20 mfc_get((volatile void *)buf, addr, size, mask, 0, 0); |
59 | 21 } |
22 | |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
23 /** |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
24 * DMA Store |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
25 * |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
26 * @param[in] buf Buffer of Store Data at SPE |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
27 * @param[in] addr Address of Store Data at Main Memory |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
28 * @param[in] size Size of Store Data |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
29 * @param[in] mask DMA tag |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
30 */ |
59 | 31 void |
88 | 32 CellDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) |
59 | 33 { |
88 | 34 if (size == 0) return ; |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
35 mfc_put((volatile void *)buf, addr, size, mask, 0, 0); |
59 | 36 } |
37 | |
38 /** | |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
39 * DMA Wait |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
40 * |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
41 * @param[in] mask Tag for Wait DMA process |
59 | 42 */ |
249 | 43 |
44 static void | |
242 | 45 CellDmaManager::start_dmawait_profile() |
46 { | |
47 wait_time = spu_readch(SPU_RdDec); | |
249 | 48 // global 変数にする |
242 | 49 global_busy_time += busy_time - wait_time; |
50 spu_writech(SPU_WrDec, 0xffffffff); | |
51 } | |
52 | |
249 | 53 static void |
242 | 54 CellDmaManager::end_dmawait_profile() |
55 { | |
56 wait_time = spu_readch(SPU_RdDec); | |
249 | 57 // global 変数にする |
242 | 58 global_wait_time += 0xffffffff - wait_time; |
59 busy_time = wait_time; | |
60 } | |
239 | 61 |
251 | 62 // ここでプリント、ppu側から Task にして投げる |
239 | 63 void |
249 | 64 CellDmaManager::print_wait() |
65 { | |
66 } | |
67 | |
239 | 68 void |
255 | 69 CellDmaManager::show_dma_wait(int cpu) |
70 { | |
71 | |
72 printf("spu%d: global_wait_time = %lld\n",cpu, global_wait_time); | |
73 printf("spu%d: global_busy_time = %lld\n",cpu, global_busy_time); | |
74 printf("spu%d: busy_ratio = %g%%\n",cpu, | |
75 ((double)global_busy_time)/((double)(global_busy_time+global_wait_time))*100.0); | |
76 } | |
77 | |
78 void | |
88 | 79 CellDmaManager::dma_wait(uint32 mask) |
59 | 80 { |
242 | 81 #ifdef SPU_PROFILE |
82 start_dmawait_profile(); | |
83 #endif | |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
84 mfc_write_tag_mask(1 << mask); |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
85 mfc_write_tag_update_all(); |
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
86 mfc_read_tag_status(); |
242 | 87 #ifdef SPU_PROFILE |
88 end_dmawait_profile(); | |
89 #endif | |
59 | 90 } |
91 | |
92 void | |
88 | 93 CellDmaManager::mail_write(uint32 data) |
59 | 94 { |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
95 spu_write_out_mbox(data); |
59 | 96 } |
97 | |
98 unsigned int | |
99 CellDmaManager::mail_read(void) | |
100 { | |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
101 unsigned int mail = spu_read_in_mbox(); |
109 | 102 return mail; |
103 } | |
104 | |
105 void | |
106 CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) | |
107 { | |
108 mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, | |
109 mask, 0, 0); | |
59 | 110 } |
88 | 111 |
112 void | |
109 | 113 CellDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) |
88 | 114 { |
109 | 115 mfc_putl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, |
116 mask, 0, 0); | |
117 } |