Krnl_PRNG.cl 18.3 KB
Newer Older
Leonardo Solis's avatar
Leonardo Solis committed
1
// --------------------------------------------------------------------------
2
3
// PRNG generators are implemented as Linear Feedback Shift Registers (LFSR)
// All are 32-bit LFRS, feedback taps: 30, 20, 26, 25
Leonardo Solis's avatar
Leonardo Solis committed
4
// --------------------------------------------------------------------------
lvs's avatar
lvs committed
5
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
6
7
void Krnl_Prng_BT_ushort_float(
			       unsigned int Host_seed1,
8
			       unsigned int Host_seed2,
9
10
11
			       unsigned int DockConst_pop_size

#if !defined(SW_EMU)
12
13
			      // IMPORTANT: enable this dummy global argument only for "hw" build.
			      // Check ../common_xilinx/utility/boards.mk
14
15
16
17
18
			      // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
			      ,
			      __global int *dummy
#endif
){
19
20
21
	uint2 lfsr;
	lfsr.x = Host_seed1;
	lfsr.y = Host_seed2;
22
23

	nb_pipe_status valid = PIPE_STATUS_FAILURE;
24
	
25
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
26
	LOOP_WHILE_PRNG_BT_USHORT_FLOAT:
27
	while(valid != PIPE_STATUS_SUCCESS) {	
28
/*
29
		bool active = true;
30
31
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
32
		valid = read_pipe(chan_GA2PRNG_BT_ushort_float_off, &active);
33
34
35
36

		uint   u_tmp[4]; // used as short in GA
		float  f_tmp[4];	

Leonardo Solis's avatar
Leonardo Solis committed
37
		__attribute__((opencl_unroll_hint))
Leonardo Solis's avatar
Leonardo Solis committed
38
		LOOP_FOR_PRNG_BT_USHORT_FLOAT:
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
		for(uchar i=0; i<4; i++) {
			uchar2 lsb;

			lsb.x = lfsr.x & 0x01u;
			lsb.y = lfsr.y & 0x01u;

			lfsr.x >>= 1;
			lfsr.y >>= 1;

			lfsr.x ^= (-lsb.x) & 0xA3000000u;
			lfsr.y ^= (-lsb.y) & 0xA3000000u;

			u_tmp[i] = (lfsr.x/MAX_UINT)*DockConst_pop_size;
			f_tmp[i] = (0.999999f/MAX_UINT)*lfsr.y;
		}
54
55
56
57

		nb_pipe_status success = PIPE_STATUS_FAILURE;

		if(valid != PIPE_STATUS_SUCCESS) {
58
59
60
61
62
63
64
65
66
67
68
			// Check "Krnl_GA"
			// To surpass error in hw_emu
			float u_tmp_float_0 = u_tmp[0];
			float u_tmp_float_1 = u_tmp[1];
			float u_tmp_float_2 = u_tmp[2];
			float u_tmp_float_3 = u_tmp[3];

			float8 tmp = {u_tmp_float_0, f_tmp[0],
				      u_tmp_float_1, f_tmp[1],
				      u_tmp_float_2, f_tmp[2],
				      u_tmp_float_3, f_tmp[3]};
Leonardo Solis's avatar
Leonardo Solis committed
69

lvs's avatar
lvs committed
70
			success = write_pipe(chan_PRNG2GA_BT_ushort_float_prng, &tmp);
71
		}
72
	} // End of while(valid != PIPE_STATUS_SUCCESS)
73
74
75
76
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
lvs's avatar
lvs committed
77
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
78
79
80
81
82
void Krnl_Prng_GG_uchar(
			unsigned int  Host_seed, 
		        unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
83
84
			// IMPORTANT: enable this dummy global argument only for "hw" build.
			// Check ../common_xilinx/utility/boards.mk
85
86
87
88
89
		        // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
			,
			__global int *dummy
#endif
){
90
	uint lfsr = Host_seed;
Leonardo Solis's avatar
Leonardo Solis committed
91

92
93
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

94
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
95
	LOOP_WHILE_PRNG_GG_UCHAR:
96
	while(valid != PIPE_STATUS_SUCCESS) {
97
/*
98
		bool active = true;
99
100
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
101
		valid = read_pipe(chan_GA2PRNG_GG_uchar_off, &active);		
lvs's avatar
lvs committed
102

103
		uchar tmp[2];
104

Leonardo Solis's avatar
Leonardo Solis committed
105
		__attribute__((opencl_unroll_hint))
Leonardo Solis's avatar
Leonardo Solis committed
106
		LOOP_FOR_PRNG_GG_UCHAR:
107
		for(uchar i=0; i<2; i++) {
108
109
110
111
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
112
			tmp[i] = (lfsr/MAX_UINT)*DockConst_num_of_genes;
113

114
		}
115
116

		nb_pipe_status success = PIPE_STATUS_FAILURE;
lvs's avatar
lvs committed
117

118
119
120
121
		uchar2 utmp;
		utmp.x = tmp[0];
		utmp.y = tmp[1];

122
		if(valid != PIPE_STATUS_SUCCESS) {
lvs's avatar
lvs committed
123
			success = write_pipe(chan_PRNG2GA_GG_uchar_prng, &utmp);
Leonardo Solis's avatar
Leonardo Solis committed
124
		}
125
	} // while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
126
}
Leonardo Solis's avatar
Leonardo Solis committed
127

lvs's avatar
lvs committed
128
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
129
130
131
132
133
void Krnl_Prng_GG_float(
			unsigned int  Host_seed,
		        unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
134
135
			// IMPORTANT: enable this dummy global argument only for "hw" build.
			// Check ../common_xilinx/utility/boards.mk
136
137
138
139
140
		        // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		        ,
		        __global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
141
142
	uint lfsr = Host_seed;

143
144
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

145
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
146
	LOOP_WHILE_PRNG_GG_FLOAT:
147
	while(valid != PIPE_STATUS_SUCCESS) {
148
/*
Leonardo Solis's avatar
Leonardo Solis committed
149
		bool active = true;
150
151
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
152
		valid = read_pipe(chan_GA2PRNG_GG_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
153

154
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
155
		LOOP_FOR_PRNG_GG_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
156
157
158
159
160
161
162
163
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;

164
165
166
			nb_pipe_status success = PIPE_STATUS_FAILURE;

			if(valid != PIPE_STATUS_SUCCESS) {
lvs's avatar
lvs committed
167
				success = write_pipe(chan_PRNG2GA_GG_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
168
169
			}
		}
170
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
171
}
Leonardo Solis's avatar
Leonardo Solis committed
172
173
174

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
lvs's avatar
lvs committed
175
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
176
177
void Krnl_Prng_LS123_ushort(
			    unsigned int Host_seed1,
Leonardo Solis's avatar
Leonardo Solis committed
178
179
180
181
			    unsigned int Host_seed2, 
			    unsigned int Host_seed3,
			    unsigned int Host_seed4,
			    unsigned int Host_seed5, 
182
183
184
185
			    unsigned int Host_seed6, 
			    unsigned int Host_seed7,
			    unsigned int Host_seed8,
			    unsigned int Host_seed9, 
186
187
188
		            unsigned int DockConst_pop_size

#if !defined(SW_EMU)
189
190
			    // IMPORTANT: enable this dummy global argument only for "hw" build.
			    // Check ../common_xilinx/utility/boards.mk
191
192
193
194
195
		            // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
			    ,
			    __global int *dummy
#endif
){
196
	uint lfsr[9];
Leonardo Solis's avatar
Leonardo Solis committed
197
198
199
200
201
	lfsr[0] = Host_seed1;
	lfsr[1] = Host_seed2;
	lfsr[2] = Host_seed3;
	lfsr[3] = Host_seed4;
	lfsr[4] = Host_seed5;
202
203
204
205
	lfsr[5] = Host_seed6;
	lfsr[6] = Host_seed7;
	lfsr[7] = Host_seed8;
	lfsr[8] = Host_seed9;
Leonardo Solis's avatar
Leonardo Solis committed
206

207
	nb_pipe_status valid = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
208

209
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
210
	LOOP_WHILE_PRNG_LS123_USHORT:
211
	while(valid != PIPE_STATUS_SUCCESS) {
212
/*
Leonardo Solis's avatar
Leonardo Solis committed
213
		bool active = true;
214
215
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
216
		valid  = read_pipe(chan_GA2PRNG_LS123_ushort_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
217

218
		ushort tmp[9];
Leonardo Solis's avatar
Leonardo Solis committed
219
		
Leonardo Solis's avatar
Leonardo Solis committed
220
		__attribute__((opencl_unroll_hint))
Leonardo Solis's avatar
Leonardo Solis committed
221
		LOOP_FOR_PRNG_LS123_USHORT:
222
223
		for (uint i=0; i<9; i++){
			uchar  lsb[9];
Leonardo Solis's avatar
Leonardo Solis committed
224
225
226
227
228
229
			lsb [i] = lfsr[i] & 0x01u;
			lfsr[i] >>= 1;
			lfsr[i] ^= (-lsb[i]) & 0xA3000000u;
			tmp [i] = (DockConst_pop_size/MAX_UINT)*lfsr[i];
		}

230
		// To avoid having same entities undergoing LS simultaneously
Leonardo Solis's avatar
Leonardo Solis committed
231
		if (
232
233
234
235
236
237
238
239
			(tmp[0] == tmp[1]) || (tmp[0] == tmp[2]) || (tmp[0] == tmp[3]) || (tmp[0] == tmp[4]) || (tmp[0] == tmp[5]) || (tmp[0] == tmp[6]) || (tmp[0] == tmp[7]) || (tmp[0] == tmp[8]) ||
 			(tmp[1] == tmp[2]) || (tmp[1] == tmp[3]) || (tmp[1] == tmp[4]) || (tmp[1] == tmp[5]) || (tmp[1] == tmp[6]) || (tmp[1] == tmp[7]) || (tmp[1] == tmp[8]) ||
			(tmp[2] == tmp[3]) || (tmp[2] == tmp[4]) || (tmp[2] == tmp[5]) || (tmp[2] == tmp[6]) || (tmp[2] == tmp[7]) || (tmp[2] == tmp[8]) ||
			(tmp[3] == tmp[4]) || (tmp[3] == tmp[5]) || (tmp[3] == tmp[6]) || (tmp[3] == tmp[7]) || (tmp[3] == tmp[8]) ||
			(tmp[4] == tmp[5]) || (tmp[4] == tmp[6]) || (tmp[4] == tmp[7]) || (tmp[4] == tmp[8]) ||
			(tmp[5] == tmp[6]) || (tmp[5] == tmp[7]) || (tmp[5] == tmp[8]) ||
			(tmp[6] == tmp[7]) || (tmp[6] == tmp[8]) ||
			(tmp[7] == tmp[8])
Leonardo Solis's avatar
Leonardo Solis committed
240
241
242
243
244
		) {
			tmp[1] = tmp[0] + 1;
			tmp[2] = tmp[1] + 2;
			tmp[3] = tmp[2] + 3;
			tmp[4] = tmp[3] + 4;
245
246
247
248
			tmp[5] = tmp[4] + 5;
			tmp[6] = tmp[5] + 6;
			tmp[7] = tmp[6] + 7;
			tmp[8] = tmp[7] + 8;
Leonardo Solis's avatar
Leonardo Solis committed
249
250
		}

251
		nb_pipe_status success = PIPE_STATUS_FAILURE;
lvs's avatar
lvs committed
252

253
		ushort16 tmp123;
Leonardo Solis's avatar
Leonardo Solis committed
254
255
256
257
258
		tmp123.s0 = tmp[0];
		tmp123.s1 = tmp[1];
		tmp123.s2 = tmp[2];
		tmp123.s3 = tmp[3];
		tmp123.s4 = tmp[4];
259
260
261
262
		tmp123.s5 = tmp[5];
		tmp123.s6 = tmp[6];
		tmp123.s7 = tmp[7];
		tmp123.s8 = tmp[8];
Leonardo Solis's avatar
Leonardo Solis committed
263

264
		if(valid != PIPE_STATUS_SUCCESS) {
lvs's avatar
lvs committed
265
			success = write_pipe(chan_PRNG2GA_LS123_ushort_prng, &tmp123);
Leonardo Solis's avatar
Leonardo Solis committed
266
267
		}

268
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
269
}
270
271
272

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
lvs's avatar
lvs committed
273
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
274
275
276
277
278
void Krnl_Prng_LS_float(
			unsigned int  Host_seed,
		        unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
279
280
			// IMPORTANT: enable this dummy global argument only for "hw" build.
			// Check ../common_xilinx/utility/boards.mk
281
282
283
284
285
 		        // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
			,
			__global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
286
287
	uint lfsr = Host_seed;

288
289
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

290
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
291
	LOOP_WHILE_PRNG_LS_FLOAT:
292
	while(valid != PIPE_STATUS_SUCCESS) {
293
/*
Leonardo Solis's avatar
Leonardo Solis committed
294
		bool active = true;
295
296
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
297
		valid  = read_pipe(chan_GA2PRNG_LS_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
298
	
299
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
300
		LOOP_FOR_PRNG_LS_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
301
302
303
304
305
306
307
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
308
309

			nb_pipe_status success = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
310

311
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
312
				success = write_pipe(chan_PRNG2LS_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
313
314
			}
		}
315
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
316
}
Leonardo Solis's avatar
Leonardo Solis committed
317

lvs's avatar
lvs committed
318
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
319
320
321
322
323
void Krnl_Prng_LS2_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
324
325
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
326
327
328
329
330
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
331
332
	uint lfsr = Host_seed;

333
334
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

335
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
336
	LOOP_WHILE_PRNG_LS2_FLOAT:
337
	while(valid != PIPE_STATUS_SUCCESS) {
338
/*
Leonardo Solis's avatar
Leonardo Solis committed
339
		bool active = true;
340
341
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
342
		valid  = read_pipe(chan_GA2PRNG_LS2_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
343
	
344
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
345
		LOOP_FOR_PRNG_LS2_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
346
347
348
349
350
351
352
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
353
354

			nb_pipe_status success = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
355

356
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
357
				success = write_pipe(chan_PRNG2LS2_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
358
359
			}
		}
360
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
361
}
Leonardo Solis's avatar
Leonardo Solis committed
362

lvs's avatar
lvs committed
363
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
364
365
366
367
368
void Krnl_Prng_LS3_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
369
370
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
371
372
373
374
375
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
376
377
	uint lfsr = Host_seed;

378
379
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

380
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
381
	LOOP_WHILE_PRNG_LS3_FLOAT:
382
	while(valid != PIPE_STATUS_SUCCESS) {
383
/*
Leonardo Solis's avatar
Leonardo Solis committed
384
		bool active = true;
385
386
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
387
		valid  = read_pipe(chan_GA2PRNG_LS3_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
388
	
389
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
390
		LOOP_FOR_PRNG_LS3_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
391
392
393
394
395
396
397
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
398
399

			nb_pipe_status success = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
400

401
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
402
				success = write_pipe(chan_PRNG2LS3_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
403
404
			}
		}
405
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
406
}
Leonardo Solis's avatar
Leonardo Solis committed
407

lvs's avatar
lvs committed
408
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
409
410
411
412
413
void Krnl_Prng_LS4_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
414
415
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
416
417
418
419
420
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
421
422
	uint lfsr = Host_seed;

423
424
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

425
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
426
	LOOP_WHILE_PRNG_LS4_FLOAT:
427
	while(valid != PIPE_STATUS_SUCCESS) {
428
/*
Leonardo Solis's avatar
Leonardo Solis committed
429
		bool active = true;
430
431
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
432
		valid  = read_pipe(chan_GA2PRNG_LS4_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
433
	
434
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
435
		LOOP_FOR_PRNG_LS4_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
436
437
438
439
440
441
442
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
443
444

			nb_pipe_status success = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
445

446
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
447
				success = write_pipe(chan_PRNG2LS4_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
448
449
			}
		}
450
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
451
452
}

lvs's avatar
lvs committed
453
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
454
455
456
457
458
void Krnl_Prng_LS5_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
459
460
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
461
462
463
464
465
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
Leonardo Solis's avatar
Leonardo Solis committed
466
467
	uint lfsr = Host_seed;

468
469
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

470
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
471
	LOOP_WHILE_PRNG_LS5_FLOAT:
472
	while(valid != PIPE_STATUS_SUCCESS) {
473
/*
Leonardo Solis's avatar
Leonardo Solis committed
474
		bool active = true;
475
476
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
477
		valid  = read_pipe(chan_GA2PRNG_LS5_float_off, &active);
Leonardo Solis's avatar
Leonardo Solis committed
478
	
479
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
480
		LOOP_FOR_PRNG_LS5_FLOAT:
Leonardo Solis's avatar
Leonardo Solis committed
481
482
483
484
485
486
487
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
488
489

			nb_pipe_status success = PIPE_STATUS_FAILURE;
Leonardo Solis's avatar
Leonardo Solis committed
490

491
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
492
				success = write_pipe(chan_PRNG2LS5_float_prng, &tmp);
Leonardo Solis's avatar
Leonardo Solis committed
493
494
			}
		}
495
	} // End of while(valid != PIPE_STATUS_SUCCESS)
Leonardo Solis's avatar
Leonardo Solis committed
496
}
497

lvs's avatar
lvs committed
498
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
499
500
501
502
503
void Krnl_Prng_LS6_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
504
505
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
506
507
508
509
510
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
511
512
	uint lfsr = Host_seed;

513
514
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

515
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
516
	LOOP_WHILE_PRNG_LS6_FLOAT:
517
	while(valid != PIPE_STATUS_SUCCESS) {
518
/*
519
		bool active = true;
520
521
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
522
		valid  = read_pipe(chan_GA2PRNG_LS6_float_off, &active);
523
	
524
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
525
		LOOP_FOR_PRNG_LS6_FLOAT:
526
527
528
529
530
531
532
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
533
534

			nb_pipe_status success = PIPE_STATUS_FAILURE;
535

536
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
537
				success = write_pipe(chan_PRNG2LS6_float_prng, &tmp);
538
539
540
541
542
			}
		}
	} // End of while(active)
}

lvs's avatar
lvs committed
543
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
544
545
546
547
548
void Krnl_Prng_LS7_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
549
550
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
551
552
553
554
555
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
556
557
	uint lfsr = Host_seed;

558
559
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

560
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
561
	LOOP_WHILE_PRNG_LS7_FLOAT:
562
	while(valid != PIPE_STATUS_SUCCESS) {
563
/*
564
		bool active = true;
565
566
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
567
		valid  = read_pipe(chan_GA2PRNG_LS7_float_off, &active);
568
	
569
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
570
		LOOP_FOR_PRNG_LS7_FLOAT:
571
572
573
574
575
576
577
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
578
579

			nb_pipe_status success = PIPE_STATUS_FAILURE;
580

581
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
582
				success = write_pipe(chan_PRNG2LS7_float_prng, &tmp);
583
584
			}
		}
585
	} // End of while(valid != PIPE_STATUS_SUCCESS)
586
587
}

lvs's avatar
lvs committed
588
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
589
590
591
592
593
void Krnl_Prng_LS8_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
594
595
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
596
597
598
599
600
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
601
602
	uint lfsr = Host_seed;

603
604
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

605
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
606
	LOOP_WHILE_PRNG_LS8_FLOAT:
607
	while(valid != PIPE_STATUS_SUCCESS) {
608
/*
609
		bool active = true;
610
611
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
612
		valid  = read_pipe(chan_GA2PRNG_LS8_float_off, &active);
613
	
614
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
615
		LOOP_FOR_PRNG_LS8_FLOAT:
616
617
618
619
620
621
622
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
623
624

			nb_pipe_status success = PIPE_STATUS_FAILURE;
625

626
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
627
				success = write_pipe(chan_PRNG2LS8_float_prng, &tmp);
628
629
			}
		}
630
	} // End of while(valid != PIPE_STATUS_SUCCESS)
631
632
}

lvs's avatar
lvs committed
633
__kernel __attribute__ ((reqd_work_group_size(1,1,1)))
634
635
636
637
638
void Krnl_Prng_LS9_float(
			 unsigned int  Host_seed,
			 unsigned char DockConst_num_of_genes

#if !defined(SW_EMU)
639
640
			 // IMPORTANT: enable this dummy global argument only for "hw" build.
			 // Check ../common_xilinx/utility/boards.mk
641
642
643
644
645
 		         // https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
		         , 
         		 __global int *dummy
#endif
){
646
647
	uint lfsr = Host_seed;

648
649
	nb_pipe_status valid = PIPE_STATUS_FAILURE;

650
	__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
651
	LOOP_WHILE_PRNG_LS9_FLOAT:
652
	while(valid != PIPE_STATUS_SUCCESS) {
653
/*
654
		bool active = true;
655
656
*/
		int active;
Leonardo Solis's avatar
Leonardo Solis committed
657
		valid  = read_pipe(chan_GA2PRNG_LS9_float_off, &active);
658
	
659
		__attribute__((xcl_pipeline_loop))
Leonardo Solis's avatar
Leonardo Solis committed
660
		LOOP_FOR_PRNG_LS9_FLOAT:
661
662
663
664
665
666
667
		for(uchar i=0; i<DockConst_num_of_genes; i++) {
			float tmp;
			uchar lsb;
			lsb = lfsr & 0x01u;
			lfsr >>= 1;
			lfsr ^= (-lsb) & 0xA3000000u;
			tmp = (0.999999f/MAX_UINT)*lfsr;
668
669

			nb_pipe_status success = PIPE_STATUS_FAILURE;
670

671
			if(valid != PIPE_STATUS_SUCCESS) {
Leonardo Solis's avatar
Leonardo Solis committed
672
				success = write_pipe(chan_PRNG2LS9_float_prng, &tmp);
673
674
			}
		}
675
	} // End of while(valid != PIPE_STATUS_SUCCESS)
676
}
Leonardo Solis's avatar
Leonardo Solis committed
677
678
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------