Commit 029397e9 authored by lvs's avatar lvs
Browse files

modified debug printing similar to autodockdevpy

parent 9f3aedd6
...@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//#define DEBUG_ENERGY_KERNEL #define DEBUG_ENERGY_KERNEL
#include "calcenergy_basic.h" #include "calcenergy_basic.h"
......
...@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// since this determines which reference orientation should be used. // since this determines which reference orientation should be used.
//#define DEBUG_GRAD_TRANSLATION_GENES //#define DEBUG_GRAD_TRANSLATION_GENES
//#define DEBUG_GRAD_ROTATION_GENES #define DEBUG_GRAD_ROTATION_GENES
//#define DEBUG_GRAD_TORSION_GENES //#define DEBUG_GRAD_TORSION_GENES
...@@ -853,7 +853,8 @@ void gpu_calc_gradient( ...@@ -853,7 +853,8 @@ void gpu_calc_gradient(
torque_rot.z = 0.0f; torque_rot.z = 0.0f;
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-20s %-10.5f %-10.5f %-10.5f\n", "initial torque: ", torque_rot.x, torque_rot.y, torque_rot.z); printf("\n%s\n", "----------------------------------------------------------");
printf("%-20s %-10.6f %-10.6f %-10.6f\n", "initial torque: ", torque_rot.x, torque_rot.y, torque_rot.z);
#endif #endif
// Declaring a variable to hold the center of rotation // Declaring a variable to hold the center of rotation
...@@ -884,16 +885,31 @@ void gpu_calc_gradient( ...@@ -884,16 +885,31 @@ void gpu_calc_gradient(
torque_rot += cross(r, force); torque_rot += cross(r, force);
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
#if 0
printf("%-20s %-10u\n", "contrib. of atom-id: ", lig_atom_id); printf("%-20s %-10u\n", "contrib. of atom-id: ", lig_atom_id);
printf("%-20s %-10.5f %-10.5f %-10.5f\n", "r : ", r.x, r.y, r.z); printf("%-20s %-10.5f %-10.5f %-10.5f\n", "r : ", r.x, r.y, r.z);
printf("%-20s %-10.5f %-10.5f %-10.5f\n", "force : ", force.x, force.y, force.z); printf("%-20s %-10.5f %-10.5f %-10.5f\n", "force : ", force.x, force.y, force.z);
printf("%-20s %-10.5f %-10.5f %-10.5f\n", "partial torque: ", torque_rot.x, torque_rot.y, torque_rot.z); printf("%-20s %-10.5f %-10.5f %-10.5f\n", "partial torque: ", torque_rot.x, torque_rot.y, torque_rot.z);
printf("\n"); printf("\n");
#endif
// This printing is similar to autodockdevpy
if (lig_atom_id == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%-10s %-10s %-10s %-10s %-11s %-11s %-11s %-11s %-11s %-11s\n", "atom_id", "r.x", "r.y", "r.z", "force.x", "force.y", "force.z", "torque.x", "torque.y", "torque.z");
}
printf("%-10u %-10.6f %-10.6f %-10.6f %-11.6f %-11.6f %-11.6f %-11.6f %-11.6f %-11.6f\n", lig_atom_id, r.x, r.y, r.z, force.x, force.y, force.z, torque_rot.x, torque_rot.y, torque_rot.z);
//printf("%-10u %-10.6f %-10.6f %-10.6f %-10.6f %-10.6f %-10.6f\n", lig_atom_id, r.x, r.y, r.z, force.x, force.y, force.z);
#endif #endif
} }
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-20s %-10.5f %-10.5f %-10.5f\n", "final torque: ", torque_rot.x, torque_rot.y, torque_rot.z); printf("\n%s\n", "----------------------------------------------------------");
printf("%-20s %-10.6f %-10.6f %-10.6f\n", "final torque: ", torque_rot.x, torque_rot.y, torque_rot.z);
#endif #endif
// Derived from rotation.py/axisangle_to_q() // Derived from rotation.py/axisangle_to_q()
...@@ -901,7 +917,8 @@ void gpu_calc_gradient( ...@@ -901,7 +917,8 @@ void gpu_calc_gradient(
float torque_length = fast_length(torque_rot); float torque_length = fast_length(torque_rot);
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-20s %-10.5f\n", "torque length: ", torque_length); printf("\n%s\n", "----------------------------------------------------------");
printf("%-20s %-10.6f\n", "torque length: ", torque_length);
#endif #endif
/* /*
...@@ -920,12 +937,19 @@ void gpu_calc_gradient( ...@@ -920,12 +937,19 @@ void gpu_calc_gradient(
#endif #endif
quat_torque.w = COS_HALF_INFINITESIMAL_RADIAN; quat_torque.w = COS_HALF_INFINITESIMAL_RADIAN;
quat_torque.x = fast_normalize(torque_rot).x * SIN_HALF_INFINITESIMAL_RADIAN; quat_torque.x = fast_normalize(torque_rot).x * SIN_HALF_INFINITESIMAL_RADIAN;
quat_torque.y = fast_normalize(torque_rot).y * SIN_HALF_INFINITESIMAL_RADIAN; quat_torque.y = fast_normalize(torque_rot).y * SIN_HALF_INFINITESIMAL_RADIAN;
quat_torque.z = fast_normalize(torque_rot).z * SIN_HALF_INFINITESIMAL_RADIAN; quat_torque.z = fast_normalize(torque_rot).z * SIN_HALF_INFINITESIMAL_RADIAN;
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-20s %-10.5f %-10.5f %-10.5f %-10.5f\n", "quat_torque (w,x,y,z): ", quat_torque.w, quat_torque.x, quat_torque.y, quat_torque.z); #if 0
printf("fast_normalize(torque_rot).x:%-.6f\n", fast_normalize(torque_rot).x);
printf("fast_normalize(torque_rot).y:%-.6f\n", fast_normalize(torque_rot).y);
printf("fast_normalize(torque_rot).z:%-.6f\n", fast_normalize(torque_rot).z);
#endif
printf("\n%s\n", "----------------------------------------------------------");
printf("%-20s %-10.6f %-10.6f %-10.6f %-10.6f\n", "quat_torque (w,x,y,z): ", quat_torque.w, quat_torque.x, quat_torque.y, quat_torque.z);
#endif #endif
// Converting quaternion gradients into orientation gradients // Converting quaternion gradients into orientation gradients
...@@ -950,7 +974,8 @@ void gpu_calc_gradient( ...@@ -950,7 +974,8 @@ void gpu_calc_gradient(
bool is_theta_gt_pi = (current_theta > PI_FLOAT) ? true: false; bool is_theta_gt_pi = (current_theta > PI_FLOAT) ? true: false;
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.5f %-10.5f %-10.5f\n", "current_axisangle (1,2,3): ", current_phi, current_theta, current_rotangle); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f\n", "current_axisangle (1,2,3): ", current_phi, current_theta, current_rotangle);
#endif #endif
// This is where we are in quaternion space // This is where we are in quaternion space
...@@ -970,7 +995,8 @@ void gpu_calc_gradient( ...@@ -970,7 +995,8 @@ void gpu_calc_gradient(
current_q.z = rotaxis_z * native_sin(ang); current_q.z = rotaxis_z * native_sin(ang);
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.8f %-10.8f %-10.8f %-10.8f\n", "current_q (w,x,y,z): ", current_q.w, current_q.x, current_q.y, current_q.z); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f %-10.6f\n", "current_q (w,x,y,z): ", current_q.w, current_q.x, current_q.y, current_q.z);
#endif #endif
// This is where we want to be in quaternion space // This is where we want to be in quaternion space
...@@ -984,7 +1010,8 @@ void gpu_calc_gradient( ...@@ -984,7 +1010,8 @@ void gpu_calc_gradient(
target_q.y = quat_torque.w*current_q.y + quat_torque.y*current_q.w + quat_torque.z*current_q.x - quat_torque.x*current_q.z;// y target_q.y = quat_torque.w*current_q.y + quat_torque.y*current_q.w + quat_torque.z*current_q.x - quat_torque.x*current_q.z;// y
target_q.z = quat_torque.w*current_q.z + quat_torque.z*current_q.w + quat_torque.x*current_q.y - quat_torque.y*current_q.x;// z target_q.z = quat_torque.w*current_q.z + quat_torque.z*current_q.w + quat_torque.x*current_q.y - quat_torque.y*current_q.x;// z
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.8f %-10.8f %-10.8f %-10.8f\n", "target_q (w,x,y,z): ", target_q.w, target_q.x, target_q.y, target_q.z); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f %-10.6f\n", "target_q (w,x,y,z): ", target_q.w, target_q.x, target_q.y, target_q.z);
#endif #endif
// This is where we want to be in the orientation axis-angle space // This is where we want to be in the orientation axis-angle space
...@@ -1013,7 +1040,8 @@ void gpu_calc_gradient( ...@@ -1013,7 +1040,8 @@ void gpu_calc_gradient(
} }
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.8f %-10.8f %-10.8f\n", "target_axisangle (1,2,3) - after mapping: ", target_phi, target_theta, target_rotangle); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f\n", "target_axisangle (1,2,3) - after mapping: ", target_phi, target_theta, target_rotangle);
#endif #endif
// The infinitesimal rotation will produce an infinitesimal displacement // The infinitesimal rotation will produce an infinitesimal displacement
...@@ -1024,6 +1052,11 @@ void gpu_calc_gradient( ...@@ -1024,6 +1052,11 @@ void gpu_calc_gradient(
//float shoemake_scaling = native_divide(torque_length, INFINITESIMAL_RADIAN/*infinitesimal_radian*/); //float shoemake_scaling = native_divide(torque_length, INFINITESIMAL_RADIAN/*infinitesimal_radian*/);
float orientation_scaling = torque_length * INV_INFINITESIMAL_RADIAN; float orientation_scaling = torque_length * INV_INFINITESIMAL_RADIAN;
#if defined (DEBUG_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "orientation_scaling: ", orientation_scaling);
#endif
// Derivates in cube3 // Derivates in cube3
float grad_phi, grad_theta, grad_rotangle; float grad_phi, grad_theta, grad_rotangle;
/* /*
...@@ -1036,7 +1069,8 @@ void gpu_calc_gradient( ...@@ -1036,7 +1069,8 @@ void gpu_calc_gradient(
grad_rotangle = orientation_scaling * (remainder(target_rotangle - current_rotangle + PI_FLOAT, PI_TIMES_2) - PI_FLOAT); grad_rotangle = orientation_scaling * (remainder(target_rotangle - current_rotangle + PI_FLOAT, PI_TIMES_2) - PI_FLOAT);
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.8f %-10.8f %-10.8f\n", "grad_axisangle (1,2,3) - before emp. scaling: ", grad_phi, grad_theta, grad_rotangle); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f\n", "grad_axisangle (1,2,3) - before emp. scaling: ", grad_phi, grad_theta, grad_rotangle);
#endif #endif
// Corrections of derivatives // Corrections of derivatives
...@@ -1103,6 +1137,11 @@ void gpu_calc_gradient( ...@@ -1103,6 +1137,11 @@ void gpu_calc_gradient(
} }
dependence_on_theta = (Y0_theta * (X1_theta-X_theta) + Y1_theta * (X_theta-X0_theta)) * inv_angle_delta; dependence_on_theta = (Y0_theta * (X1_theta-X_theta) + Y1_theta * (X_theta-X0_theta)) * inv_angle_delta;
#if defined (DEBUG_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "dependence_on_theta: ", dependence_on_theta);
#endif
// Interpolating rotangle values // Interpolating rotangle values
float X0_rotangle, Y0_rotangle; float X0_rotangle, Y0_rotangle;
float X1_rotangle, Y1_rotangle; float X1_rotangle, Y1_rotangle;
...@@ -1128,7 +1167,13 @@ void gpu_calc_gradient( ...@@ -1128,7 +1167,13 @@ void gpu_calc_gradient(
dependence_on_rotangle = (Y0_rotangle * (X1_rotangle-X_rotangle) + Y1_rotangle * (X_rotangle-X0_rotangle)) * inv_angle_delta; dependence_on_rotangle = (Y0_rotangle * (X1_rotangle-X_rotangle) + Y1_rotangle * (X_rotangle-X0_rotangle)) * inv_angle_delta;
#if defined (DEBUG_GRAD_ROTATION_GENES) #if defined (DEBUG_GRAD_ROTATION_GENES)
printf("%-30s %-10.8f %-10.8f %-10.8f\n", "grad_axisangle (1,2,3) - after emp. scaling: ", grad_phi, grad_theta, grad_rotangle); printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "dependence_on_rotangle: ", dependence_on_rotangle);
#endif
#if defined (DEBUG_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f\n", "grad_axisangle (1,2,3) - after emp. scaling: ", grad_phi, grad_theta, grad_rotangle);
#endif #endif
// Setting gradient rotation-related genotypes in cube // Setting gradient rotation-related genotypes in cube
...@@ -1170,9 +1215,9 @@ void gpu_calc_gradient( ...@@ -1170,9 +1215,9 @@ void gpu_calc_gradient(
#if defined (DEBUG_GRAD_TORSION_GENES) #if defined (DEBUG_GRAD_TORSION_GENES)
printf("%-15s %-10u\n", "rotbond_id: ", rotbond_id); printf("%-15s %-10u\n", "rotbond_id: ", rotbond_id);
printf("%-15s %-10i\n", "atom1_id: ", atom1_id); printf("%-15s %-10i\n", "atom1_id: ", atom1_id);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom1_coords: ", calc_coords_x[atom1_id], calc_coords_y[atom1_id], calc_coords_z[atom1_id]); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "atom1_coords: ", calc_coords_x[atom1_id], calc_coords_y[atom1_id], calc_coords_z[atom1_id]);
printf("%-15s %-10i\n", "atom2_id: ", atom2_id); printf("%-15s %-10i\n", "atom2_id: ", atom2_id);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom2_coords: ", calc_coords_x[atom2_id], calc_coords_y[atom2_id], calc_coords_z[atom2_id]); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "atom2_coords: ", calc_coords_x[atom2_id], calc_coords_y[atom2_id], calc_coords_z[atom2_id]);
printf("\n"); printf("\n");
#endif #endif
...@@ -1227,11 +1272,11 @@ void gpu_calc_gradient( ...@@ -1227,11 +1272,11 @@ void gpu_calc_gradient(
printf("\n"); printf("\n");
printf("%-15s %-10u\n", "rotable_atom_cnt: ", rotable_atom_cnt); printf("%-15s %-10u\n", "rotable_atom_cnt: ", rotable_atom_cnt);
printf("%-15s %-10u\n", "atom_id: ", lig_atom_id); printf("%-15s %-10u\n", "atom_id: ", lig_atom_id);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom_coords: ", atom_coords.x, atom_coords.y, atom_coords.z); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "atom_coords: ", atom_coords.x, atom_coords.y, atom_coords.z);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "r: ", r.x, r.y, r.z); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "r: ", r.x, r.y, r.z);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "unitvec: ", rotation_unitvec.x, rotation_unitvec.y, rotation_unitvec.z); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "unitvec: ", rotation_unitvec.x, rotation_unitvec.y, rotation_unitvec.z);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom_force: ", atom_force.x, atom_force.y, atom_force.z); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "atom_force: ", atom_force.x, atom_force.y, atom_force.z);
printf("%-15s %-10.8f %-10.8f %-10.8f\n", "torque_tor: ", torque_tor.x, torque_tor.y, torque_tor.z); printf("%-15s %-10.6f %-10.6f %-10.6f\n", "torque_tor: ", torque_tor.x, torque_tor.y, torque_tor.z);
#endif #endif
} }
......
...@@ -20,6 +20,9 @@ along with this program; if not, write to the Free Software ...@@ -20,6 +20,9 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//#define DEBUG_ENERGY_KERNEL1
__kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1))) __kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1)))
gpu_calc_initpop( gpu_calc_initpop(
char dockpars_num_of_atoms, char dockpars_num_of_atoms,
...@@ -155,7 +158,7 @@ gpu_calc_initpop( ...@@ -155,7 +158,7 @@ gpu_calc_initpop(
dockpars_energies_current[get_group_id(0)] = energy; dockpars_energies_current[get_group_id(0)] = energy;
dockpars_evals_of_new_entities[get_group_id(0)] = 1; dockpars_evals_of_new_entities[get_group_id(0)] = 1;
#if defined (DEBUG_ENERGY_KERNEL) #if defined (DEBUG_ENERGY_KERNEL1)
printf("%-18s [%-5s]---{%-5s} [%-10.8f]---{%-10.8f}\n", "-ENERGY-KERNEL1-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]); printf("%-18s [%-5s]---{%-5s} [%-10.8f]---{%-10.8f}\n", "-ENERGY-KERNEL1-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]);
#endif #endif
} }
......
...@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//#define DEBUG_ENERGY_KERNEL4
__kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1))) __kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1)))
gpu_gen_and_eval_newpops( gpu_gen_and_eval_newpops(
...@@ -309,7 +310,7 @@ gpu_gen_and_eval_newpops( ...@@ -309,7 +310,7 @@ gpu_gen_and_eval_newpops(
dockpars_evals_of_new_entities[get_group_id(0)] = 1; dockpars_evals_of_new_entities[get_group_id(0)] = 1;
dockpars_energies_next[get_group_id(0)] = energy; dockpars_energies_next[get_group_id(0)] = energy;
#if defined (DEBUG_ENERGY_KERNEL) #if defined (DEBUG_ENERGY_KERNEL4)
printf("%-18s [%-5s]---{%-5s} [%-10.8f]---{%-10.8f}\n", "-ENERGY-KERNEL4-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]); printf("%-18s [%-5s]---{%-5s} [%-10.8f]---{%-10.8f}\n", "-ENERGY-KERNEL4-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]);
#endif #endif
} }
......
// Gradient-based steepest descent minimizer // Gradient-based steepest descent minimizer
// Alternative to Solis-Wetts // Alternative to Solis-Wetts
#define DEBUG_ENERGY_KERNEL5
__kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1))) __kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1)))
gradient_minimizer( gradient_minimizer(
char dockpars_num_of_atoms, char dockpars_num_of_atoms,
...@@ -99,9 +101,9 @@ gradient_minimizer( ...@@ -99,9 +101,9 @@ gradient_minimizer(
energy = dockpars_energies_next[run_id*dockpars_pop_size+entity_id]; energy = dockpars_energies_next[run_id*dockpars_pop_size+entity_id];
#if defined (DEBUG_MINIMIZER) // #if defined (DEBUG_MINIMIZER)
printf("\nrun_id: %5u entity_id: %5u initial_energy: %.7f\n", run_id, entity_id, energy); printf("\nrun_id: %5u entity_id: %5u initial_energy: %.7f\n", run_id, entity_id, energy);
#endif // #endif
// Initializing gradient-minimizer counters and flags // Initializing gradient-minimizer counters and flags
iteration_cnt = 0; iteration_cnt = 0;
...@@ -181,6 +183,7 @@ gradient_minimizer( ...@@ -181,6 +183,7 @@ gradient_minimizer(
float ligand_center_z = -2.40896296; float ligand_center_z = -2.40896296;
#endif #endif
#if 0
// Defining lower and upper bounds for genotypes // Defining lower and upper bounds for genotypes
__local float lower_bounds_genotype[ACTUAL_GENOTYPE_LENGTH]; __local float lower_bounds_genotype[ACTUAL_GENOTYPE_LENGTH];
__local float upper_bounds_genotype[ACTUAL_GENOTYPE_LENGTH]; __local float upper_bounds_genotype[ACTUAL_GENOTYPE_LENGTH];
...@@ -206,6 +209,9 @@ gradient_minimizer( ...@@ -206,6 +209,9 @@ gradient_minimizer(
#endif #endif
} }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#endif
// Calculating maximum possible stepsize (alpha) // Calculating maximum possible stepsize (alpha)
__local float max_trans_gene, max_rota_gene, max_tors_gene; __local float max_trans_gene, max_rota_gene, max_tors_gene;
...@@ -217,6 +223,7 @@ gradient_minimizer( ...@@ -217,6 +223,7 @@ gradient_minimizer(
// The termination criteria is based on // The termination criteria is based on
// a maximum number of iterations, and // a maximum number of iterations, and
// the minimum step size allowed for single-floating point numbers // the minimum step size allowed for single-floating point numbers
...@@ -264,6 +271,28 @@ gradient_minimizer( ...@@ -264,6 +271,28 @@ gradient_minimizer(
genotype[20] = 0.0f; genotype[20] = 0.0f;
#endif #endif
genotype[0] = 28.464;
genotype[1] = 25.792762;
genotype[2] = 23.740571;
genotype[3] = 50.0;
genotype[4] = 50.0;
genotype[5] = 50.0;
genotype[6] = 0.0f;
genotype[7] = 0.0f;
genotype[8] = 0.0f;
genotype[9] = 0.0f;
genotype[10] = 0.0f;
genotype[11] = 0.0f;
genotype[12] = 0.0f;
genotype[13] = 0.0f;
genotype[14] = 0.0f;
genotype[15] = 0.0f;
genotype[16] = 0.0f;
genotype[17] = 0.0f;
genotype[18] = 0.0f;
genotype[19] = 0.0f;
genotype[20] = 0.0f;
if (get_local_id(0) == 0) { if (get_local_id(0) == 0) {
// Finding maximum of the absolute value // Finding maximum of the absolute value
// for the three translation genes // for the three translation genes
...@@ -401,16 +430,27 @@ gradient_minimizer( ...@@ -401,16 +430,27 @@ gradient_minimizer(
); );
// ============================================================= // =============================================================
/* ///*
if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) { if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) {
#if 0
for(uint i = 0; i < dockpars_num_of_genes; i++) { for(uint i = 0; i < dockpars_num_of_genes; i++) {
printf("gradient[%u]=%f \n", i, gradient[i]); printf("gradient[%u]=%f \n", i, gradient[i]);
} }
printf("\n");
#endif
for(uint i = 0; i < dockpars_num_of_atoms; i++) {
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%-10s %-10s %-10s %-10s\n", "atom_id", "coords.x", "coords.y", "coords.z");
}
printf("%-10u %-10.6f %-10.6f %-10.6f\n", i, calc_coords_x[i], calc_coords_y[i], calc_coords_z[i]);
}
printf("\n");
} }
*/ //*/
for(uint i = get_local_id(0); i < dockpars_num_of_genes; i+= NUM_OF_THREADS_PER_BLOCK) { for(uint i = get_local_id(0); i < dockpars_num_of_genes; i+= NUM_OF_THREADS_PER_BLOCK) {
// Taking step // Taking step
candidate_genotype[i] = genotype[i] - stepsize * gradient[i]; candidate_genotype[i] = genotype[i] - stepsize * gradient[i];
...@@ -418,9 +458,12 @@ gradient_minimizer( ...@@ -418,9 +458,12 @@ gradient_minimizer(
//printf("(%-3u) %-0.7f %-10.7f %-10.7f %-10.7f\n", i, stepsize, genotype[i], gradient[i], candidate_genotype[i]); //printf("(%-3u) %-0.7f %-10.7f %-10.7f %-10.7f\n", i, stepsize, genotype[i], gradient[i], candidate_genotype[i]);
#endif #endif
#if 0
// Putting genes back within bounds // Putting genes back within bounds
candidate_genotype[i] = fmin(candidate_genotype[i], upper_bounds_genotype[i]); candidate_genotype[i] = fmin(candidate_genotype[i], upper_bounds_genotype[i]);
candidate_genotype[i] = fmax(candidate_genotype[i], lower_bounds_genotype[i]); candidate_genotype[i] = fmax(candidate_genotype[i], lower_bounds_genotype[i]);
#endif
} }
// Evaluating candidate // Evaluating candidate
...@@ -442,7 +485,7 @@ gradient_minimizer( ...@@ -442,7 +485,7 @@ gradient_minimizer(
dockpars_coeff_elec, dockpars_coeff_elec,
dockpars_qasp, dockpars_qasp,
dockpars_coeff_desolv, dockpars_coeff_desolv,
candidate_genotype, /*genotype,*/ /*use genotype only for reproduce results*/ /*candidate_genotype,*/ genotype, /*use genotype only for reproduce results*/
&candidate_energy, &candidate_energy,
&run_id, &run_id,
// Some OpenCL compilers don't allow declaring // Some OpenCL compilers don't allow declaring
...@@ -483,13 +526,34 @@ gradient_minimizer( ...@@ -483,13 +526,34 @@ gradient_minimizer(
); );
// ============================================================= // =============================================================
#if defined (DEBUG_ENERGY_KERNEL) #if defined (DEBUG_ENERGY_KERNEL5)
if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) { if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) {
printf("\n");
printf("%-10s %-10.6f \n", "intra: ", partial_intraE[0]);
printf("%-10s %-10.6f \n", "grids: ", partial_interE[0]);
printf("%-10s %-10.6f \n", "Energy: ", (partial_intraE[0] + partial_interE[0]));
for(uint i = 0; i < dockpars_num_of_genes; i++) { for(uint i = 0; i < dockpars_num_of_genes; i++) {
printf("genotype[%u]=%f \n", i, genotype[i]); if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%-10s %-10s %-10s\n", "gene_id", "gene.value", "gene.gradient");
}
printf("%-10u %-10.6f %-10.6f\n", i, genotype[i], gradient[i]);
}
#if 0
for(uint i = 0; i < dockpars_num_of_atoms; i++) {
printf("atom [%u]: x=%f y=%f z=%f\n", i, calc_coords_x[i], calc_coords_y[i], calc_coords_z[i]);
}
#endif
for(uint i = 0; i < dockpars_num_of_atoms; i++) {
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%-10s %-10s %-10s %-10s\n", "atom_id", "coords.x", "coords.y", "coords.z");
}
printf("%-10u %-10.6f %-10.6f %-10.6f\n", i, calc_coords_x[i], calc_coords_y[i], calc_coords_z[i]);
} }
printf("partial_interE=%f \n", partial_interE[0]); printf("\n");
printf("partial_intraE=%f \n", partial_intraE[0]);
} }
#endif #endif
...@@ -529,12 +593,13 @@ gradient_minimizer( ...@@ -529,12 +593,13 @@ gradient_minimizer(
iteration_cnt = iteration_cnt + 1; iteration_cnt = iteration_cnt + 1;
#if defined (DEBUG_MINIMIZER) #if defined (DEBUG_MINIMIZER)
printf("# minimizer-iters: %-3u, stepsize: %10.7f, E: %10.7f\n", iteration_cnt, stepsize, energy); printf("# minimizer-iters: %-3u, stepsize: %10.6f, E: %10.6f\n", iteration_cnt, stepsize, energy);
#endif #endif
/*
#if defined (DEBUG_ENERGY_KERNEL) #if defined (DEBUG_ENERGY_KERNEL5)
printf("%-18s [%-5s]---{%-5s} [%-10.7f]---{%-10.7f}\n", "-ENERGY-KERNEL5-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]); printf("%-18s [%-5s]---{%-5s} [%-10.7f]---{%-10.7f}\n", "-ENERGY-KERNEL5-", "GRIDS", "INTRA", partial_interE[0], partial_intraE[0]);
#endif #endif
*/
} }
} while ((iteration_cnt < dockpars_max_num_of_iters) && (stepsize > 1E-8)); } while ((iteration_cnt < dockpars_max_num_of_iters) && (stepsize > 1E-8));
...@@ -547,7 +612,7 @@ gradient_minimizer( ...@@ -547,7 +612,7 @@ gradient_minimizer(
dockpars_energies_next[run_id*dockpars_pop_size+entity_id] = energy; dockpars_energies_next[run_id*dockpars_pop_size+entity_id] = energy;
#if defined (DEBUG_MINIMIZER) #if defined (DEBUG_MINIMIZER)
printf("-------> End of grad-min cycle, num of evals: %u, final energy: %.7f\n", iteration_cnt, energy); printf("-------> End of grad-min cycle, num of evals: %u, final energy: %.6f\n", iteration_cnt, energy);
#endif #endif
} }
......
...@@ -733,9 +733,15 @@ void gen_initpop_and_reflig(Dockpars* mypars, ...@@ -733,9 +733,15 @@ void gen_initpop_and_reflig(Dockpars* mypars,
ref_ori_angles[3*i+1] = 90.279; ref_ori_angles[3*i+1] = 90.279;
ref_ori_angles[3*i+2] = 190.279; ref_ori_angles[3*i+2] = 190.279;
#else #else
ref_ori_angles[3*i] = (float) (myrand()*360.0); //phi // These specific values for the rotation genes (in axis-angle space)
ref_ori_angles[3*i<