Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
docking
ocladock-fpga
Commits
3ee08f63
Commit
3ee08f63
authored
Nov 10, 2018
by
Leonardo Solis
Browse files
#31, clean code based on SINGLE_COPY_POP_ENE=yes
Former-commit-id:
647ff479
parent
e0f6511a
Changes
5
Hide whitespace changes
Inline
Side-by-side
ofdock_taskpar_xl/Makefile
View file @
3ee08f63
...
...
@@ -91,23 +91,10 @@ FIPO_FLAG = $(FIPOCO_FLAG) \
$(FIPOLS9_FLAG)
# Other configs
SINGLE_COPY_POP_ENE
=
YES
SEPARATE_FGRID_INTERE
=
NO
ifeq
($(SINGLE_COPY_POP_ENE), YES)
COPYPOPENE_FLAG
=
-DSINGLE_COPY_POP_ENE
else
COPYPOPENE_FLAG
=
endif
ifeq
($(SEPARATE_FGRID_INTERE), YES)
SEP_FGRID_FLAG
=
-DSEPARATE_FGRID_INTERE
else
SEP_FGRID_FLAG
=
endif
# Overall custom configs
CONFIG_FLAG
=
$(FIPO_FLAG)
$(COPYPOPENE_FLAG)
$(SEP_FGRID_FLAG)
CONFIG_FLAG
=
$(FIPO_FLAG)
CXXFLAGS
:=
-Wall
-O0
-g
-std
=
c++14
$(OTHER_FLAGS)
...
...
ofdock_taskpar_xl/device/Krnl_GA.cl
View file @
3ee08f63
...
...
@@ -224,12 +224,8 @@ __kernel __attribute__ ((reqd_work_group_size(1,1,1)))
void
Krnl_GA
(
__global
float*
restrict
GlobPopulationCurrent,
__global
float*
restrict
GlobEnergyCurrent,
#
if
defined
(
SINGLE_COPY_POP_ENE
)
__global
unsigned
int*
restrict
GlobEvals_performed,
__global
unsigned
int*
restrict
GlobGens_performed,
#
else
__global
unsigned
int*
restrict
GlobEvalsGenerations_performed,
#
endif
unsigned
int
DockConst_pop_size,
unsigned
int
DockConst_num_of_energy_evals,
unsigned
int
DockConst_num_of_generations,
...
...
@@ -241,13 +237,10 @@ void Krnl_GA(
float
Host_two_absmaxdang,
float
DockConst_crossover_rate,
unsigned
int
DockConst_num_of_lsentities,
unsigned
char
DockConst_num_of_genes
#
if
defined
(
SINGLE_COPY_POP_ENE
)
,
unsigned
char
DockConst_num_of_genes,
unsigned
short
Host_RunId,
unsigned
int
Host_Offset_Pop,
unsigned
int
Host_Offset_Ene
#
endif
)
{
#
if
defined
(
DEBUG_KRNL_GA
)
...
...
@@ -271,10 +264,8 @@ void Krnl_GA(
__local
float
LocalPopCurr[MAX_POPSIZE][ACTUAL_GENOTYPE_LENGTH]
;
__local
float
LocalEneCurr[MAX_POPSIZE]
;
#
if
defined
(
SINGLE_COPY_POP_ENE
)
__global
float*
GlobPopCurr
=
&
GlobPopulationCurrent
[Host_Offset_Pop]
;
__global
float*
GlobEneCurr
=
&
GlobEnergyCurrent
[Host_Offset_Ene]
;
#
endif
//
------------------------------------------------------------------
//
Initial
Calculation
(
IC
)
of
scores
...
...
@@ -292,11 +283,7 @@ void Krnl_GA(
LOOP_FOR_GA_IC_INNER_WRITE_GENOTYPE:
for
(
uchar
gene_cnt=0
; gene_cnt<DockConst_num_of_genes; gene_cnt++) {
float
tmp_ic
;
#
if
defined
(
SINGLE_COPY_POP_ENE
)
tmp_ic
=
GlobPopCurr[pop_cnt*ACTUAL_GENOTYPE_LENGTH
+
gene_cnt]
;
#
else
tmp_ic
=
GlobPopulationCurrent[pop_cnt*ACTUAL_GENOTYPE_LENGTH
+
gene_cnt]
;
#
endif
LocalPopCurr[pop_cnt][gene_cnt
&
MASK_GENOTYPE]
=
tmp_ic
;
write_pipe_block
(
chan_IC2Conf_genotype,
&tmp_ic
)
;
...
...
@@ -869,18 +856,10 @@ void Krnl_GA(
__attribute__
((
xcl_pipeline_loop
))
LOOP_GA_WRITEPOP2DDR_INNER:
for
(
uchar
gene_cnt=0
; gene_cnt<DockConst_num_of_genes; gene_cnt++) {
#
if
defined
(
SINGLE_COPY_POP_ENE
)
GlobPopCurr[pop_cnt*ACTUAL_GENOTYPE_LENGTH
+
gene_cnt]
=
LocalPopCurr[pop_cnt][gene_cnt
&
MASK_GENOTYPE]
;
#
else
GlobPopulationCurrent[pop_cnt*ACTUAL_GENOTYPE_LENGTH
+
gene_cnt]
=
LocalPopCurr[pop_cnt][gene_cnt
&
MASK_GENOTYPE]
;
#
endif
}
#
if
defined
(
SINGLE_COPY_POP_ENE
)
GlobEneCurr[pop_cnt]
=
LocalEneCurr[pop_cnt]
;
#
else
GlobEnergyCurrent[pop_cnt]
=
LocalEneCurr[pop_cnt]
;
#
endif
}
#
if
defined
(
DEBUG_KRNL_GA
)
...
...
@@ -892,13 +871,8 @@ void Krnl_GA(
#
endif
//
Write
final
evals
&
generation
counts
to
FPGA-board
DDRs
#
if
defined
(
SINGLE_COPY_POP_ENE
)
GlobEvals_performed[Host_RunId]
=
eval_cnt
;
GlobGens_performed
[Host_RunId]
=
generation_cnt
;
#
else
GlobEvalsGenerations_performed[0]
=
eval_cnt
;
GlobEvalsGenerations_performed[1]
=
generation_cnt
;
#
endif
}
//
--------------------------------------------------------------------------
...
...
ofdock_taskpar_xl/host/inc/calcenergy.h
View file @
3ee08f63
...
...
@@ -124,11 +124,7 @@ typedef struct
cl_float3
ref_coords_const
[
MAX_NUM_OF_ATOMS
]
__attribute__
((
aligned
(
2048
)));
cl_float3
rotbonds_moving_vectors_const
[
MAX_NUM_OF_ROTBONDS
]
__attribute__
((
aligned
(
512
)));
cl_float3
rotbonds_unit_vectors_const
[
MAX_NUM_OF_ROTBONDS
]
__attribute__
((
aligned
(
512
)));
#if defined(SINGLE_COPY_POP_ENE)
cl_float4
ref_orientation_quats_const
[
MAX_NUM_OF_RUNS
]
__attribute__
((
aligned
(
512
)));
#endif
}
kernelconstant_static
;
// As struct members are used as host buffers
...
...
@@ -136,14 +132,6 @@ typedef struct
// This is added for the sake of completion
// cl_float3 is made of 4 floats, its size is 16 bytes
#if defined(SINGLE_COPY_POP_ENE)
#else
typedef
struct
{
float
ref_orientation_quats_const
[
4
]
__attribute__
((
aligned
(
64
)));
}
kernelconstant_dynamic
;
#endif
/*
...
...
@@ -153,20 +141,9 @@ int prepare_const_fields_for_gpu(Liganddata* myligand_reference,
kernelconstant* KerConst);
*/
int
prepare_conststatic_fields_for_gpu
(
Liganddata
*
myligand_reference
,
Dockpars
*
mypars
,
#if defined(SINGLE_COPY_POP_ENE)
float
*
cpu_ref_ori_angles
,
#endif
Dockpars
*
mypars
,
float
*
cpu_ref_ori_angles
,
kernelconstant_static
*
KerConstStatic
);
#if defined(SINGLE_COPY_POP_ENE)
#else
int
prepare_constdynamic_fields_for_gpu
(
Liganddata
*
myligand_reference
,
Dockpars
*
mypars
,
float
*
cpu_ref_ori_angles
,
kernelconstant_dynamic
*
KerConstDynamic
);
#endif
void
make_reqrot_ordering
(
char
number_of_req_rotations
[
MAX_NUM_OF_ATOMS
],
char
atom_id_of_numrots
[
MAX_NUM_OF_ATOMS
],
...
...
ofdock_taskpar_xl/host/src/calcenergy.cpp
View file @
3ee08f63
...
...
@@ -232,20 +232,9 @@ int prepare_const_fields_for_gpu(Liganddata* myligand_reference,
}
*/
int
prepare_conststatic_fields_for_gpu
(
Liganddata
*
myligand_reference
,
Dockpars
*
mypars
,
#if defined(SINGLE_COPY_POP_ENE)
float
*
cpu_ref_ori_angles
,
#endif
Dockpars
*
mypars
,
float
*
cpu_ref_ori_angles
,
kernelconstant_static
*
KerConstStatic
)
{
int
i
,
j
;
...
...
@@ -441,9 +430,6 @@ int prepare_conststatic_fields_for_gpu(Liganddata* myligand_reference,
KerConstStatic
->
rotbonds_unit_vectors_const
[
i
].
z
=
myligand_reference
->
rotbonds_unit_vectors
[
i
][
2
];
}
#if defined(SINGLE_COPY_POP_ENE)
float
phi
,
theta
,
genrotangle
;
//reference orientation quaternions
...
...
@@ -465,167 +451,10 @@ int prepare_conststatic_fields_for_gpu(Liganddata* myligand_reference,
KerConstStatic
->
ref_orientation_quats_const
[
i
].
z
=
sinf
(
genrotangle
/
2.0
f
)
*
sinf
(
theta
)
*
sinf
(
phi
);
//y
KerConstStatic
->
ref_orientation_quats_const
[
i
].
w
=
sinf
(
genrotangle
/
2.0
f
)
*
cosf
(
theta
);
//z
}
#endif
return
0
;
}
#if defined(SINGLE_COPY_POP_ENE)
#else
int
prepare_constdynamic_fields_for_gpu
(
Liganddata
*
myligand_reference
,
Dockpars
*
mypars
,
float
*
cpu_ref_ori_angles
,
kernelconstant_dynamic
*
KerConstDynamic
)
{
int
i
,
j
;
//int type_id1, type_id2;
//float* floatpoi;
//char* charpoi;
float
phi
,
theta
,
genrotangle
;
/*
// ------------------------------
cl_float3 ref_coords[MAX_NUM_OF_ATOMS];
cl_float3 rotbonds_moving_vectors[MAX_NUM_OF_ROTBONDS];
cl_float3 rotbonds_unit_vectors[MAX_NUM_OF_ROTBONDS];
float ref_orientation_quats[4];
// ------------------------------
*/
#if 0
//coordinates of reference ligand
for (i=0; i < myligand_reference->num_of_atoms; i++)
{
/*
ref_coords[i].x = myligand_reference->atom_idxyzq[i][1];
ref_coords[i].y = myligand_reference->atom_idxyzq[i][2];
ref_coords[i].z = myligand_reference->atom_idxyzq[i][3];
*/
KerConstDynamic->ref_coords_const[i].x = myligand_reference->atom_idxyzq[i][1];
KerConstDynamic->ref_coords_const[i].y = myligand_reference->atom_idxyzq[i][2];
KerConstDynamic->ref_coords_const[i].z = myligand_reference->atom_idxyzq[i][3];
}
//rotatable bond vectors
for (i=0; i < myligand_reference->num_of_rotbonds; i++) {
/*
rotbonds_moving_vectors[i].x = myligand_reference->rotbonds_moving_vectors[i][0];
rotbonds_moving_vectors[i].y = myligand_reference->rotbonds_moving_vectors[i][1];
rotbonds_moving_vectors[i].z = myligand_reference->rotbonds_moving_vectors[i][2];
rotbonds_unit_vectors[i].x = myligand_reference->rotbonds_unit_vectors[i][0];
rotbonds_unit_vectors[i].y = myligand_reference->rotbonds_unit_vectors[i][1];
rotbonds_unit_vectors[i].z = myligand_reference->rotbonds_unit_vectors[i][2];
*/
KerConstDynamic->rotbonds_moving_vectors_const[i].x = myligand_reference->rotbonds_moving_vectors[i][0];
KerConstDynamic->rotbonds_moving_vectors_const[i].y = myligand_reference->rotbonds_moving_vectors[i][1];
KerConstDynamic->rotbonds_moving_vectors_const[i].z = myligand_reference->rotbonds_moving_vectors[i][2];
KerConstDynamic->rotbonds_unit_vectors_const[i].x = myligand_reference->rotbonds_unit_vectors[i][0];
KerConstDynamic->rotbonds_unit_vectors_const[i].y = myligand_reference->rotbonds_unit_vectors[i][1];
KerConstDynamic->rotbonds_unit_vectors_const[i].z = myligand_reference->rotbonds_unit_vectors[i][2];
}
#endif
//reference orientation quaternions
// for (i=0; i<mypars->num_of_runs; i++)
// {
// //printf("Pregenerated angles for run %d: %f %f %f\n", i, cpu_ref_ori_angles[3*i], cpu_ref_ori_angles[3*i+1], cpu_ref_ori_angles[3*i+2]);
// phi = cpu_ref_ori_angles[3*i]*DEG_TO_RAD;
// theta = cpu_ref_ori_angles[3*i+1]*DEG_TO_RAD;
// genrotangle = cpu_ref_ori_angles[3*i+2]*DEG_TO_RAD;
// ref_orientation_quats[4*i] = cosf(genrotangle/2.0f); //q
// ref_orientation_quats[4*i+1] = sinf(genrotangle/2.0f)*sinf(theta)*cosf(phi); //x
// ref_orientation_quats[4*i+2] = sinf(genrotangle/2.0f)*sinf(theta)*sinf(phi); //y
// ref_orientation_quats[4*i+3] = sinf(genrotangle/2.0f)*cosf(theta); //z
// //printf("Precalculated quaternion for run %d: %f %f %f %f\n", i, ref_orientation_quats[4*i], ref_orientation_quats[4*i+1], ref_orientation_quats[4*i+2], ref_orientation_quats[4*i+3]);
// }
phi
=
cpu_ref_ori_angles
[
0
]
*
DEG_TO_RAD
;
theta
=
cpu_ref_ori_angles
[
1
]
*
DEG_TO_RAD
;
genrotangle
=
cpu_ref_ori_angles
[
2
]
*
DEG_TO_RAD
;
/*
ref_orientation_quats[0] = cosf(genrotangle/2.0f); //q
ref_orientation_quats[1] = sinf(genrotangle/2.0f)*sinf(theta)*cosf(phi); //x
ref_orientation_quats[2] = sinf(genrotangle/2.0f)*sinf(theta)*sinf(phi); //y
ref_orientation_quats[3] = sinf(genrotangle/2.0f)*cosf(theta); //z
*/
KerConstDynamic
->
ref_orientation_quats_const
[
0
]
=
cosf
(
genrotangle
/
2.0
f
);
//q
KerConstDynamic
->
ref_orientation_quats_const
[
1
]
=
sinf
(
genrotangle
/
2.0
f
)
*
sinf
(
theta
)
*
cosf
(
phi
);
//x
KerConstDynamic
->
ref_orientation_quats_const
[
2
]
=
sinf
(
genrotangle
/
2.0
f
)
*
sinf
(
theta
)
*
sinf
(
phi
);
//y
KerConstDynamic
->
ref_orientation_quats_const
[
3
]
=
sinf
(
genrotangle
/
2.0
f
)
*
cosf
(
theta
);
//z
/*
int m;
for (m=0;m<MAX_NUM_OF_ATOMS;m++) { KerConstDynamic->ref_coords_const[m]= ref_coords[m]; }
for (m=0;m<MAX_NUM_OF_ROTBONDS;m++){ KerConstDynamic->rotbonds_moving_vectors_const[m]= rotbonds_moving_vectors[m]; }
for (m=0;m<MAX_NUM_OF_ROTBONDS;m++){ KerConstDynamic->rotbonds_unit_vectors_const[m] = rotbonds_unit_vectors[m]; }
for (m=0;m<4;m++) { KerConstDynamic->ref_orientation_quats_const[m] = ref_orientation_quats[m]; }
*/
return
0
;
}
#endif
void
make_reqrot_ordering
(
char
number_of_req_rotations
[
MAX_NUM_OF_ATOMS
],
char
atom_id_of_numrots
[
MAX_NUM_OF_ATOMS
],
int
num_of_atoms
)
...
...
ofdock_taskpar_xl/host/src/getparameters.cpp
View file @
3ee08f63
...
...
@@ -598,11 +598,7 @@ void gen_initpop_and_reflig(Dockpars* mypars,
//Generating initial population
if
(
gen_pop
==
1
)
{
#if defined(SINGLE_COPY_POP_ENE)
for
(
entity_id
=
0
;
entity_id
<
pop_size
*
mypars
->
num_of_runs
;
entity_id
++
)
#else
for
(
entity_id
=
0
;
entity_id
<
pop_size
;
entity_id
++
)
#endif
for
(
gene_id
=
0
;
gene_id
<
3
;
gene_id
++
)
#if defined (REPRO)
//init_populations[entity_id*GENOTYPE_LENGTH_IN_GLOBMEM+gene_id] = 30.1186;
...
...
@@ -612,11 +608,7 @@ void gen_initpop_and_reflig(Dockpars* mypars,
init_populations
[
entity_id
*
ACTUAL_GENOTYPE_LENGTH
+
gene_id
]
=
(
float
)
myrand
()
*
(
mygrid
->
size_xyz_angstr
[
gene_id
]);
#endif
#if defined(SINGLE_COPY_POP_ENE)
for
(
entity_id
=
0
;
entity_id
<
pop_size
*
mypars
->
num_of_runs
;
entity_id
++
)
#else
for
(
entity_id
=
0
;
entity_id
<
pop_size
;
entity_id
++
)
#endif
for
(
gene_id
=
3
;
gene_id
<
MAX_NUM_OF_ROTBONDS
+
6
;
gene_id
++
)
if
(
gene_id
==
4
)
#if defined (REPRO)
...
...
@@ -668,12 +660,7 @@ void gen_initpop_and_reflig(Dockpars* mypars,
//genotypes should contain x, y and z genes in grid spacing instead of Angstroms
//(but was previously generated in Angstroms since fdock does the same)
#if defined(SINGLE_COPY_POP_ENE)
for
(
entity_id
=
0
;
entity_id
<
pop_size
*
mypars
->
num_of_runs
;
entity_id
++
)
#else
for
(
entity_id
=
0
;
entity_id
<
pop_size
;
entity_id
++
)
#endif
for
(
gene_id
=
0
;
gene_id
<
3
;
gene_id
++
)
//init_populations [entity_id*GENOTYPE_LENGTH_IN_GLOBMEM+gene_id] = init_populations [entity_id*GENOTYPE_LENGTH_IN_GLOBMEM+gene_id]/mygrid->spacing;
init_populations
[
entity_id
*
ACTUAL_GENOTYPE_LENGTH
+
gene_id
]
=
init_populations
[
entity_id
*
ACTUAL_GENOTYPE_LENGTH
+
gene_id
]
/
mygrid
->
spacing
;
...
...
@@ -699,7 +686,6 @@ void gen_initpop_and_reflig(Dockpars* mypars,
//initial orientation will be calculated during docking,
//only the required angles are generated here,
//but the angles possibly read from file are ignored
#if defined(SINGLE_COPY_POP_ENE)
for
(
int
i
=
0
;
i
<
mypars
->
num_of_runs
;
i
++
)
{
#if defined (REPRO)
...
...
@@ -712,17 +698,7 @@ void gen_initpop_and_reflig(Dockpars* mypars,
ref_ori_angles
[
3
*
i
+
2
]
=
(
float
)
(
myrand
()
*
360.0
);
//angle
#endif
}
#else
#if defined (REPRO)
ref_ori_angles
[
0
]
=
190.279
;
ref_ori_angles
[
1
]
=
90.279
;
ref_ori_angles
[
2
]
=
190.279
;
#else
ref_ori_angles
[
0
]
=
(
float
)
(
myrand
()
*
360.0
);
//phi
ref_ori_angles
[
1
]
=
(
float
)
(
myrand
()
*
180.0
);
//theta
ref_ori_angles
[
2
]
=
(
float
)
(
myrand
()
*
360.0
);
//angle
#endif
#endif
get_movvec_to_origo
(
myligand
,
movvec_to_origo
);
move_ligand
(
myligand
,
movvec_to_origo
);
scale_ligand
(
myligand
,
1.0
/
mygrid
->
spacing
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment