Krnl_GA.cl 58.7 KB
Newer Older
1
2
3
//IC:  initial calculation of energy of populations
//GG:  genetic generation 
//LS:  local search
4
//OFF: turn off 
Leonardo Solis's avatar
Leonardo Solis committed
5
6

#include "../defines.h"
Leonardo Solis's avatar
Leonardo Solis committed
7
8
9
10

#define CHAN_DEPTH_ATOMXYZ   (MAX_NUM_OF_ATOMS/2)
#define CHAN_DEPTH_GENOTYPE  ACTUAL_GENOTYPE_LENGTH

11
// Send active signal to IGL_Arbiter
lvs's avatar
lvs committed
12
13
14
15
16
// Resized to valid SDAccel depths: 16, 32, ...
/*
pipe bool    chan_GA2IGL_IC_active;
pipe bool    chan_GA2IGL_GG_active;
*/
17
/*
lvs's avatar
lvs committed
18
19
pipe bool    chan_GA2IGL_IC_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2IGL_GG_active	__attribute__((xcl_reqd_pipe_depth(16)));
20
21
22
23
24
*/
pipe int    chan_GA2IGL_IC_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2IGL_GG_active	__attribute__((xcl_reqd_pipe_depth(16)));


25

26
// Send genotypes from producers (IC, GG, LSs) to Conform
lvs's avatar
lvs committed
27
/*
lvs's avatar
lvs committed
28
29
30
31
32
33
34
35
36
37
38
pipe float  chan_IC2Conf_genotype          __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_GG2Conf_genotype          __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS1_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS2_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS3_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS4_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS5_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS6_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS7_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS8_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float  chan_LS2Conf_LS9_genotype      __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
39
40
41
42
43
44
45
46
47
48
49
50
*/
pipe float  chan_IC2Conf_genotype          __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_GG2Conf_genotype          __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS1_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS2_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS3_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS4_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS5_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS6_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS7_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS8_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
pipe float  chan_LS2Conf_LS9_genotype      __attribute__((xcl_reqd_pipe_depth(64)));
Leonardo Solis's avatar
Leonardo Solis committed
51

52
// Send ligand-atom positions from Conform to InterE & IntraE
lvs's avatar
lvs committed
53
54
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
55
56
57
58
pipe float8  chan_Conf2Intere_xyz           __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_ATOMXYZ)));
pipe char2   chan_Conf2Intere_actmode;
pipe float8  chan_Conf2Intrae_xyz           __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_ATOMXYZ)));
pipe char2   chan_Conf2Intrae_actmode;	
lvs's avatar
lvs committed
59
60
*/
pipe float8  chan_Conf2Intere_xyz           __attribute__((xcl_reqd_pipe_depth(64)));
61
#if 0
lvs's avatar
lvs committed
62
pipe char2   chan_Conf2Intere_actmode	    __attribute__((xcl_reqd_pipe_depth(16)));
63
64
65
#endif
pipe char    chan_Conf2Intere_actmode	    __attribute__((xcl_reqd_pipe_depth(16)));

lvs's avatar
lvs committed
66
pipe float8  chan_Conf2Intrae_xyz           __attribute__((xcl_reqd_pipe_depth(64)));
67
#if 0
lvs's avatar
lvs committed
68
pipe char2   chan_Conf2Intrae_actmode       __attribute__((xcl_reqd_pipe_depth(16)));
69
70
#endif
pipe char    chan_Conf2Intrae_actmode       __attribute__((xcl_reqd_pipe_depth(16)));
71

72
// Send energy values from InterE & IntraE to genotype-senders (IC, GG, LSs)
lvs's avatar
lvs committed
73
74
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
pipe float  chan_Intere2StoreIC_intere     __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreGG_intere     __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS1_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS2_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS3_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS4_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS5_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS6_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS7_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS8_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intere2StoreLS_LS9_intere __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreIC_intrae     __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreGG_intrae     __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS1_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS2_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS3_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS4_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS5_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS6_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS7_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS8_intrae __attribute__((xcl_reqd_pipe_depth(2)));
pipe float  chan_Intrae2StoreLS_LS9_intrae __attribute__((xcl_reqd_pipe_depth(2)));
lvs's avatar
lvs committed
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
*/
pipe float  chan_Intere2StoreIC_intere     __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreGG_intere     __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS1_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS2_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS3_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS4_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS5_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS6_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS7_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS8_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intere2StoreLS_LS9_intere __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreIC_intrae     __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreGG_intrae     __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS1_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS2_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS3_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS4_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS5_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS6_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS7_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS8_intrae __attribute__((xcl_reqd_pipe_depth(16)));
pipe float  chan_Intrae2StoreLS_LS9_intrae __attribute__((xcl_reqd_pipe_depth(16)));
Leonardo Solis's avatar
Leonardo Solis committed
120

121
// Send PRNG outputs from generators to consumers
lvs's avatar
lvs committed
122
123
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
124
pipe float8   chan_PRNG2GA_BT_ushort_float_prng;
lvs's avatar
lvs committed
125
126
127
128
*/
pipe float8   chan_PRNG2GA_BT_ushort_float_prng	__attribute__((xcl_reqd_pipe_depth(16)));

/*
lvs's avatar
lvs committed
129
pipe uchar2   chan_PRNG2GA_GG_uchar_prng;
lvs's avatar
lvs committed
130
131
132
133
*/
pipe uchar2   chan_PRNG2GA_GG_uchar_prng	__attribute__((xcl_reqd_pipe_depth(16)));

/*
lvs's avatar
lvs committed
134
pipe float    chan_PRNG2GA_GG_float_prng     __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
135
136
137
138
*/
pipe float    chan_PRNG2GA_GG_float_prng     __attribute__((xcl_reqd_pipe_depth(64)));

/*
lvs's avatar
lvs committed
139
pipe ushort16 chan_PRNG2GA_LS123_ushort_prng;
lvs's avatar
lvs committed
140
141
142
143
*/
pipe ushort16 chan_PRNG2GA_LS123_ushort_prng	__attribute__((xcl_reqd_pipe_depth(16)));

/*
lvs's avatar
lvs committed
144
145
146
147
148
149
150
151
152
pipe float    chan_PRNG2GA_LS_float_prng     __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS2_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS3_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS4_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS5_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS6_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS7_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS8_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float    chan_PRNG2GA_LS9_float_prng    __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
153
154
155
156
157
158
159
160
161
162
*/
pipe float    chan_PRNG2GA_LS_float_prng     __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS2_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS3_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS4_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS5_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS6_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS7_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS8_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
pipe float    chan_PRNG2GA_LS9_float_prng    __attribute__((xcl_reqd_pipe_depth(64)));
163
164
165
166
167
168
169

// Turn-off signals to PRNG generators

// FIXME: these channels don't go anymore through IGL_Arbiter.
// That was initially the case, but was fixed.
// Name should be changed accordingly (GA instead of Arbiter)
// to avoid misleading data-flow information
lvs's avatar
lvs committed
170
171
172

// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
173
174
175
176
177
178
179
180
181
182
183
184
185
pipe bool    chan_Arbiter_BT_ushort_float_off;
pipe bool    chan_Arbiter_GG_uchar_off;
pipe bool    chan_Arbiter_GG_float_off;
pipe bool    chan_Arbiter_LS123_ushort_off;
pipe bool    chan_Arbiter_LS_float_off;
pipe bool    chan_Arbiter_LS2_float_off;
pipe bool    chan_Arbiter_LS3_float_off;
pipe bool    chan_Arbiter_LS4_float_off;
pipe bool    chan_Arbiter_LS5_float_off;
pipe bool    chan_Arbiter_LS6_float_off;
pipe bool    chan_Arbiter_LS7_float_off;
pipe bool    chan_Arbiter_LS8_float_off;
pipe bool    chan_Arbiter_LS9_float_off;
lvs's avatar
lvs committed
186
*/
187
/*
lvs's avatar
lvs committed
188
189
190
191
192
193
194
195
196
197
198
199
200
pipe bool    chan_Arbiter_BT_ushort_float_off	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_GG_uchar_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_GG_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS123_ushort_off	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS2_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS3_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS4_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS5_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS6_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS7_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS8_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_Arbiter_LS9_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
201
202
203
204
205
206
207
208
209
210
211
212
213
214
*/
pipe int    chan_Arbiter_BT_ushort_float_off	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_GG_uchar_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_GG_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS123_ushort_off	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS2_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS3_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS4_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS5_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS6_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS7_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS8_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_Arbiter_LS9_float_off		__attribute__((xcl_reqd_pipe_depth(16)));
215
216

// Send energy values and genotypes to LSs
lvs's avatar
lvs committed
217
218
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
219
220
221
222
223
224
225
226
227
pipe float   chan_GA2LS_LS1_energy;
pipe float   chan_GA2LS_LS2_energy;
pipe float   chan_GA2LS_LS3_energy;
pipe float   chan_GA2LS_LS4_energy;
pipe float   chan_GA2LS_LS5_energy;
pipe float   chan_GA2LS_LS6_energy;
pipe float   chan_GA2LS_LS7_energy;
pipe float   chan_GA2LS_LS8_energy;
pipe float   chan_GA2LS_LS9_energy;
lvs's avatar
lvs committed
228
229
230
231
232
233
234
235
236
237
238
239
240
*/
pipe float   chan_GA2LS_LS1_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS2_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS3_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS4_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS5_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS6_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS7_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS8_energy	__attribute__((xcl_reqd_pipe_depth(16)));
pipe float   chan_GA2LS_LS9_energy	__attribute__((xcl_reqd_pipe_depth(16)));

// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
241
242
243
244
245
246
247
248
249
pipe float   chan_GA2LS_LS1_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS2_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS3_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS4_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS5_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS6_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS7_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS8_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_GA2LS_LS9_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
250
251
252
253
254
255
256
257
258
259
*/
pipe float   chan_GA2LS_LS1_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS2_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS3_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS4_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS5_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS6_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS7_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS8_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_GA2LS_LS9_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
Leonardo Solis's avatar
Leonardo Solis committed
260

261
// Send LS status from LSs to IGL_Arbiter
lvs's avatar
lvs committed
262
/*
lvs's avatar
lvs committed
263
264
265
266
267
268
269
270
271
pipe bool    chan_LS2Arbiter_LS1_end;
pipe bool    chan_LS2Arbiter_LS2_end;
pipe bool    chan_LS2Arbiter_LS3_end;
pipe bool    chan_LS2Arbiter_LS4_end;
pipe bool    chan_LS2Arbiter_LS5_end;
pipe bool    chan_LS2Arbiter_LS6_end;
pipe bool    chan_LS2Arbiter_LS7_end;
pipe bool    chan_LS2Arbiter_LS8_end;
pipe bool    chan_LS2Arbiter_LS9_end;
lvs's avatar
lvs committed
272
*/
273
/*
lvs's avatar
lvs committed
274
275
276
277
278
279
280
281
282
pipe bool    chan_LS2Arbiter_LS1_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS2_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS3_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS4_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS5_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS6_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS7_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS8_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_LS2Arbiter_LS9_end	__attribute__((xcl_reqd_pipe_depth(16)));
283
284
285
286
287
288
289
290
291
292
*/
pipe int    chan_LS2Arbiter_LS1_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS2_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS3_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS4_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS5_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS6_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS7_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS8_end	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_LS2Arbiter_LS9_end	__attribute__((xcl_reqd_pipe_depth(16)));
293
// Get LS-eval-count, new energy, new genotype from LSs
lvs's avatar
lvs committed
294
295
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
296
297
298
299
300
301
302
303
304
pipe float2  chan_LS2GA_LS1_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS2_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS3_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS4_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS5_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS6_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS7_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS8_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
pipe float2  chan_LS2GA_LS9_evalenergy      __attribute__((xcl_reqd_pipe_depth(2)));
lvs's avatar
lvs committed
305
306
307
308
309
310
311
312
313
314
315
316
317
*/
pipe float2  chan_LS2GA_LS1_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS2_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS3_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS4_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS5_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS6_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS7_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS8_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));
pipe float2  chan_LS2GA_LS9_evalenergy      __attribute__((xcl_reqd_pipe_depth(16)));

// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
318
319
320
321
322
323
324
325
326
pipe float   chan_LS2GA_LS1_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS2_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS3_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS4_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS5_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS6_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS7_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS8_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
pipe float   chan_LS2GA_LS9_genotype        __attribute__((xcl_reqd_pipe_depth(CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
327
328
329
330
331
332
333
334
335
336
*/
pipe float   chan_LS2GA_LS1_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS2_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS3_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS4_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS5_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS6_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS7_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS8_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
pipe float   chan_LS2GA_LS9_genotype        __attribute__((xcl_reqd_pipe_depth(64)));
Leonardo Solis's avatar
Leonardo Solis committed
337

338
// Turn-off signals to LSs
lvs's avatar
lvs committed
339
340
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
341
342
343
344
345
346
347
348
349
pipe bool    chan_GA2LS_Off1_active;
pipe bool    chan_GA2LS_Off2_active;
pipe bool    chan_GA2LS_Off3_active;
pipe bool    chan_GA2LS_Off4_active;
pipe bool    chan_GA2LS_Off5_active;
pipe bool    chan_GA2LS_Off6_active;
pipe bool    chan_GA2LS_Off7_active;
pipe bool    chan_GA2LS_Off8_active;
pipe bool    chan_GA2LS_Off9_active;
lvs's avatar
lvs committed
350
*/
351
/*
lvs's avatar
lvs committed
352
353
354
355
356
357
358
359
360
pipe bool    chan_GA2LS_Off1_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off2_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off3_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off4_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off5_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off6_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off7_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off8_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe bool    chan_GA2LS_Off9_active	__attribute__((xcl_reqd_pipe_depth(16)));
361
362
363
364
365
366
367
368
369
370
*/
pipe int    chan_GA2LS_Off1_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off2_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off3_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off4_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off5_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off6_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off7_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off8_active	__attribute__((xcl_reqd_pipe_depth(16)));
pipe int    chan_GA2LS_Off9_active	__attribute__((xcl_reqd_pipe_depth(16)));
lvs's avatar
lvs committed
371
372

// Send genotype-producer-pipe selector and genotype 
373
// from IGL_Arbiter to Conform
lvs's avatar
lvs committed
374
375
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
376
377
pipe char2  chan_IGL2Conform_actmode	    __attribute__((xcl_reqd_pipe_depth(9))); // active, mode
pipe float  chan_IGL2Conform_genotype       __attribute__((xcl_reqd_pipe_depth(9*CHAN_DEPTH_GENOTYPE)));
lvs's avatar
lvs committed
378
*/
Leonardo Solis's avatar
Leonardo Solis committed
379
pipe char   chan_IGL2Conform_actmode	    __attribute__((xcl_reqd_pipe_depth(16))); // active, mode
lvs's avatar
lvs committed
380
pipe float  chan_IGL2Conform_genotype       __attribute__((xcl_reqd_pipe_depth(512)));
Leonardo Solis's avatar
Leonardo Solis committed
381

382
// Turn-off signal to IGL_Arbiter, Conform, InterE, IntraE
lvs's avatar
lvs committed
383
384
// Resized to valid SDAccel depths: 16, 32, ...
/*
lvs's avatar
lvs committed
385
pipe bool   chan_IGLArbiter_Off;
lvs's avatar
lvs committed
386
*/
387
/*
lvs's avatar
lvs committed
388
pipe bool   chan_IGLArbiter_Off		__attribute__((xcl_reqd_pipe_depth(16)));
389
390
*/
pipe int   chan_IGLArbiter_Off		__attribute__((xcl_reqd_pipe_depth(16)));
Leonardo Solis's avatar
Leonardo Solis committed
391

392
393
394
395
396
397
398
399
400
401
#if defined (FIXED_POINT_CONFORM) || \
    defined (FIXED_POINT_LS1)     || \
    defined (FIXED_POINT_LS2)     || \
    defined (FIXED_POINT_LS3)     || \
    defined (FIXED_POINT_LS4)     || \
    defined (FIXED_POINT_LS5)     || \
    defined (FIXED_POINT_LS6)     || \
    defined (FIXED_POINT_LS7)     || \
    defined (FIXED_POINT_LS8)     || \
    defined (FIXED_POINT_LS9)
402
403
404
#include "../defines_fixedpt.h"

typedef int3          fixedpt3;
405
typedef int4	      fixedpt4;
406
407
#endif

Leonardo Solis's avatar
Leonardo Solis committed
408
#if defined (FIXED_POINT_INTERE) || defined (FIXED_POINT_INTRAE)
409
410
411
#include "../defines_fixedpt_64.h"
#endif

Leonardo Solis's avatar
Leonardo Solis committed
412
// --------------------------------------------------------------------------
413
// Map the argument into the interval 0 - 180, or 0 - 360
Leonardo Solis's avatar
Leonardo Solis committed
414
415
416
417
418
419
420
// by adding/subtracting n*ang_max to/from it.
// Originally from: searchoptimum.c
// --------------------------------------------------------------------------

float map_angle_180(float angle)
{
	float x = angle;
421
422
423
424
425
426
	//while (x < 0.0f)
	if (x < 0.0f)   
	{ x += 180.0f; }
	//while (x > 180.0f)
	if (x > 180.0f) 
	{ x -= 180.0f; }
Leonardo Solis's avatar
Leonardo Solis committed
427
428
429
430
431
432
	return x;
}

float map_angle_360(float angle)
{
	float x = angle;
433
434
435
436
437
438
	//while (x < 0.0f)
	if (x < 0.0f)
	{ x += 360.0f; }
	//while (x > 360.0f)
	if (x > 360.0f)
	{ x -= 360.0f;}
Leonardo Solis's avatar
Leonardo Solis committed
439
440
441
	return x;
}

442
443
444
445
446
447
448
449
450
#if defined (FIXED_POINT_LS1) || \
    defined (FIXED_POINT_LS2) || \
    defined (FIXED_POINT_LS3) || \
    defined (FIXED_POINT_LS4) || \
    defined (FIXED_POINT_LS5) || \
    defined (FIXED_POINT_LS6) || \
    defined (FIXED_POINT_LS7) || \
    defined (FIXED_POINT_LS8) || \
    defined (FIXED_POINT_LS9)
451
452
453
454
455
456
#define FIXEDPT_180	0xB40000
#define FIXEDPT_360	0x1680000

fixedpt fixedpt_map_angle_180(fixedpt angle)
{
	fixedpt x = angle;
457
458
459
460
461
462
	//while (x < 0.0f) 
	if (x < 0)
	{ x += FIXEDPT_180; }
	//while (x > 180.0f)
	if (x > FIXEDPT_180)
	{ x -= FIXEDPT_180; }
463
464
465
466
467
468
	return x;
}

fixedpt fixedpt_map_angle_360(fixedpt angle)
{
	fixedpt x = angle;
469
470
471
472
473
474
	//while (x < 0.0f) 
	if (x < 0)
	{ x += FIXEDPT_360; }
	//while (x > 360.0f)
	if (x > FIXEDPT_360)
	{ x -= FIXEDPT_360;}
475
476
477
478
	return x;
}
#endif

479
// --------------------------------------------------------------------------
480
// Lamarckian Genetic-Algorithm (GA): GA + LS (Local Search) 
481
482
// Originally from: searchoptimum.c
// --------------------------------------------------------------------------
lvs's avatar
lvs committed
483
/*
484
__kernel __attribute__ ((max_global_work_dim(0)))
lvs's avatar
lvs committed
485
486
*/
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
lvs's avatar
lvs committed
487
488
void Krnl_GA(
	     __global       float*           restrict GlobPopulationCurrent,
489
	     __global       float*           restrict GlobEnergyCurrent,
490
491
492
493
	     #if defined(SINGLE_COPY_POP_ENE)
   	     __global       unsigned int*    restrict GlobEvals_performed,
             __global       unsigned int*    restrict GlobGens_performed,
	     #else
Leonardo Solis's avatar
Leonardo Solis committed
494
	     __global       unsigned int*    restrict GlobEvalsGenerations_performed,
495
	     #endif
Leonardo Solis's avatar
Leonardo Solis committed
496
497
498
499
500
501
502
			    unsigned int              DockConst_pop_size,
		     	    unsigned int              DockConst_num_of_energy_evals,
			    unsigned int              DockConst_num_of_generations,
		      	    float                     DockConst_tournament_rate,
			    float                     DockConst_mutation_rate,
		    	    float                     DockConst_abs_max_dmov,
			    float                     DockConst_abs_max_dang,
Leonardo Solis's avatar
Leonardo Solis committed
503
504
		    	    float                     Host_two_absmaxdmov,
			    float                     Host_two_absmaxdang,
Leonardo Solis's avatar
Leonardo Solis committed
505
506
			    float                     DockConst_crossover_rate,
			    unsigned int              DockConst_num_of_lsentities,
507
508
509
510
511
512
513
514
			    unsigned char             DockConst_num_of_genes
	     #if defined(SINGLE_COPY_POP_ENE)
	     					      ,
	                    unsigned short            Host_RunId,
			    unsigned int 	      Host_Offset_Pop,
			    unsigned int	      Host_Offset_Ene
	     #endif
	     )
515
{
516
	#if defined (DEBUG_KRNL_GA)
517
	printf("\n");
Leonardo Solis's avatar
Leonardo Solis committed
518
	printf("%-40s %u\n", "DockConst_pop_size: ",        		DockConst_pop_size);
Leonardo Solis's avatar
Leonardo Solis committed
519
520
521
522
523
524
	printf("%-40s %u\n", "DockConst_num_of_energy_evals: ",  	DockConst_num_of_energy_evals);
	printf("%-40s %u\n", "DockConst_num_of_generations: ",  	DockConst_num_of_generations);
	printf("%-40s %f\n", "DockConst_tournament_rate: ", 		DockConst_tournament_rate);
	printf("%-40s %f\n", "DockConst_mutation_rate: ", 		DockConst_mutation_rate);
	printf("%-40s +/-%fA\n", "DockConst_abs_max_dmov: ",		DockConst_abs_max_dmov);
	printf("%-40s +/-%f°\n", "DockConst_abs_max_dang: ",  		DockConst_abs_max_dang);
Leonardo Solis's avatar
Leonardo Solis committed
525
526
	printf("%-40s +/-%fA\n", "Host_two_absmaxdmov: ",		Host_two_absmaxdmov);
	printf("%-40s +/-%f°\n", "Host_two_absmaxdang: ",  		Host_two_absmaxdang);
Leonardo Solis's avatar
Leonardo Solis committed
527
	printf("%-40s %f\n", "DockConst_crossover_rate: ", 		DockConst_crossover_rate);
Leonardo Solis's avatar
Leonardo Solis committed
528
	printf("%-40s %u\n", "DockConst_num_of_lsentities: ",   	DockConst_num_of_lsentities);
Leonardo Solis's avatar
Leonardo Solis committed
529
	printf("%-40s %u\n", "DockConst_num_of_genes: ",        	DockConst_num_of_genes);
530
531
	#endif

532
	// Other banking configuration (see PopNext, eneNext) might reduce logic
533
	// but makes PopCurr stallable
Leonardo Solis's avatar
Leonardo Solis committed
534
535
536
	__local float LocalPopCurr[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH];
	__local float LocalEneCurr[MAX_POPSIZE];

Leonardo Solis's avatar
Leonardo Solis committed
537
538
539
540
541
	#if defined(SINGLE_COPY_POP_ENE)
	__global float* GlobPopCurr = & GlobPopulationCurrent [Host_Offset_Pop];
	__global float* GlobEneCurr = & GlobEnergyCurrent     [Host_Offset_Ene];
	#endif

542
	// ------------------------------------------------------------------
543
	// Initial Calculation (IC) of scores
544
	// ------------------------------------------------------------------
545
	__attribute__((xcl_pipeline_loop))
546
	LOOP_FOR_GA_IC_OUTER:
Leonardo Solis's avatar
Leonardo Solis committed
547
	for (ushort pop_cnt = 0; pop_cnt < DockConst_pop_size; pop_cnt++) {
548
		// Calculate energy
lvs's avatar
lvs committed
549
/*
550
		write_channel_altera(chan_GA2IGL_IC_active, true);
lvs's avatar
lvs committed
551
*/
552
/*
lvs's avatar
lvs committed
553
554
		const bool tmp_bool_true = true;
		write_pipe_block(chan_GA2IGL_IC_active, &tmp_bool_true);
555
556
557
*/
		const int tmp_int_zero = 0;
		write_pipe_block(chan_GA2IGL_IC_active, &tmp_int_zero);
558

lvs's avatar
lvs committed
559
560
561
/*
		mem_fence(CLK_CHANNEL_MEM_FENCE);
*/
562
		__attribute__((xcl_pipeline_loop))
563
		LOOP_FOR_GA_IC_INNER_WRITE_GENOTYPE:
Leonardo Solis's avatar
Leonardo Solis committed
564
		for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_genes; pipe_cnt++) {
565
			#if defined(SINGLE_COPY_POP_ENE)
Leonardo Solis's avatar
Leonardo Solis committed
566
			LocalPopCurr[pop_cnt][pipe_cnt & MASK_GENOTYPE] = GlobPopCurr[pop_cnt*ACTUAL_GENOTYPE_LENGTH + pipe_cnt];
567
			#else
Leonardo Solis's avatar
Leonardo Solis committed
568
			LocalPopCurr[pop_cnt][pipe_cnt & MASK_GENOTYPE] = GlobPopulationCurrent[pop_cnt*ACTUAL_GENOTYPE_LENGTH + pipe_cnt];
569
			#endif
lvs's avatar
lvs committed
570
/*
Leonardo Solis's avatar
Leonardo Solis committed
571
			write_channel_altera(chan_IC2Conf_genotype, LocalPopCurr[pop_cnt][pipe_cnt & MASK_GENOTYPE]);	
lvs's avatar
lvs committed
572
573
*/
			write_pipe_block(chan_IC2Conf_genotype, &LocalPopCurr[pop_cnt][pipe_cnt & MASK_GENOTYPE]);	
574
		}
575

Leonardo Solis's avatar
Leonardo Solis committed
576
		#if defined (DEBUG_KRNL_IC)
Leonardo Solis's avatar
Leonardo Solis committed
577
		printf("\nIC - tx pop: %u", pop_cnt); 		
Leonardo Solis's avatar
Leonardo Solis committed
578
		#endif
579

580
		// Read energy
581
582
		float energyIA_IC_rx;
		float energyIE_IC_rx;
lvs's avatar
lvs committed
583
/*
584
585
		bool intra_valid = false;
		bool inter_valid = false;
lvs's avatar
lvs committed
586
587
588
589
*/
		int intra_valid = 1;
		int inter_valid = 1;	
/*
590
		while( (intra_valid == false) || (inter_valid == false)) {
lvs's avatar
lvs committed
591
*/
592
		__attribute__((xcl_pipeline_loop))
593
		LOOP_WHILE_GA_IC_INNER_READ_ENERGY:
lvs's avatar
lvs committed
594
595
596
		while( (intra_valid != 0) || (inter_valid != 0)) {

/*
597
			if (intra_valid == false) {
lvs's avatar
lvs committed
598
599
600
*/
			if (intra_valid != 0) {

lvs's avatar
lvs committed
601
/*
602
				energyIA_IC_rx = read_channel_nb_altera(chan_Intrae2StoreIC_intrae, &intra_valid);
lvs's avatar
lvs committed
603
604
*/
				intra_valid = read_pipe(chan_Intrae2StoreIC_intrae, &energyIA_IC_rx);
605
			}
lvs's avatar
lvs committed
606
/*
Leonardo Solis's avatar
Leonardo Solis committed
607
			else if (inter_valid == false) {
lvs's avatar
lvs committed
608
609
*/
			else if (inter_valid != 0) {
lvs's avatar
lvs committed
610
/*
611
				energyIE_IC_rx = read_channel_nb_altera(chan_Intere2StoreIC_intere, &inter_valid);
lvs's avatar
lvs committed
612
613
*/
				inter_valid = read_pipe(chan_Intere2StoreIC_intere, &energyIE_IC_rx);
614
615
616
			}
		}

Leonardo Solis's avatar
Leonardo Solis committed
617
		LocalEneCurr[pop_cnt] = energyIA_IC_rx + energyIE_IC_rx;
618

619
		#if defined (DEBUG_KRNL_IC)
Leonardo Solis's avatar
Leonardo Solis committed
620
		printf(", IC - rx pop: %u\n", pop_cnt); 		
621
		#endif
Leonardo Solis's avatar
Leonardo Solis committed
622
	}
623
	// ------------------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
624

Leonardo Solis's avatar
Leonardo Solis committed
625
	uint eval_cnt = DockConst_pop_size; // takes into account the IC evals
626

Leonardo Solis's avatar
Leonardo Solis committed
627
	uint generation_cnt = 0;
Leonardo Solis's avatar
Leonardo Solis committed
628

629
630
	__attribute__((xcl_pipeline_loop))
	LOOP_WHILE_GA_MAIN:
Leonardo Solis's avatar
Leonardo Solis committed
631
	while ((eval_cnt < DockConst_num_of_energy_evals) && (generation_cnt < DockConst_num_of_generations)) {
Leonardo Solis's avatar
Leonardo Solis committed
632

633
634
635
		//float LocalPopNext[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH];
		//float LocalEneNext[MAX_POPSIZE];

636
		// This configuration reduces logic and does not increase block RAM usage
lvs's avatar
lvs committed
637
/*
638
639
640
641
642
		float __attribute__ ((
				       memory,
		   		       numbanks(4),
			               bankwidth(32),
			              )) LocalPopNext[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH];
lvs's avatar
lvs committed
643
644
*/
		float LocalPopNext[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH];
645

lvs's avatar
lvs committed
646
/*
647
648
649
650
651
		float __attribute__ ((
				       memory,
		   		       numbanks(4),
			               bankwidth(4),
			              )) LocalEneNext[MAX_POPSIZE];
lvs's avatar
lvs committed
652
653
*/
		float LocalEneNext[MAX_POPSIZE];
654

655
		// ------------------------------------------------------------------
656
		// Genetic Generation (GG)
657
		// ------------------------------------------------------------------
lvs's avatar
lvs committed
658
/*
Leonardo Solis's avatar
Leonardo Solis committed
659
660
661
662
663
		float __attribute__ ((
				       memory,
		   		       numbanks(1),
			               bankwidth(64),
			               singlepump,
664
 			               numreadports(6),
Leonardo Solis's avatar
Leonardo Solis committed
665
666
			               numwriteports(1)
			              )) loc_energies[MAX_POPSIZE];
lvs's avatar
lvs committed
667
668
*/
		float loc_energies[MAX_POPSIZE];
Leonardo Solis's avatar
Leonardo Solis committed
669
670
671

		ushort best_entity = 0;

672
673
		__attribute__((xcl_pipeline_loop))
		LOOP_FOR_GA_SHIFT: 
Leonardo Solis's avatar
Leonardo Solis committed
674
675
676
677
678
//		for (ushort pop_cnt=1; pop_cnt<DockConst_pop_size; pop_cnt++) {
		for (ushort pop_cnt=0; pop_cnt<DockConst_pop_size; pop_cnt++) {
			// copy energy to local memory
			loc_energies[pop_cnt] = LocalEneCurr[pop_cnt];

679
680
681
682
683
684
685
686
			#if defined (DEBUG_KRNL_GA)
			if (pop_cnt==0) {printf("\n");}
			printf("%3u %20.6f\n", pop_cnt, loc_energies[pop_cnt]);
			#endif

			if (loc_energies[pop_cnt] < loc_energies[best_entity]) {
				best_entity = pop_cnt;
			}
Leonardo Solis's avatar
Leonardo Solis committed
687
		}
688

689
690
691
692
		#if defined (DEBUG_KRNL_GA)
		printf("best_entity: %3u, energy: %20.6f\n", best_entity, loc_energies[best_entity]);
		#endif

693
694
		#pragma ivdep array (LocalPopNext)
		#pragma ivdep array (LocalEneNext)
695
696
		__attribute__((xcl_pipeline_loop))
		LOOP_FOR_GA_OUTER_GLOBAL: 
Leonardo Solis's avatar
Leonardo Solis committed
697
		for (ushort new_pop_cnt = 1; new_pop_cnt < DockConst_pop_size; new_pop_cnt++) {
698
699

			// ---------------------------------------------------
700
			// Elitism: copying the best entity to new population
701
702
			// ---------------------------------------------------
			if (new_pop_cnt == 1) {
Leonardo Solis's avatar
Leonardo Solis committed
703
/*
704
				#pragma unroll
Leonardo Solis's avatar
Leonardo Solis committed
705
706
*/
				__attribute__((opencl_unroll_hint))
707
				LOOP_FOR_GA_INNER_ELITISM:
708
				for (uchar gene_cnt=0; gene_cnt<ACTUAL_GENOTYPE_LENGTH; gene_cnt++) { 		
Leonardo Solis's avatar
Leonardo Solis committed
709
					LocalPopNext[0][gene_cnt & MASK_GENOTYPE] = LocalPopCurr[best_entity][gene_cnt & MASK_GENOTYPE]; 	
710
711
712
713
				} 		
				LocalEneNext[0] = loc_energies[best_entity];
			}

714
			#if defined (DEBUG_KRNL_GA)
715
			printf("Krnl_GA: %u\n", new_pop_cnt);
716
			#endif
Leonardo Solis's avatar
Leonardo Solis committed
717

Leonardo Solis's avatar
Leonardo Solis committed
718
719
			float local_entity_1 [ACTUAL_GENOTYPE_LENGTH];
			float local_entity_2 [ACTUAL_GENOTYPE_LENGTH]; 
Leonardo Solis's avatar
Leonardo Solis committed
720
		
721
			// ---------------------------------------------------
722
			// Binary-Tournament (BT) selection
723
			// ---------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
724

725
726
			// Get ushort binary_tournament selection prngs (parent index)
			// Get float binary_tournament selection prngs (tournament rate)
lvs's avatar
lvs committed
727
/*
728
			float8 bt_tmp = read_channel_altera(chan_PRNG2GA_BT_ushort_float_prng);
lvs's avatar
lvs committed
729
730
731
732
*/
			float8 bt_tmp;
			read_pipe_block(chan_PRNG2GA_BT_ushort_float_prng, &bt_tmp);
/*
Leonardo Solis's avatar
Leonardo Solis committed
733
			mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
734
*/
Leonardo Solis's avatar
Leonardo Solis committed
735
//printf("test point 1\n");
736
			// Convert: float prng that must be still converted to short
737
738
739
740
741
			float bt_tmp_uf0 = bt_tmp.s0;
			float bt_tmp_uf1 = bt_tmp.s2;
			float bt_tmp_uf2 = bt_tmp.s4;
			float bt_tmp_uf3 = bt_tmp.s6;

Leonardo Solis's avatar
Leonardo Solis committed
742
			// short prng ready to be used, replace ushort prng_BT_U[4];
743
/*
744
745
746
747
			ushort bt_tmp_u0 = *(uint*)&bt_tmp_uf0;
			ushort bt_tmp_u1 = *(uint*)&bt_tmp_uf1;
			ushort bt_tmp_u2 = *(uint*)&bt_tmp_uf2;
			ushort bt_tmp_u3 = *(uint*)&bt_tmp_uf3;
748
749
750
751
752
753
754
*/
			// Check "Krnl_Prng_BT_ushort_float"
			// To surpass error in hw_emu		
			ushort bt_tmp_u0 = bt_tmp_uf0;
			ushort bt_tmp_u1 = bt_tmp_uf1;
			ushort bt_tmp_u2 = bt_tmp_uf2;
			ushort bt_tmp_u3 = bt_tmp_uf3;
755

Leonardo Solis's avatar
Leonardo Solis committed
756
			// float prng ready to used, replace float prng_BT_F[4];
757
758
759
760
761
			float bt_tmp_f0 = bt_tmp.s1;
			float bt_tmp_f1 = bt_tmp.s3;
			float bt_tmp_f2 = bt_tmp.s5;
			float bt_tmp_f3 = bt_tmp.s7;

Leonardo Solis's avatar
Leonardo Solis committed
762
763
			ushort parent1;
			ushort parent2; 
Leonardo Solis's avatar
Leonardo Solis committed
764

765
			// First parent
766
767
768
769
770
771
772
			if (loc_energies[bt_tmp_u0] < loc_energies[bt_tmp_u1]) {
				if (bt_tmp_f0 < DockConst_tournament_rate) {parent1 = bt_tmp_u0;}
				else				           {parent1 = bt_tmp_u1;}}
			else {
				if (bt_tmp_f1 < DockConst_tournament_rate) {parent1 = bt_tmp_u1;}
				else				           {parent1 = bt_tmp_u0;}}

773
			// The better will be the second parent
774
775
776
777
778
779
			if (loc_energies[bt_tmp_u2] < loc_energies[bt_tmp_u3]) {
				if (bt_tmp_f2 < DockConst_tournament_rate) {parent2 = bt_tmp_u2;}
				else		          	           {parent2 = bt_tmp_u3;}}
			else {
				if (bt_tmp_f3 < DockConst_tournament_rate) {parent2 = bt_tmp_u3;}
				else			                   {parent2 = bt_tmp_u2;}}
Leonardo Solis's avatar
Leonardo Solis committed
780

781
782
			__attribute__((xcl_pipeline_loop))
			LOOP_FOR_GA_INNER_BT:
Leonardo Solis's avatar
Leonardo Solis committed
783
			// local_entity_1 and local_entity_2 are population-parent1, population-parent2
Leonardo Solis's avatar
Leonardo Solis committed
784
			for (uchar gene_cnt=0; gene_cnt<DockConst_num_of_genes; gene_cnt++) {
785
786
				local_entity_1[gene_cnt & MASK_GENOTYPE] = LocalPopCurr[parent1][gene_cnt & MASK_GENOTYPE];
				local_entity_2[gene_cnt & MASK_GENOTYPE] = LocalPopCurr[parent2][gene_cnt & MASK_GENOTYPE];
Leonardo Solis's avatar
Leonardo Solis committed
787
			}
788

789
			// ---------------------------------------------------
790
			// Mating parents
791
			// ---------------------------------------------------	
Leonardo Solis's avatar
Leonardo Solis committed
792

793
794
			// get uchar genetic_generation prngs (gene index)
			// get float genetic_generation prngs (mutation rate)
lvs's avatar
lvs committed
795
/*
796
			uchar2 prng_GG_C = read_channel_altera(chan_PRNG2GA_GG_uchar_prng);
lvs's avatar
lvs committed
797
798
799
800
*/
			uchar2 prng_GG_C;
			read_pipe_block(chan_PRNG2GA_GG_uchar_prng, &prng_GG_C);
/*
Leonardo Solis's avatar
Leonardo Solis committed
801
			mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
802
*/
Leonardo Solis's avatar
Leonardo Solis committed
803
//printf("test point 2\n");
Leonardo Solis's avatar
Leonardo Solis committed
804
805
806
807

			uchar covr_point_low;
			uchar covr_point_high;
			bool twopoint_cross_yes = false;
Leonardo Solis's avatar
Leonardo Solis committed
808

809
810
811
			if (prng_GG_C.x == prng_GG_C.y) {covr_point_low = prng_GG_C.x;}
			else {
				twopoint_cross_yes = true;
Leonardo Solis's avatar
Leonardo Solis committed
812
813
814
815
				if (prng_GG_C.x < prng_GG_C.y) { covr_point_low  = prng_GG_C.x;
					                         covr_point_high = prng_GG_C.y; }
				else {		      		 covr_point_low  = prng_GG_C.y;
   								 covr_point_high = prng_GG_C.x; }
816
817
			}
			
818
			// Reuse of bt prng float as crossover-rate
Leonardo Solis's avatar
Leonardo Solis committed
819
			bool crossover_yes = (DockConst_crossover_rate > bt_tmp_f0);
lvs's avatar
lvs committed
820
/*
Leonardo Solis's avatar
Leonardo Solis committed
821
			write_channel_altera(chan_GA2IGL_GG_active, true);
lvs's avatar
lvs committed
822
*/
823
/*
lvs's avatar
lvs committed
824
825
			const bool tmp_bool_true = true;
			write_pipe_block(chan_GA2IGL_GG_active, &tmp_bool_true);
826
827
828
*/
			const int tmp_int_zero = 0;
			write_pipe_block(chan_GA2IGL_GG_active, &tmp_int_zero);
lvs's avatar
lvs committed
829
/*
Leonardo Solis's avatar
Leonardo Solis committed
830
			mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
831
*/
Leonardo Solis's avatar
Leonardo Solis committed
832
//printf("test point 3\n");
Leonardo Solis's avatar
Leonardo Solis committed
833

834
835
			__attribute__((xcl_pipeline_loop))
			LOOP_FOR_GA_INNER_CROSS_MUT:
Leonardo Solis's avatar
Leonardo Solis committed
836
			for (uchar gene_cnt=0; gene_cnt<DockConst_num_of_genes; gene_cnt++) {
lvs's avatar
lvs committed
837
/*
Leonardo Solis's avatar
Leonardo Solis committed
838
				float prngGG = read_channel_altera(chan_PRNG2GA_GG_float_prng);
lvs's avatar
lvs committed
839
840
841
842
*/
				float prngGG;
				read_pipe_block(chan_PRNG2GA_GG_float_prng, &prngGG);
/*
Leonardo Solis's avatar
Leonardo Solis committed
843
				mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
844
*/
Leonardo Solis's avatar
Leonardo Solis committed
845
//printf("test point 4\n");
Leonardo Solis's avatar
Leonardo Solis committed
846

Leonardo Solis's avatar
Leonardo Solis committed
847
				float tmp_offspring;
Leonardo Solis's avatar
Leonardo Solis committed
848

849
				// Performing crossover
Leonardo Solis's avatar
Leonardo Solis committed
850
851
852
853
854
855
856
				if (   	(
					crossover_yes && (										// crossover
					( (twopoint_cross_yes == true)  && ((gene_cnt <= covr_point_low) || (gene_cnt > covr_point_high)) )  ||	// two-point crossover 			 		
					( (twopoint_cross_yes == false) && (gene_cnt <= covr_point_low))  					// one-point crossover
					)) || 
					(!crossover_yes)	// no crossover
				   ) {
857
					tmp_offspring = local_entity_1[gene_cnt & MASK_GENOTYPE];
Leonardo Solis's avatar
Leonardo Solis committed
858
859
				}
				else {
860
					tmp_offspring = local_entity_2[gene_cnt & MASK_GENOTYPE];
Leonardo Solis's avatar
Leonardo Solis committed
861
862
				}

863
				// Performing mutation
Leonardo Solis's avatar
Leonardo Solis committed
864
				if (DockConst_mutation_rate > prngGG) {
Leonardo Solis's avatar
Leonardo Solis committed
865
					if(gene_cnt<3) {
Leonardo Solis's avatar
Leonardo Solis committed
866
						tmp_offspring = tmp_offspring + Host_two_absmaxdmov*prngGG-DockConst_abs_max_dmov;
Leonardo Solis's avatar
Leonardo Solis committed
867
868
869
					}
					else {
						float tmp;
Leonardo Solis's avatar
Leonardo Solis committed
870
871
872
						tmp = tmp_offspring + Host_two_absmaxdang*prngGG-DockConst_abs_max_dang;
						if (gene_cnt==4) { tmp_offspring = map_angle_180(tmp); }
						else             { tmp_offspring = map_angle_360(tmp); }
Leonardo Solis's avatar
Leonardo Solis committed
873
874
875
					}
				}

876
				// Calculate energy
Leonardo Solis's avatar
Leonardo Solis committed
877
				LocalPopNext [new_pop_cnt][gene_cnt & MASK_GENOTYPE] = tmp_offspring;
lvs's avatar
lvs committed
878
/*
879
				write_channel_altera(chan_GG2Conf_genotype, tmp_offspring);
lvs's avatar
lvs committed
880
881
*/
				write_pipe_block(chan_GG2Conf_genotype, &tmp_offspring);
Leonardo Solis's avatar
Leonardo Solis committed
882
//printf("test point 5\n");
Leonardo Solis's avatar
Leonardo Solis committed
883
			}
884

885
			#if defined (DEBUG_KRNL_GG)
Leonardo Solis's avatar
Leonardo Solis committed
886
			printf("GG - tx pop: %u", new_pop_cnt); 		
887
			#endif	
888

889
			// Read energy
890
891
			float energyIA_GG_rx;
			float energyIE_GG_rx;
lvs's avatar
lvs committed
892
/*
893
894
			bool intra_valid = false;
			bool inter_valid = false;
lvs's avatar
lvs committed
895
896
897
898
899
*/
			int intra_valid = 1;
			int inter_valid = 1;

/*
900
			while( (intra_valid == false) || (inter_valid == false)) {
lvs's avatar
lvs committed
901
*/
902
903
			__attribute__((xcl_pipeline_loop))
			LOOP_WHILE_GA_INNER_READ_ENERGIES:
lvs's avatar
lvs committed
904
905
			while( (intra_valid != 0) || (inter_valid != 0)) {
/*
906
				if (intra_valid == false) {
lvs's avatar
lvs committed
907
908
*/
				if (intra_valid != 0) {
lvs's avatar
lvs committed
909
/*
910
					energyIA_GG_rx = read_channel_nb_altera(chan_Intrae2StoreGG_intrae, &intra_valid);
lvs's avatar
lvs committed
911
912
*/
					intra_valid = read_pipe(chan_Intrae2StoreGG_intrae, &energyIA_GG_rx);
913
				}
lvs's avatar
lvs committed
914
/*
Leonardo Solis's avatar
Leonardo Solis committed
915
				else if (inter_valid == false) {
lvs's avatar
lvs committed
916
917
*/
				else if (inter_valid != 0) {
lvs's avatar
lvs committed
918
/*
919
					energyIE_GG_rx = read_channel_nb_altera(chan_Intere2StoreGG_intere, &inter_valid);
lvs's avatar
lvs committed
920
921
*/
					inter_valid = read_pipe(chan_Intere2StoreGG_intere, &energyIE_GG_rx);
922
				}
923

Leonardo Solis's avatar
Leonardo Solis committed
924
//printf("intra_valid: %i, inter_valid: %i\n", intra_valid, inter_valid);
925
			}
Leonardo Solis's avatar
Leonardo Solis committed
926
//printf("test point 5\n");			
Leonardo Solis's avatar
Leonardo Solis committed
927
			LocalEneNext[new_pop_cnt] = energyIA_GG_rx + energyIE_GG_rx;
Leonardo Solis's avatar
Leonardo Solis committed
928

929
			#if defined (DEBUG_KRNL_GG)
Leonardo Solis's avatar
Leonardo Solis committed
930
			printf(", GG - rx pop: %u\n", new_pop_cnt); 		
931
			#endif
Leonardo Solis's avatar
Leonardo Solis committed
932
		} 
933
934
		// ------------------------------------------------------------------
		// LS: Local Search
935
		// Subject num_of_entity_for_ls pieces of offsprings to LS 
Leonardo Solis's avatar
Leonardo Solis committed
936
		// ------------------------------------------------------------------
937

Leonardo Solis's avatar
Leonardo Solis committed
938
		uint ls_eval_cnt = 0;
Leonardo Solis's avatar
Leonardo Solis committed
939

Leonardo Solis's avatar
Leonardo Solis committed
940
		#pragma ivdep
941
942
		__attribute__((xcl_pipeline_loop))
		LOOP_FOR_GA_LS_OUTER:
943
		for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt+=9) {
Leonardo Solis's avatar
Leonardo Solis committed
944

945
			// Choose random & different entities on every iteration
lvs's avatar
lvs committed
946
/*
947
			ushort16 entity_ls = read_channel_altera(chan_PRNG2GA_LS123_ushort_prng);
lvs's avatar
lvs committed
948
949
950
951
*/
			ushort16 entity_ls;
			read_pipe_block(chan_PRNG2GA_LS123_ushort_prng, &entity_ls);
/*
Leonardo Solis's avatar
Leonardo Solis committed
952
			mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
953
*/
954
//printf("test point LS 1\n");
Leonardo Solis's avatar
Leonardo Solis committed
955

Leonardo Solis's avatar
Leonardo Solis committed
956
957
958
959
960
			ushort entity_ls1 = entity_ls.s0;
			ushort entity_ls2 = entity_ls.s1;
			ushort entity_ls3 = entity_ls.s2;
			ushort entity_ls4 = entity_ls.s3;
			ushort entity_ls5 = entity_ls.s4;
961
962
963
964
			ushort entity_ls6 = entity_ls.s5;
			ushort entity_ls7 = entity_ls.s6;
			ushort entity_ls8 = entity_ls.s7;
			ushort entity_ls9 = entity_ls.s8;
965

lvs's avatar
lvs committed
966
/*
967
968
969
			write_channel_altera(chan_GA2LS_LS1_energy, LocalEneNext[entity_ls1]);
			write_channel_altera(chan_GA2LS_LS2_energy, LocalEneNext[entity_ls2]);
			write_channel_altera(chan_GA2LS_LS3_energy, LocalEneNext[entity_ls3]);
Leonardo Solis's avatar
Leonardo Solis committed
970
971
			write_channel_altera(chan_GA2LS_LS4_energy, LocalEneNext[entity_ls4]);
			write_channel_altera(chan_GA2LS_LS5_energy, LocalEneNext[entity_ls5]);
972
973
974
975
			write_channel_altera(chan_GA2LS_LS6_energy, LocalEneNext[entity_ls6]);
			write_channel_altera(chan_GA2LS_LS7_energy, LocalEneNext[entity_ls7]);
			write_channel_altera(chan_GA2LS_LS8_energy, LocalEneNext[entity_ls8]);
			write_channel_altera(chan_GA2LS_LS9_energy, LocalEneNext[entity_ls9]);
lvs's avatar
lvs committed
976
977
978
979
980
981
982
983
984
985
*/
			write_pipe_block(chan_GA2LS_LS1_energy, &LocalEneNext[entity_ls1]);
			write_pipe_block(chan_GA2LS_LS2_energy, &LocalEneNext[entity_ls2]);
			write_pipe_block(chan_GA2LS_LS3_energy, &LocalEneNext[entity_ls3]);
			write_pipe_block(chan_GA2LS_LS4_energy, &LocalEneNext[entity_ls4]);
			write_pipe_block(chan_GA2LS_LS5_energy, &LocalEneNext[entity_ls5]);
			write_pipe_block(chan_GA2LS_LS6_energy, &LocalEneNext[entity_ls6]);
			write_pipe_block(chan_GA2LS_LS7_energy, &LocalEneNext[entity_ls7]);
			write_pipe_block(chan_GA2LS_LS8_energy, &LocalEneNext[entity_ls8]);
			write_pipe_block(chan_GA2LS_LS9_energy, &LocalEneNext[entity_ls9]);
986
987

//printf("test point LS 2\n");
lvs's avatar
lvs committed
988
/*
Leonardo Solis's avatar
Leonardo Solis committed
989
			mem_fence(CLK_CHANNEL_MEM_FENCE);
lvs's avatar
lvs committed
990
*/
991
992
			__attribute__((xcl_pipeline_loop))
			LOOP_GA_LS_INNER_WRITE_GENOTYPE: