comparison ppe/Menu.cc @ 0:68a98d68d62a

commit
author yutaka@localhost.localdomain
date Sun, 28 Mar 2010 19:47:00 +0900
parents
children dcd83cefb980
comparison
equal deleted inserted replaced
-1:000000000000 0:68a98d68d62a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "Menu.h"
4 #include "Sys.h"
5 #include "params.h"
6
7 //headk_num と send_param_head の値を必ず返さないと、動作しない
8
9 send_params_head_t*
10 menu(int &head_num) {
11
12 head_num = SPE_NUM;
13 int all_task_num = SPE_NUM*1000;
14 //int all_task_num = 1;
15 //int task_size = MAX_DMA_SIZE;
16 int task_size = 16*1024;
17 int in_size = (task_size - sizeof(send_params_head_t)) * all_task_num;
18 int out_size = (task_size - sizeof(send_params_head_t)) * all_task_num;
19
20 float *in;
21 float *out = (float*)allocate(out_size);
22
23 int partition_size = task_size - sizeof(send_params_head_t);
24 send_params_t *send_params = (send_params_t*)allocate(sizeof(send_params_t)*all_task_num);
25
26 send_params_head_t *head = (send_params_head_t*)allocate(sizeof(send_params_head_t)*head_num);
27
28 for (int i = 0; i < all_task_num; i++) {
29
30 send_params[i] = task_allocate(task_size); // header と、in サイズを確保するよ。
31 in = (float*)send_params[i].buff;
32
33 for (int j = 0; j < partition_size / sizeof(float); j++) {
34 in[j] = j;
35 //printf("%f\n",in[j]);
36 }
37
38 }
39
40 int task_list_length = all_task_num / head_num;
41 int index = 0;
42
43 for (int i = 0; i < head_num; i++) {
44
45 head[i].next_task = (unsigned long) send_params[index].head;
46 head[i].next_task_size = task_size;
47
48 head[i].ea_out = (unsigned long) &out[(index * partition_size) / sizeof(float)];
49 head[i].size_out = partition_size;
50
51 head[i].pin_in = 0;
52 head[i].pin_out = 0;
53
54
55 for (int j = 0; j < task_list_length - 1; j++) {
56
57 //Cerium を要チェック
58
59 send_params[index].head->next_task = (unsigned long) send_params[index+1].head;
60 send_params[index].head->next_task_size = task_size;
61
62 send_params[index].head->ea_out = (unsigned long) &out[((index) * partition_size) / sizeof(float)];
63 send_params[index].head->size_out = partition_size;
64
65 send_params[index].head->pin_in = 0;
66 send_params[index].head->pin_out = 0;
67
68 index++;
69
70
71 }
72
73
74 send_params[index].head->next_task = 0;
75 send_params[index].head->next_task_size = 0;
76
77 send_params[index].head->ea_out = (unsigned long) &out[(index) * partition_size / sizeof(float)];
78
79 //printf("[PPE] %p\n",(unsigned long)send_params[index].head->ea_out);
80
81 //send_params[index].head->ea_out = 0;
82 send_params[index].head->size_out = partition_size;
83
84 send_params[index].head->pin_in = 0;
85 send_params[index].head->pin_out = 0;
86
87 //send_params[index].head = NULL;
88
89 index++;
90
91
92 }
93
94 printf("return run\n");
95
96 return head;
97
98 }