Loading ofdock_taskpar_alt/Makefile +34 −1 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ ENABLE_K2 = YES ENABLE_K3 = YES ENABLE_K4 = YES # Prng kernels ENABLE_K5 = YES ENABLE_K6 = YES ENABLE_K7 = YES Loading @@ -150,6 +151,13 @@ ENABLE_K9 = YES ENABLE_K10 = YES ENABLE_K11 = YES # LS kernels ENABLE_K12 = YES ENABLE_K13 = YES #ENABLE_K14 = YES #ENABLE_K15 = YES ifeq ($(ENABLE_K1),YES) K1 =-DENABLE_KERNEL1 else Loading Loading @@ -216,7 +224,32 @@ else K11 = endif ENABLE_KERNELS = $(K1) $(K2) $(K3) $(K4) $(K5) $(K6) $(K7) $(K8) $(K9) $(K10) $(K11) ifeq ($(ENABLE_K12),YES) K12 =-DENABLE_KERNEL12 else K12 = endif ifeq ($(ENABLE_K13),YES) K13 =-DENABLE_KERNEL13 else K13 = endif ifeq ($(ENABLE_K14),YES) K14 =-DENABLE_KERNEL14 else K14 = endif ifeq ($(ENABLE_K15),YES) K15 =-DENABLE_KERNEL15 else K15 = endif ENABLE_KERNELS = $(K1) $(K2) $(K3) $(K4) $(K5) $(K6) $(K7) $(K8) $(K9) $(K10) $(K11) $(K12) $(K13) $(K14) $(K15) # ============================= # Reproduce result (remove randomness) Loading ofdock_taskpar_alt/device/Krnl_Conform.cl +18 −24 Original line number Diff line number Diff line Loading @@ -63,11 +63,7 @@ while(active) { bool GG_valid = false; bool LS_valid = false; bool Off_valid = false; /* bool IC_active; bool GG_active; bool LS_active; */ float IC_active; float GG_active; float LS_active; Loading Loading @@ -99,37 +95,23 @@ while(active) { } char mode; /* float genotype[ACTUAL_GENOTYPE_LENGTH]; */ /* active = (IC_valid) ? IC_active : (GG_valid) ? GG_active : (LS_valid) ? LS_active : */ //printf("LS_valid: %u, LS2_valid: %u\n", LS_valid, LS2_valid); active = (IC_valid) ? true : (GG_valid) ? true : (LS_valid) ? true : (Off_valid) ? Off_active : false; // last case should never occur, otherwise above while would be still running mode = (IC_valid) ? 0x01 : (GG_valid) ? 0x02 : (LS_valid) ? 0x03 : (Off_valid) ? 0x05 : 0x05; // last case should never occur, otherwise above while would be still running /* for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_genes; pipe_cnt++) { genotype[pipe_cnt] = (IC_valid) ? read_channel_altera(chan_IC2Conf_genotype) : (GG_valid) ? read_channel_altera(chan_GG2Conf_genotype) : (LS_valid) ? read_channel_altera(chan_LS2Conf_genotype) : (Off_valid) ? 0.0f: 0.0f; // last case should never occur, otherwise above while would be still running } */ // -------------------------------------------------------------- //printf("AFTER In CONFORM CHANNEL\n"); /* Loading Loading @@ -317,6 +299,13 @@ while(active) { printf("BEFORE Out CONFORM CHANNEL\n"); #endif /* if (mode == 0x04) { printf("Krnl_Conform after loop\n"); } */ // -------------------------------------------------------------- // Send ligand atomic coordinates to channel // -------------------------------------------------------------- Loading @@ -333,6 +322,11 @@ while(active) { write_channel_altera(chan_Conf2Intere_xyz, loc_coords[pipe_cnt]); write_channel_altera(chan_Conf2Intrae_xyz, loc_coords[pipe_cnt]); } /* if (mode == 0x04) { printf("Krnl_Conform sent\n"); } */ // -------------------------------------------------------------- #if defined (DEBUG_KRNL_CONFORM) Loading ofdock_taskpar_alt/device/Krnl_GA.cl +128 −214 Original line number Diff line number Diff line Loading @@ -24,10 +24,21 @@ channel float chan_IC2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_GG2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_LS2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); /* channel float chan_LS2Conf_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_LS2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); */ // To turn off Conform, InterE, IntraE /* channel bool chan_IC2Conf_active; channel bool chan_GG2Conf_active; channel bool chan_LS2Conf_LS1_active; channel bool chan_LS2Conf_LS2_active; */ channel bool chan_Off2Conf_active; channel float3 chan_Conf2Intere_xyz __attribute__((depth(MAX_NUM_OF_ATOMS))); channel bool chan_Conf2Intere_active; channel char chan_Conf2Intere_mode; Loading @@ -39,10 +50,19 @@ channel char chan_Conf2Intrae_mode; channel float chan_Intere2StoreIC_intere __attribute__((depth(MAX_POPSIZE))); channel float chan_Intere2StoreGG_intere __attribute__((depth(MAX_POPSIZE))); channel float chan_Intere2StoreLS_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE channel float chan_Intere2StoreLS_LS2_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE /* channel float chan_Intere2StoreLS_LS3_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE */ channel float chan_Intrae2StoreIC_intrae __attribute__((depth(MAX_POPSIZE))); channel float chan_Intrae2StoreGG_intrae __attribute__((depth(MAX_POPSIZE))); channel float chan_Intrae2StoreLS_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE channel float chan_Intrae2StoreLS_LS2_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE /* channel float chan_Intrae2StoreLS_LS3_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE */ // PRNG kernerls channel bool chan_GA2PRNG_BT_ushort_active; Loading @@ -62,9 +82,44 @@ channel ushort chan_PRNG2GA_LS_ushort_prng; channel bool chan_GA2PRNG_LS_float_active; channel float chan_PRNG2GA_LS_float_prng; /* channel bool chan_GA2PRNG_LS2_float_active; channel float chan_PRNG2GA_LS2_float_prng; */ /* channel bool chan_GA2PRNG_LS23_float_active; channel float chan_PRNG2GA_LS3_float_prng; */ channel bool chan_GA2PRNG_Off_active; channel bool chan_GA2LS_LS1_active; channel float chan_GA2LS_LS1_energy; channel float chan_GA2LS_LS1_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS1_eval; channel float chan_LS2GA_LS1_energy; channel float chan_LS2GA_LS1_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel bool chan_GA2LS_LS2_active; channel float chan_GA2LS_LS2_energy; channel float chan_GA2LS_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS2_eval; channel float chan_LS2GA_LS2_energy; channel float chan_LS2GA_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); /* channel bool chan_GA2LS_LS3_active; channel float chan_GA2LS_LS3_energy; channel float chan_GA2LS_LS3_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS3_eval; channel float chan_LS2GA_LS3_energy; channel float chan_LS2GA_LS3_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); */ channel bool chan_GA2LS_Off_active; // -------------------------------------------------------------------------- // These functions map the argument into the interval 0 - 180, or 0 - 360 // by adding/subtracting n*ang_max to/from it. Loading Loading @@ -110,12 +165,12 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, float DockConst_abs_max_dang, float DockConst_crossover_rate, unsigned int DockConst_num_of_lsentities, unsigned int DockConst_max_num_of_iters, float DockConst_rho_lower_bound, float DockConst_base_dmov_mul_sqrt3, unsigned int DockConst_num_of_genes, float DockConst_base_dang_mul_sqrt3, unsigned int DockConst_cons_limit //unsigned int DockConst_max_num_of_iters, //float DockConst_rho_lower_bound, //float DockConst_base_dmov_mul_sqrt3, unsigned int DockConst_num_of_genes //, //float DockConst_base_dang_mul_sqrt3, //unsigned int DockConst_cons_limit ) { //Print algorithm parameters Loading Loading @@ -188,9 +243,14 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // Binary tournament ushort parent1, parent2; /* __local float genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; __local float genotype_bias [ACTUAL_GENOTYPE_LENGTH]; __local float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; */ __local ushort entity_ls[20]; __local float LocalPopNext[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH]; /* Loading Loading @@ -419,11 +479,16 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // choose all random entities // without checking if it has already been subjected to LS in this cycle write_channel_altera(chan_GA2PRNG_LS_ushort_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); for(uchar i=0; i<DockConst_num_of_lsentities; i++) { entity_ls [i] = read_channel_altera(chan_PRNG2GA_LS_ushort_prng); /* printf("LS entities idx: %u\n", entity_ls [i]); */ } // ------------------------------------------------------------------ Loading @@ -431,231 +496,75 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // ------------------------------------------------------------------ tmp_eval_cnt = 0; // subject num_of_entity_for_ls pieces of offsprings to LS for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt++) { //float genotype_bias [ACTUAL_GENOTYPE_LENGTH]; for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt++) { /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) genotype_bias [ACTUAL_GENOTYPE_LENGTH]; for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt+=2) { */ //float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; //float genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(1), numwriteports(1) )) genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; */ float rho = 1.0f; ushort iteration_cnt = 0; uchar cons_succ = 0; uchar cons_fail = 0; uint LS_eval = 0; bool positive_direction = true; // choose a random entity without checking if it has already been subjected to LS in this cycle write_channel_altera(chan_GA2PRNG_LS_ushort_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); ushort entity_for_ls = read_channel_altera(chan_PRNG2GA_LS_ushort_prng); //__local float offspring_genotype [ACTUAL_GENOTYPE_LENGTH]; /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) offspring_genotype [ACTUAL_GENOTYPE_LENGTH]; */ // performing local search while ((iteration_cnt < DockConst_max_num_of_iters) && (rho > DockConst_rho_lower_bound)) { // LS1 write_channel_altera(chan_GA2LS_LS1_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); write_channel_altera(chan_GA2LS_LS1_energy, LocalEneNext[entity_ls[ls_ent_cnt]]); mem_fence(CLK_CHANNEL_MEM_FENCE); // ----------------------------------------------- // Exit condition is groups here. It allows pipelining if (positive_direction == true) { if (cons_succ >= DockConst_cons_limit) { rho = LS_EXP_FACTOR*rho; cons_fail = 0; cons_succ = 0; } else { if (cons_fail >= DockConst_cons_limit) { rho = LS_CONT_FACTOR*rho; cons_fail = 0; cons_succ = 0; } } iteration_cnt++; for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2LS_LS1_genotype, LocalPopNext[entity_ls[ls_ent_cnt]][i & 0x3F]); } //printf("positive?: %u, iteration_cnt: %u, rho: %f, limit rho: %f\n", positive_direction, iteration_cnt, rho, DockConst_rho_lower_bound); // ----------------------------------------------- /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; */ // new random deviate // rho is the deviation of the uniform distribution for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2PRNG_LS_float_active, true); // LS2 write_channel_altera(chan_GA2LS_LS2_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); float tmp_prng = read_channel_altera(chan_PRNG2GA_LS_float_prng); // tmp1 is genotype_deviate float tmp1 = rho * (2.0f*tmp_prng - 1.0f); write_channel_altera(chan_GA2LS_LS2_energy, LocalEneNext[entity_ls[ls_ent_cnt+1]]); mem_fence(CLK_CHANNEL_MEM_FENCE); if (i<3) { tmp1 = tmp1 * DockConst_base_dmov_mul_sqrt3; } else { tmp1 = tmp1 * DockConst_base_dang_mul_sqrt3; for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2LS_LS2_genotype, LocalPopNext[entity_ls[ls_ent_cnt+1]][i & 0x3F]); } /* genotype_deviate [i] = tmp1; */ genotype_deviate [i] = 0.4f*tmp1; // tmp2 is the addition: genotype_deviate + genotype_bias float tmp2 = tmp1 + ((iteration_cnt == 1)? 0.0f:genotype_bias[i]); // tmp3 is entity_possible_new_genotype float tmp3; tmp3 = (positive_direction == true)? (LocalPopNext[entity_for_ls][i & 0x3F] + tmp2): (LocalPopNext[entity_for_ls][i & 0x3F] - tmp2); if (i>3) { if (i==4) { tmp3 = map_angle_180(tmp3); } else { tmp3 = map_angle_360(tmp3); } } entity_possible_new_genotype [i] = tmp3; write_channel_altera(chan_LS2Conf_genotype, tmp3); } // calculate energy of genotype float energyIA_LS_rx = read_channel_altera(chan_Intrae2StoreLS_intrae); float energyIE_LS_rx = read_channel_altera(chan_Intere2StoreLS_intere); float candidate_energy = energyIA_LS_rx + energyIE_LS_rx; // LS1 uint LS_eval = read_channel_altera(chan_LS2GA_LS1_eval); mem_fence(CLK_CHANNEL_MEM_FENCE); // update LS energy-evaluation count LS_eval++; LocalEneNext[entity_ls[ls_ent_cnt]] = read_channel_altera(chan_LS2GA_LS1_energy); mem_fence(CLK_CHANNEL_MEM_FENCE); #if 1 for (uchar i=0; i<DockConst_num_of_genes; i++) { // updating offspring_genotype // updating genotype_bias float tmp; float a = ((iteration_cnt == 1)? 0.0f:genotype_bias[i]); /* float b = 0.4f*genotype_deviate[i]; */ float b = genotype_deviate[i]; if (candidate_energy < LocalEneNext[entity_for_ls]) { LocalPopNext[entity_for_ls][i & 0x3F] = entity_possible_new_genotype [i]; float c = 0.6f*a; tmp = (positive_direction == true) ? (c + b): (c - b); } else { // updating (halving) genotype_bias tmp = 0.5f*a; } genotype_bias[i] = tmp; } // if the new entity is better if (candidate_energy < LocalEneNext[entity_for_ls]) { LocalEneNext[entity_for_ls] = candidate_energy; cons_succ++; cons_fail = 0; positive_direction = true; } else { if (positive_direction == false) { cons_fail++; cons_succ = 0; LocalPopNext[entity_ls[ls_ent_cnt]][i & 0x3F] = read_channel_altera(chan_LS2GA_LS1_genotype); } positive_direction = !positive_direction; } #endif //printf("After LS1 comes back in GA: %u\n", ls_ent_cnt); /* // if the new entity is better if (candidate_energy < LocalEneNext[entity_for_ls]) { #pragma unroll for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) { LocalPopNext[entity_for_ls][i & 0x3F] = entity_possible_new_genotype [i]; float c = 0.6f*((iteration_cnt == 1)? 0.0f:genotype_bias[i]); float b = genotype_deviate[i]; genotype_bias[i] = (positive_direction == true) ? (c + b): (c - b); } // LS2 uint eval_tmp = read_channel_altera(chan_LS2GA_LS2_eval); LS_eval += eval_tmp; mem_fence(CLK_CHANNEL_MEM_FENCE); LocalEneNext[entity_for_ls] = candidate_energy; cons_succ++; cons_fail = 0; positive_direction = true; } else { #pragma unroll for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) { genotype_bias[i] = 0.5f*genotype_bias[i]; } LocalEneNext[entity_ls[ls_ent_cnt+1]] = read_channel_altera(chan_LS2GA_LS2_energy); mem_fence(CLK_CHANNEL_MEM_FENCE); if (positive_direction == false) { cons_fail++; cons_succ = 0; } positive_direction = !positive_direction; for (uchar i=0; i<DockConst_num_of_genes; i++) { LocalPopNext[entity_ls[ls_ent_cnt+1]][i & 0x3F] = read_channel_altera(chan_LS2GA_LS2_genotype); } */ //printf("AFTER LS2 comes back in GA: %u\n", ls_ent_cnt); } // end of while (iteration_cnt) //------------------------------------------------------------------------------------------------------------ tmp_eval_cnt += LS_eval; } // End of for-loop ls_ent_cnt // ------------------------------------------------------------------ // update current pops & energies for (ushort pop_cnt=0;pop_cnt<DockConst_pop_size; pop_cnt++) { Loading @@ -677,8 +586,12 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // ------------------------------------------------------------------ // Off: turn off Conform, InterE, IntraE // ------------------------------------------------------------------ write_channel_altera(chan_Off2Conf_active, false); write_channel_altera(chan_GA2LS_Off_active, false); write_channel_altera(chan_GA2PRNG_Off_active, false); write_channel_altera(chan_Off2Conf_active, false); //mem_fence(CLK_CHANNEL_MEM_FENCE); for (ushort pop_cnt=0;pop_cnt<DockConst_pop_size; pop_cnt++) { Loading @@ -704,6 +617,7 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- #include "Krnl_LS.cl" #include "Krnl_PRNG.cl" #include "Krnl_Conform.cl" #include "Krnl_InterE.cl" Loading ofdock_taskpar_alt/device/Krnl_InterE.cl +8 −0 Original line number Diff line number Diff line Loading @@ -276,7 +276,15 @@ while(active) { case 0x03: // LS write_channel_altera(chan_Intere2StoreLS_intere, interE); break; /* case 0x04: // LS 2 write_channel_altera(chan_Intere2StoreLS_LS2_intere, interE); break; case 0x06: // LS 2 write_channel_altera(chan_Intere2StoreLS_LS2_intere, interE); break; */ //case 5: // Off // write_channel_altera(chan_Intere2StoreOff_intere, interE); //break; Loading ofdock_taskpar_alt/device/Krnl_IntraE.cl +9 −1 Original line number Diff line number Diff line Loading @@ -164,10 +164,18 @@ while(active) { write_channel_altera(chan_Intrae2StoreGG_intrae, intraE); break; case 0x03: // LS case 0x03: // LS 1 write_channel_altera(chan_Intrae2StoreLS_intrae, intraE); break; /* case 0x04: // LS 2 write_channel_altera(chan_Intrae2StoreLS_LS2_intrae, intraE); break; case 0x06: // LS 3 write_channel_altera(chan_Intrae2StoreLS_LS3_intrae, intraE); break; */ //case 5: // Off // write_channel_altera(chan_Intrae2StoreOff_intrae, intraE); //break; Loading Loading
ofdock_taskpar_alt/Makefile +34 −1 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ ENABLE_K2 = YES ENABLE_K3 = YES ENABLE_K4 = YES # Prng kernels ENABLE_K5 = YES ENABLE_K6 = YES ENABLE_K7 = YES Loading @@ -150,6 +151,13 @@ ENABLE_K9 = YES ENABLE_K10 = YES ENABLE_K11 = YES # LS kernels ENABLE_K12 = YES ENABLE_K13 = YES #ENABLE_K14 = YES #ENABLE_K15 = YES ifeq ($(ENABLE_K1),YES) K1 =-DENABLE_KERNEL1 else Loading Loading @@ -216,7 +224,32 @@ else K11 = endif ENABLE_KERNELS = $(K1) $(K2) $(K3) $(K4) $(K5) $(K6) $(K7) $(K8) $(K9) $(K10) $(K11) ifeq ($(ENABLE_K12),YES) K12 =-DENABLE_KERNEL12 else K12 = endif ifeq ($(ENABLE_K13),YES) K13 =-DENABLE_KERNEL13 else K13 = endif ifeq ($(ENABLE_K14),YES) K14 =-DENABLE_KERNEL14 else K14 = endif ifeq ($(ENABLE_K15),YES) K15 =-DENABLE_KERNEL15 else K15 = endif ENABLE_KERNELS = $(K1) $(K2) $(K3) $(K4) $(K5) $(K6) $(K7) $(K8) $(K9) $(K10) $(K11) $(K12) $(K13) $(K14) $(K15) # ============================= # Reproduce result (remove randomness) Loading
ofdock_taskpar_alt/device/Krnl_Conform.cl +18 −24 Original line number Diff line number Diff line Loading @@ -63,11 +63,7 @@ while(active) { bool GG_valid = false; bool LS_valid = false; bool Off_valid = false; /* bool IC_active; bool GG_active; bool LS_active; */ float IC_active; float GG_active; float LS_active; Loading Loading @@ -99,37 +95,23 @@ while(active) { } char mode; /* float genotype[ACTUAL_GENOTYPE_LENGTH]; */ /* active = (IC_valid) ? IC_active : (GG_valid) ? GG_active : (LS_valid) ? LS_active : */ //printf("LS_valid: %u, LS2_valid: %u\n", LS_valid, LS2_valid); active = (IC_valid) ? true : (GG_valid) ? true : (LS_valid) ? true : (Off_valid) ? Off_active : false; // last case should never occur, otherwise above while would be still running mode = (IC_valid) ? 0x01 : (GG_valid) ? 0x02 : (LS_valid) ? 0x03 : (Off_valid) ? 0x05 : 0x05; // last case should never occur, otherwise above while would be still running /* for (uchar pipe_cnt=0; pipe_cnt<DockConst_num_of_genes; pipe_cnt++) { genotype[pipe_cnt] = (IC_valid) ? read_channel_altera(chan_IC2Conf_genotype) : (GG_valid) ? read_channel_altera(chan_GG2Conf_genotype) : (LS_valid) ? read_channel_altera(chan_LS2Conf_genotype) : (Off_valid) ? 0.0f: 0.0f; // last case should never occur, otherwise above while would be still running } */ // -------------------------------------------------------------- //printf("AFTER In CONFORM CHANNEL\n"); /* Loading Loading @@ -317,6 +299,13 @@ while(active) { printf("BEFORE Out CONFORM CHANNEL\n"); #endif /* if (mode == 0x04) { printf("Krnl_Conform after loop\n"); } */ // -------------------------------------------------------------- // Send ligand atomic coordinates to channel // -------------------------------------------------------------- Loading @@ -333,6 +322,11 @@ while(active) { write_channel_altera(chan_Conf2Intere_xyz, loc_coords[pipe_cnt]); write_channel_altera(chan_Conf2Intrae_xyz, loc_coords[pipe_cnt]); } /* if (mode == 0x04) { printf("Krnl_Conform sent\n"); } */ // -------------------------------------------------------------- #if defined (DEBUG_KRNL_CONFORM) Loading
ofdock_taskpar_alt/device/Krnl_GA.cl +128 −214 Original line number Diff line number Diff line Loading @@ -24,10 +24,21 @@ channel float chan_IC2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_GG2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_LS2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); /* channel float chan_LS2Conf_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel float chan_LS2Conf_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); */ // To turn off Conform, InterE, IntraE /* channel bool chan_IC2Conf_active; channel bool chan_GG2Conf_active; channel bool chan_LS2Conf_LS1_active; channel bool chan_LS2Conf_LS2_active; */ channel bool chan_Off2Conf_active; channel float3 chan_Conf2Intere_xyz __attribute__((depth(MAX_NUM_OF_ATOMS))); channel bool chan_Conf2Intere_active; channel char chan_Conf2Intere_mode; Loading @@ -39,10 +50,19 @@ channel char chan_Conf2Intrae_mode; channel float chan_Intere2StoreIC_intere __attribute__((depth(MAX_POPSIZE))); channel float chan_Intere2StoreGG_intere __attribute__((depth(MAX_POPSIZE))); channel float chan_Intere2StoreLS_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE channel float chan_Intere2StoreLS_LS2_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE /* channel float chan_Intere2StoreLS_LS3_intere __attribute__((depth(20))); // it requires 6% MAX_POPSIZE */ channel float chan_Intrae2StoreIC_intrae __attribute__((depth(MAX_POPSIZE))); channel float chan_Intrae2StoreGG_intrae __attribute__((depth(MAX_POPSIZE))); channel float chan_Intrae2StoreLS_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE channel float chan_Intrae2StoreLS_LS2_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE /* channel float chan_Intrae2StoreLS_LS3_intrae __attribute__((depth(20))); // it requires 6% MAX_POPSIZE */ // PRNG kernerls channel bool chan_GA2PRNG_BT_ushort_active; Loading @@ -62,9 +82,44 @@ channel ushort chan_PRNG2GA_LS_ushort_prng; channel bool chan_GA2PRNG_LS_float_active; channel float chan_PRNG2GA_LS_float_prng; /* channel bool chan_GA2PRNG_LS2_float_active; channel float chan_PRNG2GA_LS2_float_prng; */ /* channel bool chan_GA2PRNG_LS23_float_active; channel float chan_PRNG2GA_LS3_float_prng; */ channel bool chan_GA2PRNG_Off_active; channel bool chan_GA2LS_LS1_active; channel float chan_GA2LS_LS1_energy; channel float chan_GA2LS_LS1_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS1_eval; channel float chan_LS2GA_LS1_energy; channel float chan_LS2GA_LS1_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel bool chan_GA2LS_LS2_active; channel float chan_GA2LS_LS2_energy; channel float chan_GA2LS_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS2_eval; channel float chan_LS2GA_LS2_energy; channel float chan_LS2GA_LS2_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); /* channel bool chan_GA2LS_LS3_active; channel float chan_GA2LS_LS3_energy; channel float chan_GA2LS_LS3_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); channel uint chan_LS2GA_LS3_eval; channel float chan_LS2GA_LS3_energy; channel float chan_LS2GA_LS3_genotype __attribute__((depth(MAX_NUM_OF_ROTBONDS+6))); */ channel bool chan_GA2LS_Off_active; // -------------------------------------------------------------------------- // These functions map the argument into the interval 0 - 180, or 0 - 360 // by adding/subtracting n*ang_max to/from it. Loading Loading @@ -110,12 +165,12 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, float DockConst_abs_max_dang, float DockConst_crossover_rate, unsigned int DockConst_num_of_lsentities, unsigned int DockConst_max_num_of_iters, float DockConst_rho_lower_bound, float DockConst_base_dmov_mul_sqrt3, unsigned int DockConst_num_of_genes, float DockConst_base_dang_mul_sqrt3, unsigned int DockConst_cons_limit //unsigned int DockConst_max_num_of_iters, //float DockConst_rho_lower_bound, //float DockConst_base_dmov_mul_sqrt3, unsigned int DockConst_num_of_genes //, //float DockConst_base_dang_mul_sqrt3, //unsigned int DockConst_cons_limit ) { //Print algorithm parameters Loading Loading @@ -188,9 +243,14 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // Binary tournament ushort parent1, parent2; /* __local float genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; __local float genotype_bias [ACTUAL_GENOTYPE_LENGTH]; __local float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; */ __local ushort entity_ls[20]; __local float LocalPopNext[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH]; /* Loading Loading @@ -419,11 +479,16 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // choose all random entities // without checking if it has already been subjected to LS in this cycle write_channel_altera(chan_GA2PRNG_LS_ushort_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); for(uchar i=0; i<DockConst_num_of_lsentities; i++) { entity_ls [i] = read_channel_altera(chan_PRNG2GA_LS_ushort_prng); /* printf("LS entities idx: %u\n", entity_ls [i]); */ } // ------------------------------------------------------------------ Loading @@ -431,231 +496,75 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // ------------------------------------------------------------------ tmp_eval_cnt = 0; // subject num_of_entity_for_ls pieces of offsprings to LS for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt++) { //float genotype_bias [ACTUAL_GENOTYPE_LENGTH]; for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt++) { /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) genotype_bias [ACTUAL_GENOTYPE_LENGTH]; for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst_num_of_lsentities; ls_ent_cnt+=2) { */ //float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; //float genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(1), numwriteports(1) )) genotype_deviate [ACTUAL_GENOTYPE_LENGTH]; */ float rho = 1.0f; ushort iteration_cnt = 0; uchar cons_succ = 0; uchar cons_fail = 0; uint LS_eval = 0; bool positive_direction = true; // choose a random entity without checking if it has already been subjected to LS in this cycle write_channel_altera(chan_GA2PRNG_LS_ushort_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); ushort entity_for_ls = read_channel_altera(chan_PRNG2GA_LS_ushort_prng); //__local float offspring_genotype [ACTUAL_GENOTYPE_LENGTH]; /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) offspring_genotype [ACTUAL_GENOTYPE_LENGTH]; */ // performing local search while ((iteration_cnt < DockConst_max_num_of_iters) && (rho > DockConst_rho_lower_bound)) { // LS1 write_channel_altera(chan_GA2LS_LS1_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); write_channel_altera(chan_GA2LS_LS1_energy, LocalEneNext[entity_ls[ls_ent_cnt]]); mem_fence(CLK_CHANNEL_MEM_FENCE); // ----------------------------------------------- // Exit condition is groups here. It allows pipelining if (positive_direction == true) { if (cons_succ >= DockConst_cons_limit) { rho = LS_EXP_FACTOR*rho; cons_fail = 0; cons_succ = 0; } else { if (cons_fail >= DockConst_cons_limit) { rho = LS_CONT_FACTOR*rho; cons_fail = 0; cons_succ = 0; } } iteration_cnt++; for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2LS_LS1_genotype, LocalPopNext[entity_ls[ls_ent_cnt]][i & 0x3F]); } //printf("positive?: %u, iteration_cnt: %u, rho: %f, limit rho: %f\n", positive_direction, iteration_cnt, rho, DockConst_rho_lower_bound); // ----------------------------------------------- /* float __attribute__ (( memory, numbanks(1), bankwidth(64), singlepump, numreadports(2), numwriteports(1) )) entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH]; */ // new random deviate // rho is the deviation of the uniform distribution for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2PRNG_LS_float_active, true); // LS2 write_channel_altera(chan_GA2LS_LS2_active, true); mem_fence(CLK_CHANNEL_MEM_FENCE); float tmp_prng = read_channel_altera(chan_PRNG2GA_LS_float_prng); // tmp1 is genotype_deviate float tmp1 = rho * (2.0f*tmp_prng - 1.0f); write_channel_altera(chan_GA2LS_LS2_energy, LocalEneNext[entity_ls[ls_ent_cnt+1]]); mem_fence(CLK_CHANNEL_MEM_FENCE); if (i<3) { tmp1 = tmp1 * DockConst_base_dmov_mul_sqrt3; } else { tmp1 = tmp1 * DockConst_base_dang_mul_sqrt3; for (uchar i=0; i<DockConst_num_of_genes; i++) { write_channel_altera(chan_GA2LS_LS2_genotype, LocalPopNext[entity_ls[ls_ent_cnt+1]][i & 0x3F]); } /* genotype_deviate [i] = tmp1; */ genotype_deviate [i] = 0.4f*tmp1; // tmp2 is the addition: genotype_deviate + genotype_bias float tmp2 = tmp1 + ((iteration_cnt == 1)? 0.0f:genotype_bias[i]); // tmp3 is entity_possible_new_genotype float tmp3; tmp3 = (positive_direction == true)? (LocalPopNext[entity_for_ls][i & 0x3F] + tmp2): (LocalPopNext[entity_for_ls][i & 0x3F] - tmp2); if (i>3) { if (i==4) { tmp3 = map_angle_180(tmp3); } else { tmp3 = map_angle_360(tmp3); } } entity_possible_new_genotype [i] = tmp3; write_channel_altera(chan_LS2Conf_genotype, tmp3); } // calculate energy of genotype float energyIA_LS_rx = read_channel_altera(chan_Intrae2StoreLS_intrae); float energyIE_LS_rx = read_channel_altera(chan_Intere2StoreLS_intere); float candidate_energy = energyIA_LS_rx + energyIE_LS_rx; // LS1 uint LS_eval = read_channel_altera(chan_LS2GA_LS1_eval); mem_fence(CLK_CHANNEL_MEM_FENCE); // update LS energy-evaluation count LS_eval++; LocalEneNext[entity_ls[ls_ent_cnt]] = read_channel_altera(chan_LS2GA_LS1_energy); mem_fence(CLK_CHANNEL_MEM_FENCE); #if 1 for (uchar i=0; i<DockConst_num_of_genes; i++) { // updating offspring_genotype // updating genotype_bias float tmp; float a = ((iteration_cnt == 1)? 0.0f:genotype_bias[i]); /* float b = 0.4f*genotype_deviate[i]; */ float b = genotype_deviate[i]; if (candidate_energy < LocalEneNext[entity_for_ls]) { LocalPopNext[entity_for_ls][i & 0x3F] = entity_possible_new_genotype [i]; float c = 0.6f*a; tmp = (positive_direction == true) ? (c + b): (c - b); } else { // updating (halving) genotype_bias tmp = 0.5f*a; } genotype_bias[i] = tmp; } // if the new entity is better if (candidate_energy < LocalEneNext[entity_for_ls]) { LocalEneNext[entity_for_ls] = candidate_energy; cons_succ++; cons_fail = 0; positive_direction = true; } else { if (positive_direction == false) { cons_fail++; cons_succ = 0; LocalPopNext[entity_ls[ls_ent_cnt]][i & 0x3F] = read_channel_altera(chan_LS2GA_LS1_genotype); } positive_direction = !positive_direction; } #endif //printf("After LS1 comes back in GA: %u\n", ls_ent_cnt); /* // if the new entity is better if (candidate_energy < LocalEneNext[entity_for_ls]) { #pragma unroll for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) { LocalPopNext[entity_for_ls][i & 0x3F] = entity_possible_new_genotype [i]; float c = 0.6f*((iteration_cnt == 1)? 0.0f:genotype_bias[i]); float b = genotype_deviate[i]; genotype_bias[i] = (positive_direction == true) ? (c + b): (c - b); } // LS2 uint eval_tmp = read_channel_altera(chan_LS2GA_LS2_eval); LS_eval += eval_tmp; mem_fence(CLK_CHANNEL_MEM_FENCE); LocalEneNext[entity_for_ls] = candidate_energy; cons_succ++; cons_fail = 0; positive_direction = true; } else { #pragma unroll for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) { genotype_bias[i] = 0.5f*genotype_bias[i]; } LocalEneNext[entity_ls[ls_ent_cnt+1]] = read_channel_altera(chan_LS2GA_LS2_energy); mem_fence(CLK_CHANNEL_MEM_FENCE); if (positive_direction == false) { cons_fail++; cons_succ = 0; } positive_direction = !positive_direction; for (uchar i=0; i<DockConst_num_of_genes; i++) { LocalPopNext[entity_ls[ls_ent_cnt+1]][i & 0x3F] = read_channel_altera(chan_LS2GA_LS2_genotype); } */ //printf("AFTER LS2 comes back in GA: %u\n", ls_ent_cnt); } // end of while (iteration_cnt) //------------------------------------------------------------------------------------------------------------ tmp_eval_cnt += LS_eval; } // End of for-loop ls_ent_cnt // ------------------------------------------------------------------ // update current pops & energies for (ushort pop_cnt=0;pop_cnt<DockConst_pop_size; pop_cnt++) { Loading @@ -677,8 +586,12 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // ------------------------------------------------------------------ // Off: turn off Conform, InterE, IntraE // ------------------------------------------------------------------ write_channel_altera(chan_Off2Conf_active, false); write_channel_altera(chan_GA2LS_Off_active, false); write_channel_altera(chan_GA2PRNG_Off_active, false); write_channel_altera(chan_Off2Conf_active, false); //mem_fence(CLK_CHANNEL_MEM_FENCE); for (ushort pop_cnt=0;pop_cnt<DockConst_pop_size; pop_cnt++) { Loading @@ -704,6 +617,7 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent, // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- #include "Krnl_LS.cl" #include "Krnl_PRNG.cl" #include "Krnl_Conform.cl" #include "Krnl_InterE.cl" Loading
ofdock_taskpar_alt/device/Krnl_InterE.cl +8 −0 Original line number Diff line number Diff line Loading @@ -276,7 +276,15 @@ while(active) { case 0x03: // LS write_channel_altera(chan_Intere2StoreLS_intere, interE); break; /* case 0x04: // LS 2 write_channel_altera(chan_Intere2StoreLS_LS2_intere, interE); break; case 0x06: // LS 2 write_channel_altera(chan_Intere2StoreLS_LS2_intere, interE); break; */ //case 5: // Off // write_channel_altera(chan_Intere2StoreOff_intere, interE); //break; Loading
ofdock_taskpar_alt/device/Krnl_IntraE.cl +9 −1 Original line number Diff line number Diff line Loading @@ -164,10 +164,18 @@ while(active) { write_channel_altera(chan_Intrae2StoreGG_intrae, intraE); break; case 0x03: // LS case 0x03: // LS 1 write_channel_altera(chan_Intrae2StoreLS_intrae, intraE); break; /* case 0x04: // LS 2 write_channel_altera(chan_Intrae2StoreLS_LS2_intrae, intraE); break; case 0x06: // LS 3 write_channel_altera(chan_Intrae2StoreLS_LS3_intrae, intraE); break; */ //case 5: // Off // write_channel_altera(chan_Intrae2StoreOff_intrae, intraE); //break; Loading