1 | /* |
---|
2 | * $Id: Parameters.cpp 128 2009-06-26 08:43:23Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Core/Dcache_Access/include/Parameters.h" |
---|
9 | #include "Common/include/Max.h" |
---|
10 | #include "Common/include/BitManipulation.h" |
---|
11 | |
---|
12 | namespace morpheo { |
---|
13 | namespace behavioural { |
---|
14 | namespace core { |
---|
15 | namespace dcache_access { |
---|
16 | |
---|
17 | |
---|
18 | #undef FUNCTION |
---|
19 | #define FUNCTION "Dcache_Access::Parameters" |
---|
20 | Parameters::Parameters (uint32_t nb_thread , |
---|
21 | uint32_t nb_execute_loop , |
---|
22 | uint32_t * nb_load_store_unit , |
---|
23 | uint32_t * nb_context , |
---|
24 | uint32_t ** nb_cache_access , |
---|
25 | uint32_t nb_dcache_port , |
---|
26 | uint32_t size_address , |
---|
27 | uint32_t size_data , |
---|
28 | uint32_t size_dcache_thread_id , |
---|
29 | uint32_t size_dcache_packet_id , |
---|
30 | uint32_t ** size_thread_id , |
---|
31 | uint32_t ** size_packet_id , |
---|
32 | uint32_t *** table_routing , |
---|
33 | Tpriority_t priority , |
---|
34 | Tload_balancing_t load_balancing , |
---|
35 | uint32_t *** translate_load_store_unit_to_thread, |
---|
36 | bool is_toplevel ) |
---|
37 | { |
---|
38 | log_begin(Dcache_Access,FUNCTION); |
---|
39 | |
---|
40 | _nb_thread = nb_thread ; |
---|
41 | _nb_execute_loop = nb_execute_loop ; |
---|
42 | _nb_load_store_unit = nb_load_store_unit; |
---|
43 | _nb_context = nb_context ; |
---|
44 | _nb_cache_access = nb_cache_access ; |
---|
45 | _nb_dcache_port = nb_dcache_port ; |
---|
46 | _size_address = size_address ; |
---|
47 | _size_data = size_data ; |
---|
48 | _size_dcache_thread_id = size_dcache_thread_id; |
---|
49 | _size_dcache_packet_id = size_dcache_packet_id; |
---|
50 | _size_thread_id = size_thread_id ; |
---|
51 | _size_packet_id = size_packet_id ; |
---|
52 | _table_routing = table_routing ; |
---|
53 | _priority = priority ; |
---|
54 | _load_balancing = load_balancing ; |
---|
55 | _translate_load_store_unit_to_thread = translate_load_store_unit_to_thread; |
---|
56 | |
---|
57 | // log_printf(TRACE,Dcache_Access,FUNCTION," * table_routing"); |
---|
58 | // for (uint32_t i=0; i<_nb_execute_loop; i++) |
---|
59 | // for (uint32_t j=0; j<_nb_load_store_unit [i]; ++j) |
---|
60 | // for (uint32_t k=0; k<_nb_cache_access [i][j]; ++k) |
---|
61 | // log_printf(TRACE,Dcache_Access,FUNCTION," [%d][%d][%d] %d",i,j,k,_table_routing [i][j][k]); |
---|
62 | |
---|
63 | // log_printf(TRACE,Dcache_Access,FUNCTION," * translate_load_store_unit_to_thread"); |
---|
64 | // for (uint32_t i=0; i<_nb_execute_loop; i++) |
---|
65 | // for (uint32_t j=0; j<_nb_load_store_unit [i]; j++) |
---|
66 | // for (uint32_t k=0; k<_nb_context[i]; k++) |
---|
67 | // log_printf(TRACE,Dcache_Access,FUNCTION," [%d][%d][%d] %d",i,j,k,_translate_load_store_unit_to_thread [i][j][k]); |
---|
68 | |
---|
69 | test(); |
---|
70 | |
---|
71 | _max_nb_load_store_unit = max<uint32_t>(_nb_load_store_unit, nb_execute_loop); |
---|
72 | _max_nb_cache_access = max<uint32_t>(_nb_cache_access , _nb_execute_loop, _nb_load_store_unit); |
---|
73 | |
---|
74 | // _size_dcache_thread_id = (log2(_nb_execute_loop) + |
---|
75 | // log2(_max_nb_load_store_unit) + |
---|
76 | // log2(_max_nb_cache_access) + |
---|
77 | // _max_size_thread_id); |
---|
78 | |
---|
79 | uint32_t max_size_packet_id= max<uint32_t>(_size_packet_id , _nb_execute_loop, _nb_load_store_unit); |
---|
80 | |
---|
81 | _shift_num_cache_access = max_size_packet_id; |
---|
82 | _mask_num_cache_access = gen_mask<Tpacket_t>(log2(_max_nb_cache_access)); |
---|
83 | _mask_num_lsq_packet = gen_mask<Tpacket_t>(max_size_packet_id); |
---|
84 | |
---|
85 | _have_port_dcache_thread_id= _size_dcache_thread_id > 0; |
---|
86 | _have_port_dcache_packet_id= _size_dcache_packet_id > 0; |
---|
87 | |
---|
88 | _have_port_lsq_thread_id = new bool * [_nb_execute_loop]; |
---|
89 | _have_port_lsq_packet_id = new bool * [_nb_execute_loop]; |
---|
90 | |
---|
91 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
92 | { |
---|
93 | _have_port_lsq_thread_id [i] = new bool [_nb_load_store_unit [i]]; |
---|
94 | _have_port_lsq_packet_id [i] = new bool [_nb_load_store_unit [i]]; |
---|
95 | |
---|
96 | for (uint32_t j=0; j<_nb_load_store_unit [i]; ++j) |
---|
97 | { |
---|
98 | _have_port_lsq_thread_id [i][j] = _size_thread_id[i][j] > 0; |
---|
99 | _have_port_lsq_packet_id [i][j] = _size_packet_id[i][j] > 0; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | _translate_thread_to_execute_loop = new uint32_t [nb_thread]; |
---|
104 | _translate_thread_to_load_store_unit = new uint32_t [nb_thread]; |
---|
105 | _translate_thread_to_context = new uint32_t [nb_thread]; |
---|
106 | |
---|
107 | log_printf(TRACE,Dcache_Access,FUNCTION," * translate_load_store_unit_to_thread"); |
---|
108 | |
---|
109 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
110 | for (uint32_t j=0; j<_nb_load_store_unit [i]; ++j) |
---|
111 | for (uint32_t k=0; k<_nb_context[i]; ++k) |
---|
112 | { |
---|
113 | uint32_t num_thread = _translate_load_store_unit_to_thread [i][j][k]; |
---|
114 | |
---|
115 | log_printf(TRACE,Dcache_Access,FUNCTION," [%d][%d][%d] %d",i,j,k,_translate_load_store_unit_to_thread [i][j][k]); |
---|
116 | |
---|
117 | if (num_thread < _nb_thread) |
---|
118 | { |
---|
119 | _translate_thread_to_execute_loop [num_thread] = i; |
---|
120 | _translate_thread_to_load_store_unit [num_thread] = j; |
---|
121 | _translate_thread_to_context [num_thread] = k; |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | _translate_thread_to_execute_loop [num_thread] = _nb_execute_loop; |
---|
126 | _translate_thread_to_load_store_unit [num_thread] = _nb_load_store_unit [i]; |
---|
127 | _translate_thread_to_context [num_thread] = _nb_context [i]; |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | if (is_toplevel) |
---|
132 | { |
---|
133 | copy(); |
---|
134 | } |
---|
135 | |
---|
136 | log_end(Dcache_Access,FUNCTION); |
---|
137 | }; |
---|
138 | |
---|
139 | // #undef FUNCTION |
---|
140 | // #define FUNCTION "Dcache_Access::Parameters (copy)" |
---|
141 | // Parameters::Parameters (Parameters & param) |
---|
142 | // { |
---|
143 | // log_begin(Dcache_Access,FUNCTION); |
---|
144 | // test(); |
---|
145 | // log_end(Dcache_Access,FUNCTION); |
---|
146 | // }; |
---|
147 | |
---|
148 | #undef FUNCTION |
---|
149 | #define FUNCTION "Dcache_Access::~Parameters" |
---|
150 | Parameters::~Parameters (void) |
---|
151 | { |
---|
152 | log_begin(Dcache_Access,FUNCTION); |
---|
153 | |
---|
154 | delete [] _translate_thread_to_context ; |
---|
155 | delete [] _translate_thread_to_load_store_unit; |
---|
156 | delete [] _translate_thread_to_execute_loop ; |
---|
157 | |
---|
158 | for (uint32_t i=0; i<_nb_execute_loop; ++i) |
---|
159 | { |
---|
160 | delete [] _have_port_lsq_thread_id [i]; |
---|
161 | delete [] _have_port_lsq_packet_id [i]; |
---|
162 | } |
---|
163 | delete [] _have_port_lsq_thread_id; |
---|
164 | delete [] _have_port_lsq_packet_id; |
---|
165 | |
---|
166 | log_end(Dcache_Access,FUNCTION); |
---|
167 | }; |
---|
168 | |
---|
169 | #undef FUNCTION |
---|
170 | #define FUNCTION "Dcache_Access::copy" |
---|
171 | void Parameters::copy (void) |
---|
172 | { |
---|
173 | log_begin(Dcache_Access,FUNCTION); |
---|
174 | log_end(Dcache_Access,FUNCTION); |
---|
175 | }; |
---|
176 | |
---|
177 | }; // end namespace dcache_access |
---|
178 | }; // end namespace core |
---|
179 | |
---|
180 | }; // end namespace behavioural |
---|
181 | }; // end namespace morpheo |
---|