Commit f9234691 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

solved segfault by limiting value of u1 into 0.1-0.9

parent 6c601854
......@@ -196,9 +196,9 @@ odock: check-env-all stringify $(SRC)
# Example
PDB := 1stp
NRUN := 1
POPSIZE := 50
PDB := 3ce3
NRUN := 100
POPSIZE := 150
TESTNAME:= test
test: odock
......
......@@ -289,16 +289,33 @@ void gpu_calc_energy( int dockpars_rotbondlist_length,
rotation_unitvec[0] = genrot_unitvec[0];
rotation_unitvec[1] = genrot_unitvec[1];
rotation_unitvec[2] = genrot_unitvec[2];
rotation_angle = genrotangle;rotation_unitvec
rotation_angle = genrotangle;
*/
// Moved back in here
// Transforming Shoemake (u1, u2, u3) into quaternions
// FIXME: add precision choices with preprocessor directives:
// NATIVE_PRECISION, HALF_PRECISION, Full precision
quatrot_left_q = sqrt(1 - u1) * sin(u2);
quatrot_left_x = sqrt(1 - u1) * cos(u2);
quatrot_left_y = sqrt(u1) * sin(u3);
quatrot_left_z = sqrt(u1) * cos(u3);
if (u1 > 1) {
u1 = 0.9f;
}
if (u1 < 0) {
u1 = 0.1f;
}
quatrot_left_q = native_sqrt(1 - u1) * native_sin(u2);
quatrot_left_x = native_sqrt(1 - u1) * native_cos(u2);
quatrot_left_y = native_sqrt(u1) * native_sin(u3);
quatrot_left_z = native_sqrt(u1) * native_cos(u3);
/*
if ((1-u1) < 0) {
printf("u1:%f 1-u1:%f sqrt(1-u1):%f\n", u1, (1-u1), sqrt(1-u1));
}
*/
// Kept as the original
rotation_movingvec[0] = genotype[0];
......@@ -342,8 +359,8 @@ void gpu_calc_energy( int dockpars_rotbondlist_length,
// FIXME: add precision choices with preprocessor directives:
// NATIVE_PRECISION, HALF_PRECISION, Full precision
rotation_angle = rotation_angle/2;
quatrot_left_q = cos(rotation_angle);
sin_angle = sin(rotation_angle);
quatrot_left_q = native_cos(rotation_angle);
sin_angle = native_sin(rotation_angle);
quatrot_left_x = sin_angle*rotation_unitvec[0];
quatrot_left_y = sin_angle*rotation_unitvec[1];
quatrot_left_z = sin_angle*rotation_unitvec[2];
......
......@@ -199,9 +199,24 @@ perform_LS( char dockpars_num_of_atoms,
//generating new genotype candidate
for (gene_counter=get_local_id(0);
gene_counter<dockpars_num_of_genes;
gene_counter += NUM_OF_THREADS_PER_BLOCK)
gene_counter += NUM_OF_THREADS_PER_BLOCK) {
genotype_candidate[gene_counter] = offspring_genotype[gene_counter] + genotype_deviate[gene_counter] + genotype_bias[gene_counter];
///*
if (gene_counter == 3) {// u1, FIXME: hardcoded
if (genotype_candidate[gene_counter] > 1.0f) { // clamp it
offspring_genotype[gene_counter] = 0.9f;
}
if (genotype_candidate[gene_counter] < 0.0f) { // clamp it
offspring_genotype[gene_counter] = 0.1f;
}
//printf("LS positive - genotype_candidate[gene_counter]: %f\n", genotype_candidate[gene_counter]);
}
//*/
}
//evaluating candidate
barrier(CLK_LOCAL_MEM_FENCE);
......@@ -279,9 +294,23 @@ perform_LS( char dockpars_num_of_atoms,
//generating the other genotype candidate
for (gene_counter=get_local_id(0);
gene_counter<dockpars_num_of_genes;
gene_counter += NUM_OF_THREADS_PER_BLOCK)
gene_counter += NUM_OF_THREADS_PER_BLOCK) {
genotype_candidate[gene_counter] = offspring_genotype[gene_counter] - genotype_deviate[gene_counter] - genotype_bias[gene_counter];
///*
if (gene_counter == 3) {// u1, FIXME: hardcoded
if (genotype_candidate[gene_counter] > 1.0f) { // clamp it
offspring_genotype[gene_counter] = 0.9f;
}
if (genotype_candidate[gene_counter] < 0.0f) { // clamp it
offspring_genotype[gene_counter] = 0.1f;
}
//printf("LS negative - genotype_candidate[gene_counter]: %f\n", genotype_candidate[gene_counter]);
}
//*/
}
//evaluating candidate
barrier(CLK_LOCAL_MEM_FENCE);
......
......@@ -250,8 +250,20 @@ gpu_gen_and_eval_newpops(char dockpars_num_of_atoms,
*/
if (gene_counter < 3)
offspring_genotype[gene_counter] += dockpars_abs_max_dmov*(2*gpu_randf(dockpars_prng_states)-1);
else if (gene_counter == 3) // u1, FIXME: hardcoded
else if (gene_counter == 3) {// u1, FIXME: hardcoded
offspring_genotype[gene_counter] += 0.2f*(2*gpu_randf(dockpars_prng_states)-1);
///*
if (offspring_genotype[gene_counter] > 1.0f) { // clamp it
offspring_genotype[gene_counter] = 0.9f;
}
if (offspring_genotype[gene_counter] < 0.0f) { // clamp it
offspring_genotype[gene_counter] = 0.1f;
}
//printf("mutation - offspring_genotype[gene_counter]: %f\n", offspring_genotype[gene_counter]);
//*/
}
else if (gene_counter < 6) { // u2&3, FIXME: hardcoded
offspring_genotype[gene_counter] += 90.0f*(2*gpu_randf(dockpars_prng_states)-1);
map_angle(&(offspring_genotype[gene_counter]));
......
......@@ -722,10 +722,10 @@ filled with clock() */
#if defined (DOCK_DEBUG)
for (int cnt_pop=0;cnt_pop<size_populations/sizeof(float);cnt_pop++)
printf("total_num_pop: %u, cpu_final_populations[%u]: %f\n",(unsigned int)(size_populations/sizeof(float)),cnt_pop,cpu_final_populations[cnt_pop]);
#endif
for (int cnt_pop=0;cnt_pop<size_energies/sizeof(float);cnt_pop++)
printf("total_num_energies: %u, cpu_energies[%u]: %f\n", (unsigned int)(size_energies/sizeof(float)),cnt_pop,cpu_energies[cnt_pop]);
#endif
// ===============================================================================
......
......@@ -1240,6 +1240,7 @@ void change_conform_f(Liganddata* myligand,
}
#endif // End of original change_conform_f()
#if 1
void change_conform_f(Liganddata* myligand,
const float genotype_f [],
float* cpu_ref_ori_angles,
......@@ -1322,12 +1323,12 @@ void change_conform_f(Liganddata* myligand,
rotate_shoemake(&(myligand->atom_idxyzq[atom_id][1]),
genrot_movvec,
&refori_shoemake [0],
refori_shoemake,
debug); //rotating to reference oritentation
rotate_shoemake(&(myligand->atom_idxyzq[atom_id][1]),
genrot_movvec,
&shoemake [0],
shoemake,
debug); //general rotation
}
......@@ -1338,6 +1339,7 @@ void change_conform_f(Liganddata* myligand,
printf("Moved point (final values) (x,y,z): %lf, %lf, %lf\n", myligand->atom_idxyzq [atom_id][1], myligand->atom_idxyzq [atom_id][2], myligand->atom_idxyzq [atom_id][3]);
}
#endif
float calc_interE_f(const Gridinfo* mygrid,
const Liganddata* myligand,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment