Krnl_Conform.cl 18.3 KB
Newer Older
1
// --------------------------------------------------------------------------
2
3
// Conform changes the conformation of the ligand according to 
// the genotype fed by any producer logic/kernel (IC, GG, LSs).
4
5
// Originally from: processligand.c
// --------------------------------------------------------------------------
6
__kernel __attribute__ ((max_global_work_dim(0)))
7
void Krnl_Conform(
8
	     __global const int*  restrict KerConstStatic_rotlist_const,
9
	     #if defined (FIXED_POINT_CONFORM)
10
11
12
	     __constant fixedpt3* restrict KerConstStatic_ref_coords_const,
	     __constant fixedpt3* restrict KerConstStatic_rotbonds_moving_vectors_const,
	     __constant fixedpt3* restrict KerConstStatic_rotbonds_unit_vectors_const,
13
14
15
16
17
18
19
20
	     #else
	     __constant float3*   restrict KerConstStatic_ref_coords_const,
	     __constant float3*   restrict KerConstStatic_rotbonds_moving_vectors_const,
	     __constant float3*   restrict KerConstStatic_rotbonds_unit_vectors_const,
	     #endif    
			      unsigned int          DockConst_rotbondlist_length,
			      unsigned char         DockConst_num_of_atoms,
			      unsigned char         DockConst_num_of_genes,
21

22
	     #if defined (FIXED_POINT_CONFORM)
23
	     __constant fixedpt4* restrict KerConstStatic_ref_orientation_quats_const,
24
	     #else
25
	     __constant float4*   restrict KerConstStatic_ref_orientation_quats_const,
26
	     #endif
27
			      unsigned short        Host_RunId
28
)
29
{
Leonardo Solis's avatar
Leonardo Solis committed
30
31
32
33
34
35
36
	#if defined (DEBUG_KRNL_Conform) 
	printf("\n");
	printf("%-40s %u\n", "DockConst->rotbondlist_length: ",	DockConst_rotbondlist_length);
	printf("%-40s %u\n", "DockConst->num_of_atoms: ",  	DockConst_num_of_atoms);
	printf("%-40s %u\n", "DockConst_num_of_genes: ",        DockConst_num_of_genes);	
	#endif

37
	// Check best practices guide
Leonardo Solis's avatar
Leonardo Solis committed
38
	// Table 11. Effects of numbanks and bankwidth on the Bank Geometry ...
39
40
41
42
43
	// Only first three indexes of the lower array are used
	// however size of lower array was declared as 4, 
	// just to keep sizes equal to power of 2
	// __local float  __attribute__((numbanks(8), bankwidth(16))) loc_coords[MAX_NUM_OF_ATOMS][4];

44
	#if 0
Leonardo Solis's avatar
Leonardo Solis committed
45
	char active = 0x01;	
46
47
	#endif
	char active;
48

Leonardo Solis's avatar
Leonardo Solis committed
49
50
	__local int rotlist_localcache [MAX_NUM_OF_ROTATIONS];
	for (ushort c = 0; c < DockConst_rotbondlist_length; c++) {
Leonardo Solis's avatar
Leonardo Solis committed
51
		rotlist_localcache [c] = KerConstStatic_rotlist_const [c];
52
53
54
55

		if (c == (DockConst_rotbondlist_length-1)){
			active = 0x01;
		}
Leonardo Solis's avatar
Leonardo Solis committed
56
	}
57
	mem_fence(CLK_LOCAL_MEM_FENCE);
Leonardo Solis's avatar
Leonardo Solis committed
58

59
while(active) {
Leonardo Solis's avatar
Leonardo Solis committed
60
61
	char mode;

Leonardo Solis's avatar
Leonardo Solis committed
62
63
64
65
66
	#if defined (FIXED_POINT_CONFORM)
	fixedpt  phi;
	fixedpt  theta;
	fixedpt  genrotangle;
	fixedpt3 genotype_xyz;
Leonardo Solis's avatar
Leonardo Solis committed
67
68
69
70
71
72
73
	fixedpt3 __attribute__ ((
			      memory,
			      numbanks(1),
			      bankwidth(16),
			      singlepump,
			      numreadports(3),
			      numwriteports(1)
74
			    )) loc_coords [MAX_NUM_OF_ATOMS];
Leonardo Solis's avatar
Leonardo Solis committed
75
76
77
78
79
	#else
	float  phi;
	float  theta;
	float  genrotangle;
	float3 genotype_xyz;
Leonardo Solis's avatar
Leonardo Solis committed
80
81
82
83
84
85
86
	float3 __attribute__ ((
			      memory,
			      numbanks(1),
			      bankwidth(16),
			      singlepump,
			      numreadports(3),
			      numwriteports(1)
87
			    )) loc_coords [MAX_NUM_OF_ATOMS];
Leonardo Solis's avatar
Leonardo Solis committed
88
89
	#endif

90
#if 0
Leonardo Solis's avatar
Leonardo Solis committed
91
	char2 actmode = read_channel_altera(chan_IGL2Conform_actmode);
92
93
#endif
	char actmode = read_channel_altera(chan_IGL2Conform_actmode);
Leonardo Solis's avatar
Leonardo Solis committed
94
95
	mem_fence(CLK_CHANNEL_MEM_FENCE);

96
#if 0
Leonardo Solis's avatar
Leonardo Solis committed
97
	active = actmode.x;
98
	mode   = actmode.y;
99
100
101
102
#endif

	active = actmode;
	mode   = actmode;
Leonardo Solis's avatar
Leonardo Solis committed
103

104
105
//printf("Conform: %u\n", mode);

106
107
108
109
110
	#if defined (FIXED_POINT_CONFORM)
	fixedpt genotype [ACTUAL_GENOTYPE_LENGTH];
	#else
	float   genotype [ACTUAL_GENOTYPE_LENGTH];
	#endif
Leonardo Solis's avatar
Leonardo Solis committed
111

112
	for (uchar i=0; i<DockConst_num_of_genes; i++) {
113
114
		float fl_tmp;
		switch (mode) {
115
116
			case 'I':  fl_tmp = read_channel_altera(chan_IC2Conf_genotype);     break;
			case 'G':  fl_tmp = read_channel_altera(chan_GG2Conf_genotype);     break;
Leonardo Solis's avatar
Leonardo Solis committed
117
/*
118
119
120
121
122
123
124
125
126
			case 0x01: fl_tmp = read_channel_altera(chan_LS2Conf_LS1_genotype); break;
			case 0x02: fl_tmp = read_channel_altera(chan_LS2Conf_LS2_genotype); break;
			case 0x03: fl_tmp = read_channel_altera(chan_LS2Conf_LS3_genotype); break;
			case 0x04: fl_tmp = read_channel_altera(chan_LS2Conf_LS4_genotype); break;
			case 0x05: fl_tmp = read_channel_altera(chan_LS2Conf_LS5_genotype); break;
			case 0x06: fl_tmp = read_channel_altera(chan_LS2Conf_LS6_genotype); break;
			case 0x07: fl_tmp = read_channel_altera(chan_LS2Conf_LS7_genotype); break;
			case 0x08: fl_tmp = read_channel_altera(chan_LS2Conf_LS8_genotype); break;
			case 0x09: fl_tmp = read_channel_altera(chan_LS2Conf_LS9_genotype); break;
Leonardo Solis's avatar
Leonardo Solis committed
127
*/
128
129
130
131
132
133
134
135
		}
		
		if (i > 2) {
			fl_tmp = fl_tmp * DEG_TO_RAD;
		}

//printf("Conform: %u %u\n", mode, i);

136
		#if defined (FIXED_POINT_CONFORM)
137
		// Convert float to fixedpt
Leonardo Solis's avatar
Leonardo Solis committed
138
139
140
141
142
143
144
145
146
147
		fixedpt fx_tmp = fixedpt_fromfloat(fl_tmp);
		switch (i) {
			case 0: genotype_xyz.x = fx_tmp; break;
			case 1: genotype_xyz.y = fx_tmp; break;
			case 2: genotype_xyz.z = fx_tmp; break;
			case 3: phi            = fx_tmp; break;
			case 4: theta          = fx_tmp; break;
			case 5: genrotangle    = fx_tmp; break;
		}
		genotype [i] = fx_tmp;
148
		#else
Leonardo Solis's avatar
Leonardo Solis committed
149
150
151
152
153
154
155
156
157
		switch (i) {
			case 0: genotype_xyz.x = fl_tmp; break;
			case 1: genotype_xyz.y = fl_tmp; break;
			case 2: genotype_xyz.z = fl_tmp; break;
			case 3: phi            = fl_tmp; break;
			case 4: theta          = fl_tmp; break;
			case 5: genrotangle    = fl_tmp; break;
		}
		genotype [i] = fl_tmp;
158
		#endif
Leonardo Solis's avatar
Leonardo Solis committed
159
160
	}

161
	#if defined (DEBUG_ACTIVE_KERNEL)
Leonardo Solis's avatar
Leonardo Solis committed
162
	if (active == 0x00) {printf("	%-20s: %s\n", "Krnl_Conform", "must be disabled");}
163
	#endif
164

Leonardo Solis's avatar
Leonardo Solis committed
165
	for (ushort rotation_counter = 0; rotation_counter < DockConst_rotbondlist_length; rotation_counter++)
166
	{
Leonardo Solis's avatar
Leonardo Solis committed
167
		int rotation_list_element = rotlist_localcache [rotation_counter];
168

169
		if ((rotation_list_element & RLIST_DUMMY_MASK) == 0)	// If not dummy rotation
170
		{
Leonardo Solis's avatar
Leonardo Solis committed
171
			uint atom_id = rotation_list_element & RLIST_ATOMID_MASK;
172

173
			// Capturing atom coordinates
174
175
176
			#if defined (FIXED_POINT_CONFORM)
			fixedpt3 atom_to_rotate;
			#else
Leonardo Solis's avatar
Leonardo Solis committed
177
			float3 atom_to_rotate;
178
			#endif
Leonardo Solis's avatar
Leonardo Solis committed
179

180
			if ((rotation_list_element & RLIST_FIRSTROT_MASK) != 0)	// If first rotation of this atom
181
			{	
182
				atom_to_rotate = KerConstStatic_ref_coords_const [atom_id];
183
184
			}
			else
Leonardo Solis's avatar
Leonardo Solis committed
185
			{	
Leonardo Solis's avatar
Leonardo Solis committed
186
				atom_to_rotate = loc_coords[atom_id];
187
188
			}

189
			// Capturing rotation vectors and angle
190
191
192
193
194
195
196
197
198
			#if defined (FIXED_POINT_CONFORM)
			fixedpt3 rotation_unitvec;
			fixedpt3 rotation_movingvec;
			fixedpt  rotation_angle;
			#else
			float3   rotation_unitvec;
			float3   rotation_movingvec;
			float    rotation_angle;
			#endif
Leonardo Solis's avatar
Leonardo Solis committed
199

200
			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	// If general rotation
201
			{
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
				#if defined (FIXED_POINT_CONFORM)
				fixedpt  sin_theta, cos_theta;
				fixedpt3 genrot_unitvec;
				sin_theta = fixedpt_sin(theta);
				cos_theta = fixedpt_cos(theta);
				genrot_unitvec.x = fixedpt_mul(sin_theta, fixedpt_cos(phi));
				genrot_unitvec.y = fixedpt_mul(sin_theta, fixedpt_sin(phi));
				genrot_unitvec.z = cos_theta;
				#else
				float  sin_theta, cos_theta;
				float3 genrot_unitvec;
				sin_theta = native_sin(theta);
				cos_theta = native_cos(theta);
				genrot_unitvec.x = sin_theta*native_cos(phi);
				genrot_unitvec.y = sin_theta*native_sin(phi);
				genrot_unitvec.z = cos_theta;
				#endif

Leonardo Solis's avatar
Leonardo Solis committed
220
				rotation_unitvec = genrot_unitvec;
221
222
223

				rotation_angle = genrotangle;

Leonardo Solis's avatar
Leonardo Solis committed
224
				rotation_movingvec = genotype_xyz;
225
			}
226
			else	// If rotating around rotatable bond
227
			{
Leonardo Solis's avatar
Leonardo Solis committed
228
				uint rotbond_id = (rotation_list_element & RLIST_RBONDID_MASK) >> RLIST_RBONDID_SHIFT;
229

230
				rotation_unitvec = KerConstStatic_rotbonds_unit_vectors_const [rotbond_id];
Leonardo Solis's avatar
Leonardo Solis committed
231
				
Leonardo Solis's avatar
Leonardo Solis committed
232
				rotation_angle = genotype [6+rotbond_id];
Leonardo Solis's avatar
Leonardo Solis committed
233

234
				rotation_movingvec = KerConstStatic_rotbonds_moving_vectors_const [rotbond_id];
235

236
237
				// In addition performing the first movement 
				// which is needed only if rotating around rotatable bond
238
239

				#if defined (FIXED_POINT_CONFORM)
240
241
242
				atom_to_rotate.x = fixedpt_sub(atom_to_rotate.x, rotation_movingvec.x);
				atom_to_rotate.y = fixedpt_sub(atom_to_rotate.y, rotation_movingvec.y);
				atom_to_rotate.z = fixedpt_sub(atom_to_rotate.z, rotation_movingvec.z);
243
				#else
Leonardo Solis's avatar
Leonardo Solis committed
244
				atom_to_rotate -= rotation_movingvec;
245
				#endif
246
247
			}

248
			// Performing rotation
249
250
251
252
			#if defined (FIXED_POINT_CONFORM)
			fixedpt quatrot_left_x, quatrot_left_y, quatrot_left_z, quatrot_left_q;
			fixedpt quatrot_temp_x, quatrot_temp_y, quatrot_temp_z, quatrot_temp_q;
			#else
253
254
			float4 quatrot_left;
			float4 quatrot_temp;
255
			#endif
Leonardo Solis's avatar
Leonardo Solis committed
256

257
258
259
			#if defined (FIXED_POINT_CONFORM)
			rotation_angle = rotation_angle >> 1;
			#else
260
			rotation_angle = rotation_angle*0.5f;
261
262
263
264
265
266
			#endif

			#if defined (FIXED_POINT_CONFORM)
			fixedpt sin_angle, cos_angle;
			sin_angle      = fixedpt_sin(rotation_angle);
			cos_angle      = fixedpt_cos(rotation_angle);
267
268
269
			quatrot_left_x = fixedpt_mul(sin_angle, rotation_unitvec.x);
			quatrot_left_y = fixedpt_mul(sin_angle, rotation_unitvec.y);
			quatrot_left_z = fixedpt_mul(sin_angle, rotation_unitvec.z);
270
271
			quatrot_left_q = cos_angle;
			#else
Leonardo Solis's avatar
Leonardo Solis committed
272
			float sin_angle, cos_angle;
273
274
			sin_angle      = native_sin(rotation_angle);
			cos_angle      = native_cos(rotation_angle);
275
276
277
278
			quatrot_left.x = sin_angle*rotation_unitvec.x;
			quatrot_left.y = sin_angle*rotation_unitvec.y;
			quatrot_left.z = sin_angle*rotation_unitvec.z;
			quatrot_left.w = cos_angle;
279
			#endif
280

281
282
283
			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	// If general rotation, 
										// two rotations should be performed 
										// (multiplying the quaternions)
284
			{
285
286
				#if defined (FIXED_POINT_CONFORM)
				const fixedpt4 ref_orientation_quats_const = KerConstStatic_ref_orientation_quats_const[Host_RunId];
287
288
289
290
				const fixedpt  ref_orientation_quats_const_0 = ref_orientation_quats_const.x;
				const fixedpt  ref_orientation_quats_const_1 = ref_orientation_quats_const.y;
				const fixedpt  ref_orientation_quats_const_2 = ref_orientation_quats_const.z;
				const fixedpt  ref_orientation_quats_const_3 = ref_orientation_quats_const.w;
291
292
				#else
				const float4 ref_orientation_quats_const = KerConstStatic_ref_orientation_quats_const[Host_RunId];
293
294
295
296
				const float  ref_orientation_quats_const_0 = ref_orientation_quats_const.x;
				const float  ref_orientation_quats_const_1 = ref_orientation_quats_const.y;
				const float  ref_orientation_quats_const_2 = ref_orientation_quats_const.z;
				const float  ref_orientation_quats_const_3 = ref_orientation_quats_const.w;
297
298
				#endif

299
300
				// Calculating quatrot_left*ref_orientation_quats_const, 
				// which means that reference orientation rotation is the first
301
				#if defined (FIXED_POINT_CONFORM)
302
303
304
305
				quatrot_temp_q = quatrot_left_q;
				quatrot_temp_x = quatrot_left_x;
				quatrot_temp_y = quatrot_left_y;
				quatrot_temp_z = quatrot_left_z;
306
307
308
				#else
				quatrot_temp = quatrot_left;
				#endif
309

310
				// Taking the first element of ref_orientation_quats_const member
311
				#if defined (FIXED_POINT_CONFORM)
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
				quatrot_left_q =   fixedpt_mul(quatrot_temp_q, ref_orientation_quats_const_0) 
						 - fixedpt_mul(quatrot_temp_x, ref_orientation_quats_const_1) 
						 - fixedpt_mul(quatrot_temp_y, ref_orientation_quats_const_2) 
						 - fixedpt_mul(quatrot_temp_z, ref_orientation_quats_const_3);

				quatrot_left_x =   fixedpt_mul(quatrot_temp_q, ref_orientation_quats_const_1) 
						 + fixedpt_mul(quatrot_temp_x, ref_orientation_quats_const_0) 
					         + fixedpt_mul(quatrot_temp_y, ref_orientation_quats_const_3) 
						 - fixedpt_mul(quatrot_temp_z, ref_orientation_quats_const_2);

				quatrot_left_y =   fixedpt_mul(quatrot_temp_q, ref_orientation_quats_const_2)
						 - fixedpt_mul(quatrot_temp_x, ref_orientation_quats_const_3) 
  						 + fixedpt_mul(quatrot_temp_y, ref_orientation_quats_const_0) 
						 + fixedpt_mul(quatrot_temp_z, ref_orientation_quats_const_1);

				quatrot_left_z =   fixedpt_mul(quatrot_temp_q, ref_orientation_quats_const_3)
						 + fixedpt_mul(quatrot_temp_x, ref_orientation_quats_const_2) 
						 - fixedpt_mul(quatrot_temp_y, ref_orientation_quats_const_1) 
						 + fixedpt_mul(quatrot_temp_z, ref_orientation_quats_const_0);
331
				#else
332
333
334
335
336
337
338
339
340
				float4 ref4x = {   ref_orientation_quats_const_0,   ref_orientation_quats_const_3, - ref_orientation_quats_const_2, ref_orientation_quats_const_1};
				float4 ref4y = { - ref_orientation_quats_const_3,   ref_orientation_quats_const_0,   ref_orientation_quats_const_1, ref_orientation_quats_const_2};
				float4 ref4z = {   ref_orientation_quats_const_2, - ref_orientation_quats_const_1,   ref_orientation_quats_const_0, ref_orientation_quats_const_3};
				float4 ref4w = { - ref_orientation_quats_const_1, - ref_orientation_quats_const_2, - ref_orientation_quats_const_3, ref_orientation_quats_const_0};

				quatrot_left.x = dot(quatrot_temp, ref4x);
				quatrot_left.y = dot(quatrot_temp, ref4y);
				quatrot_left.z = dot(quatrot_temp, ref4z);
				quatrot_left.w = dot(quatrot_temp, ref4w);
341
				#endif
342
			}
Leonardo Solis's avatar
Leonardo Solis committed
343

344
			#if defined (FIXED_POINT_CONFORM)
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
			quatrot_temp_q = - fixedpt_mul(quatrot_left_x, atom_to_rotate.x) 
					 - fixedpt_mul(quatrot_left_y, atom_to_rotate.y)
					 - fixedpt_mul(quatrot_left_z, atom_to_rotate.z);

			quatrot_temp_x =   fixedpt_mul(quatrot_left_q, atom_to_rotate.x) 
					 + fixedpt_mul(quatrot_left_y, atom_to_rotate.z)
					 - fixedpt_mul(quatrot_left_z, atom_to_rotate.y);

			quatrot_temp_y =   fixedpt_mul(quatrot_left_q, atom_to_rotate.y)
					 - fixedpt_mul(quatrot_left_x, atom_to_rotate.z)
					 + fixedpt_mul(quatrot_left_z, atom_to_rotate.x);

			quatrot_temp_z =   fixedpt_mul(quatrot_left_q, atom_to_rotate.z)
					 + fixedpt_mul(quatrot_left_x, atom_to_rotate.y)
					 - fixedpt_mul(quatrot_left_y, atom_to_rotate.x);

			atom_to_rotate.x = - fixedpt_mul(quatrot_temp_q, quatrot_left_x)
					   + fixedpt_mul(quatrot_temp_x, quatrot_left_q)
					   - fixedpt_mul(quatrot_temp_y, quatrot_left_z)
					   + fixedpt_mul(quatrot_temp_z, quatrot_left_y);

			atom_to_rotate.y = - fixedpt_mul(quatrot_temp_q, quatrot_left_y)
					   + fixedpt_mul(quatrot_temp_x, quatrot_left_z)
					   + fixedpt_mul(quatrot_temp_y, quatrot_left_q)
					   - fixedpt_mul(quatrot_temp_z, quatrot_left_x);

			atom_to_rotate.z = - fixedpt_mul(quatrot_temp_q, quatrot_left_z)
					   - fixedpt_mul(quatrot_temp_x, quatrot_left_y)
					   + fixedpt_mul(quatrot_temp_y, quatrot_left_x)
					   + fixedpt_mul(quatrot_temp_z, quatrot_left_q);
375
			#else
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
			float3 left3x = {  quatrot_left.w, - quatrot_left.z,   quatrot_left.y};
			float3 left3y = {  quatrot_left.z,   quatrot_left.w, - quatrot_left.x};
			float3 left3z = {- quatrot_left.y,   quatrot_left.x,   quatrot_left.w};
			float3 left3w = {- quatrot_left.x, - quatrot_left.y, - quatrot_left.z};

			quatrot_temp.x = dot(left3x, atom_to_rotate);
			quatrot_temp.y = dot(left3y, atom_to_rotate);
			quatrot_temp.z = dot(left3z, atom_to_rotate);
			quatrot_temp.w = dot(left3w, atom_to_rotate);

			float4 left4x = {  quatrot_left.w, - quatrot_left.z,   quatrot_left.y, - quatrot_left.x};
			float4 left4y = {  quatrot_left.z,   quatrot_left.w, - quatrot_left.x, - quatrot_left.y};
			float4 left4z = {- quatrot_left.y,   quatrot_left.x,   quatrot_left.w, - quatrot_left.z};

			atom_to_rotate.x = dot(quatrot_temp, left4x);
			atom_to_rotate.y = dot(quatrot_temp, left4y);
			atom_to_rotate.z = dot(quatrot_temp, left4z);
393
			#endif
394

395
			// Performing final movement and storing values
Leonardo Solis's avatar
Leonardo Solis committed
396
			loc_coords[atom_id] = atom_to_rotate + rotation_movingvec;
Leonardo Solis's avatar
Leonardo Solis committed
397

398
399
400
		} // End if-statement not dummy rotation
	} // End rotation_counter for-loop

401
	#if defined (DEBUG_KRNL_CONFORM)
402
	printf("BEFORE Out CONFORM CHANNEL\n");
403
	#endif
404

405
	// --------------------------------------------------------------
406
	// Send ligand atomic coordinates to channel 
407
	// --------------------------------------------------------------
408
	/*
409
410
411
	write_channel_altera(chan_Conf2Intere_active, active);
	write_channel_altera(chan_Conf2Intrae_active, active);
	mem_fence(CLK_CHANNEL_MEM_FENCE);
412

413
414
415
	write_channel_altera(chan_Conf2Intere_mode,   mode);
	write_channel_altera(chan_Conf2Intrae_mode,   mode);
	mem_fence(CLK_CHANNEL_MEM_FENCE);
Leonardo Solis's avatar
Leonardo Solis committed
416

417
	//float3 position_xyz;
Leonardo Solis's avatar
Leonardo Solis committed
418
	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt++) {
419
420
421
422
423
		write_channel_altera(chan_Conf2Intere_xyz, loc_coords[pipe_cnt]);
		write_channel_altera(chan_Conf2Intrae_xyz, loc_coords[pipe_cnt]);
	}*/


424
	/*
425
426
	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt++) {
		if (pipe_cnt == 0) {
Leonardo Solis's avatar
Leonardo Solis committed
427
428
429
430
431
432
			char  active_tmp = active;
			char  mode_tmp   = mode;
			char2 actmode    = {active_tmp, mode_tmp};

			write_channel_altera(chan_Conf2Intere_actmode, actmode);
			write_channel_altera(chan_Conf2Intrae_actmode, actmode);
433
		}
Leonardo Solis's avatar
Leonardo Solis committed
434
		mem_fence(CLK_CHANNEL_MEM_FENCE);
435

436
437
438
439
440
441
442
443
444
445
446
447
		#if defined (FIXED_POINT_CONFORM)
		// convert fixedpt3 to float3
		float tmp_x = fixedpt_tofloat(loc_coords[pipe_cnt].x);
		float tmp_y = fixedpt_tofloat(loc_coords[pipe_cnt].y);
		float tmp_z = fixedpt_tofloat(loc_coords[pipe_cnt].z);
		float3 tmp = {tmp_x, tmp_y, tmp_z};
		#else
		float3 tmp = loc_coords[pipe_cnt];
		#endif

		write_channel_altera(chan_Conf2Intere_xyz, tmp);
		write_channel_altera(chan_Conf2Intrae_xyz, tmp);
448
	}
449
	*/
Leonardo Solis's avatar
Leonardo Solis committed
450
451
452

	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt+=2) {
		if (pipe_cnt == 0) {
453
#if 0
Leonardo Solis's avatar
Leonardo Solis committed
454
455
456
			char  active_tmp = active;
			char  mode_tmp   = mode;
			char2 actmode    = {active_tmp, mode_tmp};
457
458
459
#endif
			write_channel_altera(chan_Conf2Intere_actmode, /*actmode*/ mode);
			write_channel_altera(chan_Conf2Intrae_actmode, /*actmode*/ mode);
Leonardo Solis's avatar
Leonardo Solis committed
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
		}
		mem_fence(CLK_CHANNEL_MEM_FENCE);

		#if defined (FIXED_POINT_CONFORM)
		fixedpt3 tmp_coords[2];
		#else
		float3 tmp_coords[2];
		#endif

		#pragma unroll
		for (uchar i=0; i<2; i++) {
			tmp_coords[i] = loc_coords[pipe_cnt+i];
		}

		float8 tmp;

		#if defined (FIXED_POINT_CONFORM)
477
		// Convert fixedpt3 to float3
Leonardo Solis's avatar
Leonardo Solis committed
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
		float tmp_x1 = fixedpt_tofloat(tmp_coords[0].x);
		float tmp_y1 = fixedpt_tofloat(tmp_coords[0].y);
		float tmp_z1 = fixedpt_tofloat(tmp_coords[0].z);
		float tmp_x2 = fixedpt_tofloat(tmp_coords[1].x);
		float tmp_y2 = fixedpt_tofloat(tmp_coords[1].y);
		float tmp_z2 = fixedpt_tofloat(tmp_coords[1].z);
		tmp.s0 = tmp_x1; tmp.s1 = tmp_y1; tmp.s2 = tmp_z1; //tmp.s3
		tmp.s4 = tmp_x2; tmp.s5 = tmp_y2; tmp.s6 = tmp_z2; //tmp.s7
		#else
		tmp.s0 = tmp_coords[0].x; tmp.s1 = tmp_coords[0].y; tmp.s2 = tmp_coords[0].z; //tmp.s3
		tmp.s4 = tmp_coords[1].x; tmp.s5 = tmp_coords[1].y; tmp.s6 = tmp_coords[1].z; //tmp.s7
		#endif

		write_channel_altera(chan_Conf2Intere_xyz, tmp);
		write_channel_altera(chan_Conf2Intrae_xyz, tmp);
	}
494

495
	// --------------------------------------------------------------
496
	#if defined (DEBUG_KRNL_CONFORM)
497
	printf("AFTER Out CONFORM CHANNEL\n");
498
	#endif
499

500
} // End of while(active)
501

502
503
504
505
#if defined (DEBUG_ACTIVE_KERNEL)
printf("	%-20s: %s\n", "Krnl_Conform", "disabled");
#endif

506
507
508
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------