Commit c9b5d2e2 authored by lvs's avatar lvs
Browse files

improved printfs + added case 2brt (4 tors)

parent d7a0eb02
......@@ -34,10 +34,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// whose population includes the current entity (which can be determined with get_group_id(0)),
// since this determines which reference orientation should be used.
//#define DEBUG_GRAD_TRANSLATION_GENES
//#define DEBUG_GRAD_ROTATION_GENES
#define DEBUG_GRAD_TORSION_GENES
//#define PRINT_GRAD_TRANSLATION_GENES
//#define PRINT_GRAD_ROTATION_GENES
//#define PRINT_GRAD_TORSION_GENES
#define ENABLE_PARALLEL_GRAD_TORSION
void map_priv_angle(float* angle)
// The GPU device function maps
......@@ -797,7 +798,7 @@ void gpu_calc_gradient(
gradient_inter_y[atom_cnt] = native_divide(gradient_inter_y[atom_cnt], dockpars_grid_spacing);
gradient_inter_z[atom_cnt] = native_divide(gradient_inter_z[atom_cnt], dockpars_grid_spacing);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
if (atom_cnt == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%s\n", "Gradients: inter and intra");
......@@ -815,7 +816,7 @@ void gpu_calc_gradient(
//printf("%-15s %-5u %-10.8f %-10.8f %-10.8f\n", "grad_intra", atom_cnt, gradient_intra_x[atom_cnt], gradient_intra_y[atom_cnt], gradient_intra_z[atom_cnt]);
//printf("%-15s %-5u %-10.8f %-10.8f %-10.8f\n", "calc_coords", atom_cnt, calc_coords_x[atom_cnt], calc_coords_y[atom_cnt], calc_coords_z[atom_cnt]);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
if (atom_cnt == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%s\n", "Gradients: total = inter + intra");
......@@ -851,7 +852,8 @@ void gpu_calc_gradient(
gradient_genotype[1] *= dockpars_grid_spacing;
gradient_genotype[2] *= dockpars_grid_spacing;
#if defined (DEBUG_GRAD_TRANSLATION_GENES)
#if defined (PRINT_GRAD_TRANSLATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("gradient_x:%f\n", gradient_genotype [0]);
printf("gradient_y:%f\n", gradient_genotype [1]);
printf("gradient_z:%f\n", gradient_genotype [2]);
......@@ -877,7 +879,7 @@ void gpu_calc_gradient(
torque_rot.y = 0.0f;
torque_rot.z = 0.0f;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
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
......@@ -909,7 +911,7 @@ void gpu_calc_gradient(
torque_rot += cross(r, force);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
#if 0
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);
......@@ -933,7 +935,7 @@ void gpu_calc_gradient(
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
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
......@@ -942,7 +944,7 @@ void gpu_calc_gradient(
// genes[3:7] = rotation.axisangle_to_q(torque, rad)
float torque_length = fast_length(torque_rot);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-20s %-10.6f\n", "torque length: ", torque_length);
#endif
......@@ -967,7 +969,7 @@ void gpu_calc_gradient(
quat_torque.y = fast_normalize(torque_rot).y * SIN_HALF_INFINITESIMAL_RADIAN;
quat_torque.z = fast_normalize(torque_rot).z * SIN_HALF_INFINITESIMAL_RADIAN;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
#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);
......@@ -1001,7 +1003,7 @@ void gpu_calc_gradient(
bool is_theta_gt_pi = (current_theta > PI_FLOAT) ? true: false;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
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
......@@ -1022,7 +1024,7 @@ void gpu_calc_gradient(
current_q.y = rotaxis_y * native_sin(ang);
current_q.z = rotaxis_z * native_sin(ang);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
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
......@@ -1037,7 +1039,7 @@ void gpu_calc_gradient(
target_q.x = quat_torque.w*current_q.x + quat_torque.x*current_q.w + quat_torque.y*current_q.z - quat_torque.z*current_q.y;// x
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
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
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
......@@ -1067,7 +1069,7 @@ void gpu_calc_gradient(
target_theta = PI_TIMES_2 - target_theta;
}
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f %-10.6f %-10.6f\n", "target_axisangle (1,2,3): ", target_phi, target_theta, target_rotangle);
#endif
......@@ -1080,7 +1082,7 @@ void gpu_calc_gradient(
//float shoemake_scaling = native_divide(torque_length, INFINITESIMAL_RADIAN/*infinitesimal_radian*/);
float orientation_scaling = torque_length * INV_INFINITESIMAL_RADIAN;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "orientation_scaling: ", orientation_scaling);
#endif
......@@ -1096,7 +1098,7 @@ void gpu_calc_gradient(
grad_theta = orientation_scaling * (fmod(target_theta - current_theta + PI_FLOAT, PI_TIMES_2) - PI_FLOAT);
grad_rotangle = orientation_scaling * (fmod(target_rotangle - current_rotangle + PI_FLOAT, PI_TIMES_2) - PI_FLOAT);
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s \n", "grad_axisangle (1,2,3) - before empirical scaling: ");
printf("%-13s %-13s %-13s \n", "grad_phi", "grad_theta", "grad_rotangle");
......@@ -1167,7 +1169,7 @@ void gpu_calc_gradient(
}
dependence_on_theta = (Y0_theta * (X1_theta-X_theta) + Y1_theta * (X_theta-X0_theta)) * inv_angle_delta;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "dependence_on_theta: ", dependence_on_theta);
#endif
......@@ -1196,7 +1198,7 @@ void gpu_calc_gradient(
}
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 (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s %-10.6f\n", "dependence_on_rotangle: ", dependence_on_rotangle);
#endif
......@@ -1206,7 +1208,7 @@ void gpu_calc_gradient(
gradient_genotype[3] = native_divide(grad_phi, (dependence_on_theta * dependence_on_rotangle)) * DEG_TO_RAD;
gradient_genotype[4] = native_divide(grad_theta, dependence_on_rotangle) * DEG_TO_RAD;
gradient_genotype[5] = grad_rotangle * DEG_TO_RAD;
#if defined (DEBUG_GRAD_ROTATION_GENES)
#if defined (PRINT_GRAD_ROTATION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-30s \n", "grad_axisangle (1,2,3) - after empirical scaling: ");
printf("%-13s %-13s %-13s \n", "grad_phi", "grad_theta", "grad_rotangle");
......@@ -1218,24 +1220,23 @@ void gpu_calc_gradient(
// Obtaining torsion-related gradients
// ------------------------------------------
//----------------------------------
// fastergrad
//----------------------------------
///*
#if defined (ENABLE_PARALLEL_GRAD_TORSION)
for (uint rotbond_id = get_local_id(0);
rotbond_id < dockpars_num_of_genes-6;
rotbond_id +=NUM_OF_THREADS_PER_BLOCK) {
#if defined (PRINT_GRAD_TORSION_GENES)
if (rotbond_id == 0) {
printf("\n%s\n", "NOTE: torsion gradients are calculated by many work-items");
}
#endif
#else
if (get_local_id(0) == 2) {
for (uint rotbond_id = 0;
rotbond_id < dockpars_num_of_genes-6;
rotbond_id ++) {
//*/
/*
for (uint rotbond_id = get_local_id(0);
rotbond_id < dockpars_num_of_genes-6;
rotbond_id +=NUM_OF_THREADS_PER_BLOCK) {
*/
//----------------------------------
#endif
// Querying ids of atoms belonging to the rotatable bond in question
int atom1_id = rotbonds_const[2*rotbond_id];
......@@ -1246,7 +1247,7 @@ void gpu_calc_gradient(
atomRef_coords.y = calc_coords_y[atom1_id];
atomRef_coords.z = calc_coords_z[atom1_id];
#if defined (DEBUG_GRAD_TORSION_GENES)
#if defined (PRINT_GRAD_TORSION_GENES)
printf("\n%s\n", "----------------------------------------------------------");
printf("%-5s %3u \n\t %-5s %3i \n\t %-5s %3i\n", "gene: ", (rotbond_id+6), "atom1: ", atom1_id, "atom2: ", atom2_id);
#endif
......@@ -1262,7 +1263,7 @@ void gpu_calc_gradient(
rotation_unitvec.z = calc_coords_z[atom2_id] - calc_coords_z[atom1_id];
rotation_unitvec = fast_normalize(rotation_unitvec);
#if defined (DEBUG_GRAD_TORSION_GENES)
#if defined (PRINT_GRAD_TORSION_GENES)
printf("\n");
printf("%-15s \n\t %-10.6f %-10.6f %-10.6f\n", "unitvec: ", rotation_unitvec.x, rotation_unitvec.y, rotation_unitvec.z);
#endif
......@@ -1303,7 +1304,7 @@ void gpu_calc_gradient(
torque_tor += cross(r, atom_force);
#if defined (DEBUG_GRAD_TORSION_GENES)
#if defined (PRINT_GRAD_TORSION_GENES)
if (rotable_atom_cnt == 0) {
printf("\n %-30s %3i\n", "contributor for gene : ", (rotbond_id+6));
}
......@@ -1317,7 +1318,7 @@ void gpu_calc_gradient(
#endif
}
#if defined (DEBUG_GRAD_TORSION_GENES)
#if defined (PRINT_GRAD_TORSION_GENES)
printf("\n");
#endif
......@@ -1327,18 +1328,17 @@ void gpu_calc_gradient(
// Assignment of gene-based gradient
gradient_genotype[rotbond_id+6] = torque_on_axis * DEG_TO_RAD /*(M_PI / 180.0f)*/;
#if defined (DEBUG_GRAD_TORSION_GENES)
#if defined (PRINT_GRAD_TORSION_GENES)
printf("gradient_torsion [%u] :%f\n", rotbond_id+6, gradient_genotype [rotbond_id+6]);
#endif
} // End of iterations over rotatable bonds
//----------------------------------
// fastergrad
//----------------------------------
///*
#if defined (ENABLE_PARALLEL_GRAD_TORSION)
#else
}
//*/
#endif
//----------------------------------
barrier(CLK_LOCAL_MEM_FENCE);
......
......@@ -2,6 +2,9 @@
// Alternative to Solis-Wetts
#define DEBUG_ENERGY_KERNEL5
#define PRINT_ENERGIES
#define PRINT_GENES_AND_GRADS
//#define PRINT_ATOMIC_COORDS
__kernel void __attribute__ ((reqd_work_group_size(NUM_OF_THREADS_PER_BLOCK,1,1)))
gradient_minimizer(
......@@ -271,6 +274,8 @@ gradient_minimizer(
genotype[20] = 0.0f;
#endif
#if 0
// 2j5s
genotype[0] = 28.464;
genotype[1] = 25.792762;
genotype[2] = 23.740571;
......@@ -292,6 +297,32 @@ gradient_minimizer(
genotype[18] = 0.0f;
genotype[19] = 0.0f;
genotype[20] = 0.0f;
#endif
#if 1
// 2brt
genotype[0] = 24.093334;
genotype[1] = 24.658667;
genotype[2] = 24.210667;
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;
#endif
if (get_local_id(0) == 0) {
// Finding maximum of the absolute value
......@@ -430,15 +461,22 @@ gradient_minimizer(
);
// =============================================================
///*
// This could be enabled back for double checking
#if 0
#if defined (DEBUG_ENERGY_KERNEL5)
if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) {
#if 0
#if defined (PRINT_GENES_AND_GRADS)
for(uint i = 0; i < dockpars_num_of_genes; i++) {
printf("gradient[%u]=%f \n", i, gradient[i]);
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%13s %13s %5s %15s %15s\n", "gene_id", "gene.value", "|", "gene.grad", "(autodockdevpy units)");
}
printf("%13u %13.6f %5s %15.6f %15.6f\n", i, genotype[i], "|", gradient[i], (i<3)? (gradient[i]/0.375f):(gradient[i]*180.0f/PI_FLOAT));
}
printf("\n");
#endif
#endif
#if defined (PRINT_ATOMIC_COORDS)
for(uint i = 0; i < dockpars_num_of_atoms; i++) {
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
......@@ -448,8 +486,10 @@ gradient_minimizer(
printf("%12u %12.6f %12.6f %12.6f\n", i, calc_coords_x[i], calc_coords_y[i], calc_coords_z[i]);
}
printf("\n");
#endif
}
//*/
#endif
#endif
for(uint i = get_local_id(0); i < dockpars_num_of_genes; i+= NUM_OF_THREADS_PER_BLOCK) {
// Taking step
......@@ -486,7 +526,7 @@ gradient_minimizer(
dockpars_coeff_elec,
dockpars_qasp,
dockpars_coeff_desolv,
/*candidate_genotype,*/ genotype, /*use genotype only for reproduce results*/
/*candidate_genotype,*/ genotype, /*WARNING: use genotype ONLY to reproduce results*/
&candidate_energy,
&run_id,
// Some OpenCL compilers don't allow declaring
......@@ -529,24 +569,24 @@ gradient_minimizer(
#if defined (DEBUG_ENERGY_KERNEL5)
if ((get_group_id(0) == 0) && (get_local_id(0) == 0)) {
#if defined (PRINT_ENERGIES)
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]));
#endif
#if defined (PRINT_GENES_AND_GRADS)
for(uint i = 0; i < dockpars_num_of_genes; i++) {
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
printf("%13s %13s %13s\n", "gene_id", "gene.value", "gene.grad");
printf("%13s %13s %5s %15s %15s\n", "gene_id", "gene.value", "|", "gene.grad", "(autodockdevpy units)");
}
printf("%13u %13.6f %13.6f\n", i, genotype[i], gradient[i]);
printf("%13u %13.6f %5s %15.6f %15.6f\n", i, genotype[i], "|", gradient[i], (i<3)? (gradient[i]/0.375f):(gradient[i]*180.0f/PI_FLOAT));
}
#endif
#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
#if defined (PRINT_ATOMIC_COORDS)
for(uint i = 0; i < dockpars_num_of_atoms; i++) {
if (i == 0) {
printf("\n%s\n", "----------------------------------------------------------");
......@@ -556,6 +596,7 @@ gradient_minimizer(
printf("%12u %12.6f %12.6f %12.6f\n", i, calc_coords_x[i], calc_coords_y[i], calc_coords_z[i]);
}
printf("\n");
#endif
}
#endif
......
Markdown is supported
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