Commit 9c153df7 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

LS9 blocks + added comments + corrections

parent 3938e557
Loading
Loading
Loading
Loading
+66 −47
Original line number Diff line number Diff line
@@ -532,7 +532,11 @@ else
endif


ENABLE_KERNELS = $(K1) $(K2) $(K3) $(K4) $(K5) $(K6) $(K7) $(K8) $(K9) $(K10) $(K11) $(K12) $(K13) $(K14) $(K15) $(K16) $(K17) $(K18) $(K19) $(K20) $(K21) $(K22) $(K23) $(K24) $(K25) $(K26) $(K27) $(K28) $(K29) $(K30) $(K31) $(K32) $(K33) $(K34) $(K35) $(K36) $(K37) $(K38) $(K39) $(K40) $(K41) $(K42) $(K43) $(K44) $(K45) $(K46) $(K47) $(K48)
ENABLE_KERNELS = $(K1)  $(K2)  $(K3)  $(K4)  $(K5)  $(K6)  $(K7)  $(K8)  $(K9)  $(K10) \
		 $(K11) $(K12) $(K13) $(K14) $(K15) $(K16) $(K17) $(K18) $(K19) $(K20) \
		 $(K21) $(K22) $(K23) $(K24) $(K25) $(K26) $(K27) $(K28) $(K29) $(K30) \
		 $(K31) $(K32) $(K33) $(K34) $(K35) $(K36) $(K37) $(K38) $(K39) $(K40) \
		 $(K41) $(K42) $(K43) $(K44) $(K45) $(K46) $(K47) $(K48)

# =============================
# Reproduce result (remove randomness)
@@ -666,7 +670,18 @@ else
	SEP_FGRID_FLAG=
endif

FIPO_FLAG = $(FIPOCO_FLAG) $(FIPOIE_FLAG) $(FIPOIA_FLAG) $(FIPOLS1_FLAG) $(FIPOLS2_FLAG) $(FIPOLS3_FLAG) $(FIPOLS4_FLAG) $(FIPOLS5_FLAG) $(FIPOLS6_FLAG) $(FIPOLS7_FLAG) $(FIPOLS8_FLAG) $(FIPOLS9_FLAG) $(COPYPOPENE_FLAG) $(SEP_FGRID_FLAG) 
FIPO_FLAG = $(FIPOCO_FLAG) \
	    $(FIPOIE_FLAG) $(FIPOIA_FLAG) \
	    $(FIPOLS1_FLAG) \
	    $(FIPOLS2_FLAG) \
	    $(FIPOLS3_FLAG) \
	    $(FIPOLS4_FLAG) \
	    $(FIPOLS5_FLAG) \
	    $(FIPOLS6_FLAG) \
	    $(FIPOLS7_FLAG) \
	    $(FIPOLS8_FLAG) \
	    $(FIPOLS9_FLAG) \
	    $(COPYPOPENE_FLAG) $(SEP_FGRID_FLAG) 

# =============================
# AOC flags
@@ -716,18 +731,19 @@ $(TARGET_DIR)/$(TARGET) : Makefile $(SRCS) $(INCS) $(TARGET_DIR)
			$(foreach L,$(LIBS),-l$L) \
			-o $(TARGET_DIR)/$(TARGET) $(DOCK_DEBUG_FLAG) $(DEV) $(DOCK_PROG) $(ENABLE_KERNELS) $(REP) $(FIPO_FLAG)
	@echo " "
	@echo "================================"
	@echo "INFO: host binary is under: bin/"
	@echo "================================"
	@echo "==================================================="
	@echo "INFO: host binary is under: $(TARGET_DIR)/$(TARGET)"
	@echo "==================================================="
	@echo " "

# Docking parameters 
# NEV was usually set to 100000
# that directly determine the execution time
# Following values are used only for emulation
# to have a short but still a representative test
PDB  := 1stp
NRUN := 10
NEV  := 50000 


# Project name
PROJECT_NAME := ofdock_taskpar_alt

@@ -753,9 +769,9 @@ BOARD := Proc10A_X115
keremu: $(DEV_SRC)
	aoc -march=emulator -v --board $(BOARD) $(DEV_SRC) -o $(TARGET_DIR)/$(KRNL_NAME).aocx $(REP) $(FIPO_FLAG) $(AOC_FLAG) -g
	@echo " "
	@echo "==============================================================="
	@echo "INFO: emulation files are under: bin/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "==============================================================="
	@echo "========================================================================="
	@echo "INFO: emulation files are under: $(TARGET_DIR)/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "========================================================================="
	@echo " "

# Run emulation
@@ -766,9 +782,9 @@ emu: $(TARGET_DIR)/$(TARGET) keremu
	cd $(TARGET_DIR) && \
	CL_CONTEXT_EMULATOR_DEVICE_ALTERA=1 ./$(TARGET) -ffile ../input/$(PDB)/derived/$(PDB)_protein.maps.fld -lfile ../input/$(PDB)/derived/$(PDB)_ligand.pdbqt -nev $(NEV) -nrun $(NRUN) -gfpop 1
	@echo " "
	@echo "========================================"
	@echo "INFO: log file is under: bin/docking.dlg"
	@echo "========================================"
	@echo "=================================================="
	@echo "INFO: log file is under: $(TARGET_DIR)/docking.dlg"
	@echo "=================================================="
	@echo " "


@@ -781,13 +797,13 @@ emu: $(TARGET_DIR)/$(TARGET) keremu
kerrpt: $(DEV_SRC)
	aoc --board $(BOARD) $(DEV_SRC) -o $(TARGET_DIR)/$(KRNL_NAME).aoco $(REP) $(FIPO_FLAG) $(AOC_FLAG) -c --report -g
	@echo " "
	@echo "=================================================================="
	@echo "INFO: report files are under: bin/$(KRNL_NAME)/reports/report.html"
	@echo "============================================================================"
	@echo "INFO: report files are under: $(TARGET_DIR)/$(KRNL_NAME)/reports/report.html"
	@echo "INFO: THIS WORKS ONLY FROM V16.1 ON                                         "
	@echo "                                        		                           "
	@echo "INFO: report file is under: bin/$(KRNL_NAME).log                  "
	@echo "INFO: report file is under: $(TARGET_DIR)/$(KRNL_NAME).log                  "
	@echo "INFO: THIS WORKS IN V16.0 AND OLDER.                                        "
	@echo "=================================================================="
	@echo "============================================================================"
	@echo " "

# Build hw (FPGA bitstream)
@@ -799,17 +815,17 @@ kerrpt: $(DEV_SRC)
hw: 	
	aoc --board $(BOARD) $(DEV_SRC) -o $(TARGET_DIR_HW)/$(KRNL_NAME).aocx $(FIPO_FLAG) $(AOC_FLAG)
	@echo " "
	@echo "================================================================"
	@echo "INFO: FPGA bitstream is under: bin_hw/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "================================================================"
	@echo "=========================================================================="
	@echo "INFO: FPGA bitstream is under: $(TARGET_DIR_HW)/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "=========================================================================="
	@echo " "

hw-he:
	aoc --high-effort --board $(BOARD) $(DEV_SRC) -o $(TARGET_DIR_HW)/$(KRNL_NAME).aocx $(FIPO_FLAG) $(AOC_FLAG)
	@echo " "
	@echo "================================================================"
	@echo "INFO: FPGA bitstream is under: bin_hw/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "================================================================"
	@echo "=========================================================================="
	@echo "INFO: FPGA bitstream is under: $(TARGET_DIR_HW)/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "=========================================================================="
	@echo " "

# Build hw (FPGA bitstream) instrumented with performance counters
@@ -821,13 +837,13 @@ hw-he:
hw-prof:
	aoc --profile --board $(BOARD) $(DEV_SRC) -o $(TARGET_DIR_HW_PROF)/$(KRNL_NAME).aocx $(FIPO_FLAG) $(AOC_FLAG)
	@echo " "
	@echo "====================================================================================="
	@echo "INFO: instrumented FPGA bitstream is under: bin_hw_profile/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "====================================================================================="
	@echo "============================================================================================"
	@echo "INFO: instrumented FPGA bitstream is under: $(TARGET_DIR_HW_PROF)/$(KRNL_NAME)(.aoco)(.aocx)"
	@echo "============================================================================================"
	@echo " "


# Execute on sauron server
# Execute on remote server
# Host-recompilation
# Copy of host to $(TARGET_DIR_HW)
# The working directory is changed
@@ -835,15 +851,15 @@ hw-prof:
exe: $(TARGET_DIR)/$(TARGET)
	cp $(TARGET_DIR)/$(TARGET) $(TARGET_DIR_HW)/ && \
	cd $(TARGET_DIR_HW) && \
	./$(TARGET) -ffile ../input/$(PDB)/derived/$(PDB)_protein.maps.fld -lfile ../input/$(PDB)/derived/$(PDB)_ligand.pdbqt -nrun 10
	./$(TARGET) -ffile ../input/$(PDB)/derived/$(PDB)_protein.maps.fld -lfile ../input/$(PDB)/derived/$(PDB)_ligand.pdbqt -nrun $(NRUN) -resnam docking_$(PDB)_$(NRUN)
	@echo " "
	@echo "==========================================="
	@echo "INFO: log file is under: bin_hw/docking.dlg"
	@echo "==========================================="
	@echo "===================================================================="
	@echo "INFO: log file is under: $(TARGET_DIR_HW)/docking_$(PDB)_$(NRUN).dlg"
	@echo "===================================================================="
	@echo " "


# Execute and profile on sauron server
# Execute and profile on remote server
# Host-recompilation
# Copy of host to $(TARGET_DIR_HW_PROF)
# The working directory is changed
@@ -851,20 +867,23 @@ exe: $(TARGET_DIR)/$(TARGET)
exe-prof: $(TARGET_DIR)/$(TARGET)
	cp $(TARGET_DIR)/$(TARGET) $(TARGET_DIR_HW_PROF)/ && \
	cd $(TARGET_DIR_HW_PROF) && \
	./$(TARGET) -ffile ../input/$(PDB)/derived/$(PDB)_protein.maps.fld -lfile ../input/$(PDB)/derived/$(PDB)_ligand.pdbqt -nrun 10
	./$(TARGET) -ffile ../input/$(PDB)/derived/$(PDB)_protein.maps.fld -lfile ../input/$(PDB)/derived/$(PDB)_ligand.pdbqt -nrun $(NRUN) -resnam docking_$(PDB)_$(NRUN)
	@echo " "
	@echo "==================================================="
	@echo "INFO: log file is under: bin_hw_profile/docking.dlg"
	@echo "==================================================="
	@echo "========================================================================="
	@echo "INFO: log file is under: $(TARGET_DIR_HW_PROF)/docking_$(PDB)_$(NRUN).dlg"
	@echo "========================================================================="
	@echo " "

COPY_DIR := copy_$(PROJECT_NAME)
COPY_DIR_DOCK := $(PROJECT_NAME)

# Make sure this remote-server alias exists (in ~/.ssh/config)
SERVER := sauron

# Delete an existing folder if previously created
# Create a folder $(COPY_DIR) in the parent directory
# Copy binaries into $(COPY_DIR) folder, avoiding the (innecesary) compilation intermediate files
# Copy source files into $(COPY_DIR) as host is built in the HARP2 front-end
# Copy source files into $(COPY_DIR) as host is built in the remote $(SERVER)
# Create a zip file out of the $(COPY_DIR) folder
copy: clean-copy
	mkdir ../$(COPY_DIR)
@@ -882,16 +901,16 @@ copy: clean-copy
	cp -r input/ ../$(COPY_DIR)/$(COPY_DIR_DOCK)/
	cp -r wrapcl/ ../$(COPY_DIR)/$(COPY_DIR_DOCK)/
	cp -r ../common ../$(COPY_DIR)/
	cp ../conf_aoc160_sauron.sh ../$(COPY_DIR)/
	cp ../conf_aoc160_$(SERVER).sh ../$(COPY_DIR)/
	cd ../;	zip -r $(COPY_DIR).zip $(COPY_DIR)
	@echo " "
	@echo "Transfer the $(COPY_DIR).zip file to sauron server: "
	@echo "Transfer the $(COPY_DIR).zip file to $(SERVER) server: "
	@echo " "
	cd ../ && scp $(COPY_DIR).zip sauron:~/
	cd ../ && scp $(COPY_DIR).zip $(SERVER):~/
	@echo " "
	@echo "================="
	@echo "Transfer finished"
	@echo "================="
	@echo "=========================================="
	@echo "Files listed were transferred to $(SERVER)"
	@echo "=========================================="
	@echo " "

clean-copy:
+41 −113
Original line number Diff line number Diff line
// --------------------------------------------------------------------------
// The function changes the conformation of myligand according to 
// the genotype given by the second parameter.
// Conform changes the conformation of the ligand according to 
// the genotype fed by any producer logic/kernel (IC, GG, LSs).
// Originally from: processligand.c
// --------------------------------------------------------------------------
__kernel __attribute__ ((max_global_work_dim(0)))
@@ -18,9 +18,7 @@ void Krnl_Conform(
			      unsigned int          DockConst_rotbondlist_length,
			      unsigned char         DockConst_num_of_atoms,
			      unsigned char         DockConst_num_of_genes,
/*
			      unsigned char         Host_num_of_rotbonds,
*/

	     #if defined (FIXED_POINT_CONFORM)
	     __constant fixedpt4* restrict KerConstStatic_ref_orientation_quats_const,
	     #else
@@ -36,17 +34,13 @@ void Krnl_Conform(
	printf("%-40s %u\n", "DockConst_num_of_genes: ",        DockConst_num_of_genes);	
	#endif

/*
	// check best practices guide
	// Check best practices guide
	// Table 11. Effects of numbanks and bankwidth on the Bank Geometry ...
	// 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];
*/
	// 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];

/*
	bool active = true;
*/
	char active = 0x01;	

	__local int rotlist_localcache [MAX_NUM_OF_ROTATIONS];
@@ -62,10 +56,6 @@ while(active) {
	fixedpt  phi;
	fixedpt  theta;
	fixedpt  genrotangle;
/*
	fixedpt  sin_theta, cos_theta;
	fixedpt3 genrot_unitvec;
*/
	fixedpt3 genotype_xyz;
	fixedpt3 __attribute__ ((
			      memory,
@@ -79,10 +69,6 @@ while(active) {
	float  phi;
	float  theta;
	float  genrotangle;
/*
	float  sin_theta, cos_theta;
	float3 genrot_unitvec;
*/
	float3 genotype_xyz;
	float3 __attribute__ ((
			      memory,
@@ -94,10 +80,6 @@ while(active) {
			    )) loc_coords [MAX_NUM_OF_ATOMS];
	#endif

/*
	active = read_channel_altera(chan_IGL2Conform_active);
	mem_fence(CLK_CHANNEL_MEM_FENCE);
*/
	char2 actmode = read_channel_altera(chan_IGL2Conform_actmode);
	mem_fence(CLK_CHANNEL_MEM_FENCE);

@@ -113,52 +95,19 @@ while(active) {
	#endif

	for (uchar i=0; i<DockConst_num_of_genes; i++) {
		/*float fl_tmp = read_channel_altera(chan_IGL2Conform_genotype);*/
		float fl_tmp;
		switch (mode) {
			case 'I':
				fl_tmp = read_channel_altera(chan_IC2Conf_genotype);
			break;

			case 'G':
				fl_tmp = read_channel_altera(chan_GG2Conf_genotype);
			break;

			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;
			case 'I':  fl_tmp = read_channel_altera(chan_IC2Conf_genotype);     break;
			case 'G':  fl_tmp = read_channel_altera(chan_GG2Conf_genotype);     break;
			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;
		}
		
		if (i > 2) {
@@ -168,7 +117,7 @@ while(active) {
//printf("Conform: %u %u\n", mode, i);

		#if defined (FIXED_POINT_CONFORM)
		// convert float to fixedpt
		// Convert float to fixedpt
		fixedpt fx_tmp = fixedpt_fromfloat(fl_tmp);
		switch (i) {
			case 0: genotype_xyz.x = fx_tmp; break;
@@ -196,40 +145,23 @@ while(active) {
	if (active == 0x00) {printf("	%-20s: %s\n", "Krnl_Conform", "must be disabled");}
	#endif

/*
	#if defined (FIXED_POINT_CONFORM)
	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
	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
*/

	for (ushort rotation_counter = 0; rotation_counter < DockConst_rotbondlist_length; rotation_counter++)
	{
		int rotation_list_element = rotlist_localcache [rotation_counter];

		if ((rotation_list_element & RLIST_DUMMY_MASK) == 0)	//if not dummy rotation
		if ((rotation_list_element & RLIST_DUMMY_MASK) == 0)	// If not dummy rotation
		{
			uint atom_id = rotation_list_element & RLIST_ATOMID_MASK;

			//capturing atom coordinates
			// Capturing atom coordinates
			#if defined (FIXED_POINT_CONFORM)
			fixedpt3 atom_to_rotate;
			#else
			float3 atom_to_rotate;
			#endif

			if ((rotation_list_element & RLIST_FIRSTROT_MASK) != 0)	//if first rotation of this atom
			if ((rotation_list_element & RLIST_FIRSTROT_MASK) != 0)	// If first rotation of this atom
			{	
				/*atom_to_rotate = ref_coords_localcache [atom_id];*/
				atom_to_rotate = KerConstStatic_ref_coords_const [atom_id];
			}
			else
@@ -237,7 +169,7 @@ while(active) {
				atom_to_rotate = loc_coords[atom_id];
			}

			//capturing rotation vectors and angle
			// Capturing rotation vectors and angle
			#if defined (FIXED_POINT_CONFORM)
			fixedpt3 rotation_unitvec;
			fixedpt3 rotation_movingvec;
@@ -248,7 +180,7 @@ while(active) {
			float    rotation_angle;
			#endif

			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	//if general rotation
			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	// If general rotation
			{
				#if defined (FIXED_POINT_CONFORM)
				fixedpt  sin_theta, cos_theta;
@@ -274,19 +206,17 @@ while(active) {

				rotation_movingvec = genotype_xyz;
			}
			else	//if rotating around rotatable bond
			else	// If rotating around rotatable bond
			{
				uint rotbond_id = (rotation_list_element & RLIST_RBONDID_MASK) >> RLIST_RBONDID_SHIFT;

				/*rotation_unitvec = rotbonds_unit_vectors_localcache [rotbond_id];*/
				rotation_unitvec = KerConstStatic_rotbonds_unit_vectors_const [rotbond_id];
				
				rotation_angle = genotype [6+rotbond_id];

				/*rotation_movingvec = rotbonds_moving_vectors_localcache [rotbond_id];*/
				rotation_movingvec = KerConstStatic_rotbonds_moving_vectors_const [rotbond_id];

				//in addition performing the first movement 
				// In addition performing the first movement 
				// which is needed only if rotating around rotatable bond

				#if defined (FIXED_POINT_CONFORM)
@@ -298,7 +228,7 @@ while(active) {
				#endif
			}

			//performing rotation
			// Performing rotation
			#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;
@@ -331,7 +261,7 @@ while(active) {
			quatrot_left.w = cos_angle;
			#endif

			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	//if general rotation, 
			if ((rotation_list_element & RLIST_GENROT_MASK) != 0)	// If general rotation, 
										// two rotations should be performed 
										// (multiplying the quaternions)
			{
@@ -349,7 +279,7 @@ while(active) {
				const float  ref_orientation_quats_const_3 = ref_orientation_quats_const.w;
				#endif

				//calculating quatrot_left*ref_orientation_quats_const, 
				// Calculating quatrot_left*ref_orientation_quats_const, 
				// which means that reference orientation rotation is the first
				#if defined (FIXED_POINT_CONFORM)
				quatrot_temp_q = quatrot_left_q;
@@ -360,7 +290,7 @@ while(active) {
				quatrot_temp = quatrot_left;
				#endif

				//taking the first element of ref_orientation_quats_const member
				// Taking the first element of ref_orientation_quats_const member
				#if defined (FIXED_POINT_CONFORM)
				quatrot_left_q =   fixedpt_mul(quatrot_temp_q, ref_orientation_quats_const_0) 
						 - fixedpt_mul(quatrot_temp_x, ref_orientation_quats_const_1) 
@@ -445,7 +375,7 @@ while(active) {
			atom_to_rotate.z = dot(quatrot_temp, left4z);
			#endif

			//performing final movement and storing values
			// Performing final movement and storing values
			loc_coords[atom_id] = atom_to_rotate + rotation_movingvec;

		} // End if-statement not dummy rotation
@@ -501,8 +431,6 @@ while(active) {
	}
	*/



	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt+=2) {
		if (pipe_cnt == 0) {
			char  active_tmp = active;
@@ -528,7 +456,7 @@ while(active) {
		float8 tmp;

		#if defined (FIXED_POINT_CONFORM)
		// convert fixedpt3 to float3
		// Convert fixedpt3 to float3
		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);
@@ -551,7 +479,7 @@ while(active) {
	printf("AFTER Out CONFORM CHANNEL\n");
	#endif

} // End of while(1)
} // End of while(active)

#if defined (DEBUG_ACTIVE_KERNEL)
printf("	%-20s: %s\n", "Krnl_Conform", "disabled");
+104 −119

File changed.

Preview size limit exceeded, changes collapsed.

+26 −38
Original line number Diff line number Diff line
// --------------------------------------------------------------------------
// IGL_Arbiter keeps checking whether any kernel (GA or any LSs) 
// is sending genotypes to Conform, as well as whether 
// GA sent the "turn-off" signal.
// Its name references the logic that is producing genotypes: 
// IC, GG and any LS.
// IC and GG are two logic blocks inside the GA kernel,
// while any LS logic is a kernel itself.

// It uses the valid signals to determine the "mode" value,
// used as a mux selector signal (of genotype logic-producers) in Conform.

// Initially genotypes passed through this kernel getting reordered and 
// synchronized with "mode".
// This has been later optimized, so now genotypes go directly 
// from producer logic/kernel (IC, GG, LSs) to the consumer (Conform) kernel.
// --------------------------------------------------------------------------
__kernel __attribute__ ((max_global_work_dim(0)))
void Krnl_IGL_Arbiter(/*unsigned char DockConst_num_of_genes*/) {
@@ -71,12 +86,11 @@ while(active) {
	active = Off_valid ? 0x00 : 0x01;
	char mode [9];	// mode for all LS

/*
	float genotypeICGG  [ACTUAL_GENOTYPE_LENGTH]; 
	float genotype   [3][ACTUAL_GENOTYPE_LENGTH];
*/

	// get genotype from IC, GG, LS1, LS2, LS3
	// Determine "mode" value
	// This considers all possible cases as all LS could be 
	// potentially producing genotypes simultaneously.
	// Be careful modifying the nested conditional-statements below,
	// as even a litle mistake may be undetectable in emulation.
	if (active == 0x01) {

		if (IC_valid == true) {
@@ -86,7 +100,7 @@ while(active) {
			bound_tmp++;
		}	
		else{
			// Reorder the mode & genotype coming from LS
			// Reorder the mode & from LS

			// **************************************************************************************
			// LS1: yes
@@ -1292,39 +1306,14 @@ while(active) {

	uchar bound = active ? bound_tmp : 1;

/*
	if ((LS1_end_valid || LS2_end_valid || LS3_end_valid)) {
		printf("bound_tmp: %-5u, LS1: %-5s, LS2: %-5s, LS3: %-5s\n", bound_tmp, LS1_end_valid?"yes":"no", LS2_end_valid?"yes":"no", LS3_end_valid?"yes":"no");
	}
*/

	// send data to Krnl_Conform
	// Send "mode" to Conform
	for (uchar j=0; j<bound; j++) {

		char mode_tmp = Off_valid? 0x00: IC_valid? 'I': GG_valid? 'G': mode[j];

//printf("IGL: %u\n", mode_tmp);

		char2 actmode = {active, mode_tmp};

		write_channel_altera(chan_IGL2Conform_actmode, actmode);
/*
		mem_fence(CLK_CHANNEL_MEM_FENCE);
*/

/*
		for (uchar i=0; i<DockConst_num_of_genes; i++) {

			float gene_tmp = (IC_valid || GG_valid)? genotypeICGG[i]: genotype[j][i & MASK_GENOTYPE];

			if (i > 2) {
				gene_tmp = gene_tmp * DEG_TO_RAD;
			}

			write_channel_altera(chan_IGL2Conform_genotype, gene_tmp);
		}
*/
		#if defined (DEBUG_KRNL_CONF_ARBITER)
		#if defined (DEBUG_KRNL_IGL_ARBITER)
		printf("bound: %u, mode: %u\n", bound, mode_tmp);
		#endif
	}
@@ -1344,7 +1333,6 @@ while(active) {
	}
	*/
	

} // End of while (active)

}
+18 −52
Original line number Diff line number Diff line
// --------------------------------------------------------------------------
// The function calculates the intermolecular energy of a ligand given by 
// myligand parameter, and a receptor represented as a grid. 
// The grid point values must be stored at the location which starts at GlobFgrids, 
// the memory content can be generated with get_gridvalues function.
// The mygrid parameter must be the corresponding grid informtaion. 
// If an atom is outside the grid, the coordinates will be changed with 
// the value of outofgrid_tolerance, 
// if it remains outside, a very high value will be added to the current energy as a penalty. 
// InterE calculates the intermolecular energy of a ligand given by 
// ligand xyz-positions, and a receptor represented as a grid. 
// The grid point values must be stored at the location which starts at GlobFgrids. 
// If an atom is remains outside the grid, 
// a very high value will be added to the current energy as a penalty. 
// Originally from: processligand.c
// --------------------------------------------------------------------------
__kernel __attribute__ ((max_global_work_dim(0)))
@@ -47,9 +44,6 @@ void Krnl_InterE(
*/
)
{
/*
	bool active = true;
*/	
	char active = 0x01;

	__global const float* GlobFgrids2 = & GlobFgrids [Host_mul_tmp2];
@@ -80,12 +74,6 @@ while(active) {
	active = actmode.x;
	mode   = actmode.y;

/*
	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt++) {
		loc_coords[pipe_cnt] = read_channel_altera(chan_Conf2Intere_xyz);
	}
*/

	for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_atoms; pipe_cnt+=2) {
		float8 tmp = read_channel_altera(chan_Conf2Intere_xyz);
		float3 tmp1 = {tmp.s0, tmp.s1, tmp.s2};
@@ -94,7 +82,6 @@ while(active) {
		loc_coords[pipe_cnt+1] = tmp2;
	}


	// --------------------------------------------------------------
	//printf("AFTER In INTER CHANNEL\n");

@@ -108,7 +95,7 @@ while(active) {
	float interE = 0.0f;
	#endif

	// for each atom
	// For each ligand atom
	for (uchar atom1_id=0; atom1_id<DockConst_num_of_atoms; atom1_id++)
	{
		char atom1_typeid = KerConstStatic_atom_types_const [atom1_id];
@@ -143,7 +130,7 @@ while(active) {
		float partialE3;
		#endif

		// if the atom is outside of the grid
		// If the atom is outside of the grid
		#if defined (FIXED_POINT_INTERE)
		if ((fixpt_x < 0) || (fixpt_x >= fixedpt64_fromint(DockConst_gridsize_x_minus1)) || 
		    (fixpt_y < 0) || (fixpt_y >= fixedpt64_fromint(DockConst_gridsize_y_minus1)) ||
@@ -154,7 +141,7 @@ while(active) {
		    (z < 0.0f) || (z >= DockConst_gridsize_z_minus1))	{
		#endif

			//penalty is 2^24 for each atom outside the grid
			// Penalty is 2^24 for each atom outside the grid
			/*
			interE += 16777216.0f; 
			*/
@@ -235,7 +222,7 @@ while(active) {
			printf("coeff(1,1,1) = %f\n", weights [1][1][1]);
			#endif

			// lvs added temporal variables
			// Added temporal variables
			uint cube_000, cube_100, cube_010, cube_110, cube_001, cube_101, cube_011, cube_111;

			uint ylow_times_g1  = y_low  * DockConst_g1;	
@@ -254,7 +241,7 @@ while(active) {

			uint mul_tmp = atom1_typeid * DockConst_g3;

			//energy contribution of the current grid type
			// Energy contribution of the current grid type
			#if defined (FIXED_POINT_INTERE)
			fixedpt64 fixpt_cube [2][2][2];
	                fixpt_cube [0][0][0] = fixedpt64_fromfloat(GlobFgrids[cube_000 + mul_tmp]);
@@ -314,7 +301,7 @@ while(active) {
			printf("interpolated value = %f\n\n", TRILININTERPOL(cube, weights));
			#endif

			//energy contribution of the electrostatic grid
			// Energy contribution of the electrostatic grid
			/*
			#if defined(SEPARATE_FGRID_INTERE)
			#else
@@ -383,7 +370,7 @@ while(active) {
			printf("interpolated value = %f, multiplied by q = %f\n\n", TRILININTERPOL(cube, weights), q*TRILININTERPOL(cube, weights));
			#endif

			//energy contribution of the desolvation grid
			// Energy contribution of the desolvation grid
			/*
			#if defined(SEPARATE_FGRID_INTERE)
			#else
@@ -471,42 +458,21 @@ while(active) {
	#endif

	switch (mode) {
		// IC
		case 'I':  write_channel_altera(chan_Intere2StoreIC_intere, final_interE);     break;

		// GG
		case 'G':  write_channel_altera(chan_Intere2StoreGG_intere, final_interE);     break;

		// LS 1
		case 0x01: write_channel_altera(chan_Intere2StoreLS_LS1_intere, final_interE); break;

		// LS 2
		case 0x02: write_channel_altera(chan_Intere2StoreLS_LS2_intere, final_interE); break;

		// LS 3
		case 0x03: write_channel_altera(chan_Intere2StoreLS_LS3_intere, final_interE); break;

		// LS 4
		case 0x04: write_channel_altera(chan_Intere2StoreLS_LS4_intere, final_interE); break;

		// LS 5
		case 0x05: write_channel_altera(chan_Intere2StoreLS_LS5_intere, final_interE); break;

		// LS 6
		case 0x06: write_channel_altera(chan_Intere2StoreLS_LS6_intere, final_interE); break;

		// LS 7
		case 0x07: write_channel_altera(chan_Intere2StoreLS_LS7_intere, final_interE); break;

		// LS 8
		case 0x08: write_channel_altera(chan_Intere2StoreLS_LS8_intere, final_interE); break;

		// LS 9
		case 0x09: write_channel_altera(chan_Intere2StoreLS_LS9_intere, final_interE); break;
	}
	// --------------------------------------------------------------
 	
} // End of while(1)
} // End of while(active)

	#if defined (DEBUG_ACTIVE_KERNEL)
	printf("	%-20s: %s\n", "Krnl_InterE", "disabled");
Loading