Commit b2436392 authored by Leonardo Solis's avatar Leonardo Solis

issue #35: merged E+G + updated fire & adadelta kernels

parent 2ae385a1
......@@ -23,7 +23,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//#define DEBUG_ENERGY_KERNEL
// No needed to be included as all kernel sources are stringified
#if 0
#include "calcenergy_basic.h"
#endif
typedef struct
{
......@@ -689,6 +692,8 @@ if (get_local_id (0) == 0) {
}
// No needed to be included as all kernel sources are stringified
#if 0
#include "kernel1.cl"
#include "kernel2.cl"
#include "auxiliary_genetic.cl"
......@@ -698,3 +703,6 @@ if (get_local_id (0) == 0) {
#include "kernel_sd.cl"
#include "kernel_fire.cl"
#include "kernel_ad.cl"
#include "calcEnerGrad.cl"
#endif
......@@ -312,6 +312,12 @@ gradient_minAD(
}
#endif
// Replacing separate gradient and energy
// calculations with a single & unified
// gpu_calc_energrad() function
// IMPORTANT: be careful with input/output (RE) assignment
// of genotypes, energy, and gradients
#if 0
// =============================================================
// Calculating gradient
barrier(CLK_LOCAL_MEM_FENCE);
......@@ -437,20 +443,92 @@ gradient_minAD(
calc_coords_y,
calc_coords_z,
partial_energies,
#if defined (DEBUG_ENERGY_KERNEL)
#if defined (DEBUG_ENERGY_KERNEL)
partial_interE,
partial_intraE,
#endif
#if 0
#endif
#if 0
true,
#endif
kerconst_interintra,
kerconst_intracontrib,
kerconst_intra,
kerconst_rotlist,
kerconst_conform
);
// =============================================================
#endif
// =============================================================
// =============================================================
// =============================================================
// Calculating energy & gradient
barrier(CLK_LOCAL_MEM_FENCE);
gpu_calc_energrad(
dockpars_rotbondlist_length,
dockpars_num_of_atoms,
dockpars_gridsize_x,
dockpars_gridsize_y,
dockpars_gridsize_z,
// g1 = gridsize_x
dockpars_gridsize_x_times_y, // g2 = gridsize_x * gridsize_y
dockpars_gridsize_x_times_y_times_z, // g3 = gridsize_x * gridsize_y * gridsize_z
dockpars_fgrids,
dockpars_num_of_atypes,
dockpars_num_of_intraE_contributors,
dockpars_grid_spacing,
dockpars_coeff_elec,
dockpars_qasp,
dockpars_coeff_desolv,
dockpars_smooth,
// Some OpenCL compilers don't allow declaring
// local variables within non-kernel functions.
// These local variables must be declared in a kernel,
// and then passed to non-kernel functions.
genotype,
&energy,
&run_id,
calc_coords_x,
calc_coords_y,
calc_coords_z,
partial_energies,
#if defined (DEBUG_ENERGY_KERNEL)
partial_interE,
partial_intraE,
#endif
kerconst_interintra,
kerconst_intracontrib,
kerconst_intra,
kerconst_rotlist,
kerconst_conform
,
rotbonds_const,
rotbonds_atoms_const,
num_rotating_atoms_per_rotbond_const
,
angle_const,
dependence_on_theta_const,
dependence_on_rotangle_const
// Gradient-related arguments
// Calculate gradients (forces) for intermolecular energy
// Derived from autodockdev/maps.py
,
dockpars_num_of_genes,
gradient_inter_x,
gradient_inter_y,
gradient_inter_z,
gradient_intra_x,
gradient_intra_y,
gradient_intra_z,
gradient
);
// =============================================================
// =============================================================
// =============================================================
#if defined (DEBUG_ENERGY_ADADELTA)
if (/*(get_group_id(0) == 0) &&*/ (get_local_id(0) == 0)) {
......
......@@ -440,11 +440,17 @@ gradient_minFire(
candidate_genotype [gene_counter] = genotype [gene_counter] + dt * velocity [gene_counter];
}
// Replacing separate gradient and energy
// calculations with a single & unified
// gpu_calc_energrad() function
// IMPORTANT: be careful with input/output (RE) assignment
// of genotypes, energy, and gradients
#if 0
// =============================================================
// Calculating (candidate) gradient
// from "candidate_genotype"
barrier(CLK_LOCAL_MEM_FENCE);
// =============================================================
gpu_calc_gradient(
dockpars_rotbondlist_length,
dockpars_num_of_atoms,
......@@ -536,20 +542,92 @@ gradient_minFire(
calc_coords_y,
calc_coords_z,
partial_energies,
#if defined (DEBUG_ENERGY_KERNEL)
#if defined (DEBUG_ENERGY_KERNEL)
partial_interE,
partial_intraE,
#endif
#if 0
#endif
#if 0
true,
#endif
kerconst_interintra,
kerconst_intracontrib,
kerconst_intra,
kerconst_rotlist,
kerconst_conform
);
// =============================================================
#endif
// =============================================================
// =============================================================
// =============================================================
// Calculating energy & gradient
barrier(CLK_LOCAL_MEM_FENCE);
gpu_calc_energrad(
dockpars_rotbondlist_length,
dockpars_num_of_atoms,
dockpars_gridsize_x,
dockpars_gridsize_y,
dockpars_gridsize_z,
// g1 = gridsize_x
dockpars_gridsize_x_times_y, // g2 = gridsize_x * gridsize_y
dockpars_gridsize_x_times_y_times_z, // g3 = gridsize_x * gridsize_y * gridsize_z
dockpars_fgrids,
dockpars_num_of_atypes,
dockpars_num_of_intraE_contributors,
dockpars_grid_spacing,
dockpars_coeff_elec,
dockpars_qasp,
dockpars_coeff_desolv,
dockpars_smooth,
// Some OpenCL compilers don't allow declaring
// local variables within non-kernel functions.
// These local variables must be declared in a kernel,
// and then passed to non-kernel functions.
candidate_genotype,
&candidate_energy,
&run_id,
calc_coords_x,
calc_coords_y,
calc_coords_z,
partial_energies,
#if defined (DEBUG_ENERGY_KERNEL)
partial_interE,
partial_intraE,
#endif
kerconst_interintra,
kerconst_intracontrib,
kerconst_intra,
kerconst_rotlist,
kerconst_conform
,
rotbonds_const,
rotbonds_atoms_const,
num_rotating_atoms_per_rotbond_const
,
angle_const,
dependence_on_theta_const,
dependence_on_rotangle_const
// Gradient-related arguments
// Calculate gradients (forces) for intermolecular energy
// Derived from autodockdev/maps.py
,
dockpars_num_of_genes,
gradient_inter_x,
gradient_inter_y,
gradient_inter_z,
gradient_intra_x,
gradient_intra_y,
gradient_intra_z,
candidate_gradient
);
// =============================================================
// =============================================================
// =============================================================
// Calculating power
// power is force * velocity.
......
......@@ -6,35 +6,53 @@ IN_HEADER1=$HEADER_DIR/"defines.h"
IN_HEADER2=$HEADER_DIR/"calcenergy_basic.h"
echo " "
echo "Stringified input header-files: "
echo "Stringified input header files: "
echo $IN_HEADER1
echo $IN_HEADER2
# kernel files
# device source-code folder
KERNEL_DIR="./device"
IN_KERNELm=$KERNEL_DIR/"calcenergy.cl"
IN_KERNEL1=$KERNEL_DIR/"kernel1.cl"
IN_KERNEL2=$KERNEL_DIR/"kernel2.cl"
IN_KERNELa=$KERNEL_DIR/"auxiliary_genetic.cl"
IN_KERNEL3=$KERNEL_DIR/"kernel3.cl"
IN_KERNEL4=$KERNEL_DIR/"kernel4.cl"
IN_KERNELb=$KERNEL_DIR/"calcgradient.cl"
IN_KERNEL5=$KERNEL_DIR/"kernel_sd.cl"
IN_KERNEL6=$KERNEL_DIR/"kernel_fire.cl"
IN_KERNEL7=$KERNEL_DIR/"kernel_ad.cl"
# non-kernel function files
## AUXI: auxiliary
## ENER: energy
## GRAD: gradient
## ENEGRA: merged energy & gradient
IN_FUNCTION_AUXI=$KERNEL_DIR/"auxiliary_genetic.cl"
IN_FUNCTION_ENER=$KERNEL_DIR/"calcenergy.cl"
IN_FUNCTION_GRAD=$KERNEL_DIR/"calcgradient.cl"
IN_FUNCTION_MERGED_EG=$KERNEL_DIR/"calcMergedEneGra.cl"
# kernel files
## INIT: energy calculation of initial population
## EVAL: evaluation count
## GS_ORIG_GA: Global Search Original Genetic Algorithm
## LS_ORIG_SW: Local Search Original Solis-Wets
## LS_GRAD_{SD | FI | AD}: Local Search Gradient-based {Steepest-Descent | Fire | Ada-Delta}
IN_KERNEL_INIT=$KERNEL_DIR/"kernel1.cl"
IN_KERNEL_EVAL=$KERNEL_DIR/"kernel2.cl"
IN_KERNEL_GS_ORIG_GA=$KERNEL_DIR/"kernel4.cl"
IN_KERNEL_LS_ORIG_SW=$KERNEL_DIR/"kernel3.cl"
IN_KERNEL_LS_GRAD_SD=$KERNEL_DIR/"kernel_sd.cl"
IN_KERNEL_LS_GRAD_FI=$KERNEL_DIR/"kernel_fire.cl"
IN_KERNEL_LS_GRAD_AD=$KERNEL_DIR/"kernel_ad.cl"
echo " "
echo "Stringified input non-kernel files: "
echo $IN_FUNCTION_AUXI
echo $IN_FUNCTION_ENER
echo $IN_FUNCTION_GRAD
echo $IN_FUNCTION_MERGED_EG
echo " "
echo "Stringified input kernel-files: "
echo $IN_KERNELm
echo $IN_KERNEL1
echo $IN_KERNEL2
echo $IN_KERNELa
echo $IN_KERNEL3
echo $IN_KERNEL4
echo $IN_KERNELb
echo $IN_KERNEL5
echo $IN_KERNEL6
echo $IN_KERNEL7
echo $IN_KERNEL_INIT
echo $IN_KERNEL_EVAL
echo $IN_KERNEL_GS_ORIG_GA
echo $IN_KERNEL_LS_ORIG_SW
echo $IN_KERNEL_LS_GRAD_SD
echo $IN_KERNEL_LS_GRAD_FI
echo $IN_KERNEL_LS_GRAD_AD
# output file
OUT=host/inc/stringify.h
......@@ -47,23 +65,24 @@ echo " "
# temporal file
TMP=$KERNEL_DIR/stringify_tmp
echo "// OCLADOCK: AUTOMATICALLY GENERATED FILE, DO NOT EDIT" >$TMP
echo "// OCLADock: AUTOMATICALLY GENERATED FILE, DO NOT EDIT." >$TMP
echo "#ifndef STRINGIFY_H" >>$TMP
echo "#define STRINGIFY_H" >>$TMP
echo "const char *calcenergy_ocl =" >>$TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELm >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELa >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL3 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL4 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELb >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL5 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL6 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL7 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_FUNCTION_AUXI >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_FUNCTION_ENER >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_FUNCTION_GRAD >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_FUNCTION_MERGED_EG >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_INIT >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_EVAL >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_GS_ORIG_GA >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_LS_ORIG_SW >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_LS_GRAD_SD >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_LS_GRAD_FI >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL_LS_GRAD_AD >> $TMP
echo ";" >>$TMP
echo "#endif // End of STRINGIFY_H" >>$TMP
......
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