calcenergy.h 3.98 KB
Newer Older
lvs's avatar
lvs committed
1
2
#ifndef CALCENERGY_H_
#define CALCENERGY_H_
3
4

#include "ext_headers.h"
lvs's avatar
lvs committed
5
6
7
8
#include "miscellaneous.h"
#include "processligand.h"
#include "getparameters.h"

9
10
11
// Members of this struct are passed to the FPGA OpenCL kernels as inputs.
// Struct members are parameters related to the ligand, the grid
// and the genetic algorithm, or they are pointers of FPGA memory areas
lvs's avatar
lvs committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// used for storing different data such as the current
// and the next population genotypes and energies, the grids,
// the evaluation counters and the random number generator states.
typedef struct
{
	unsigned char  	num_of_atoms;
	unsigned char   num_of_atypes;
	unsigned int    num_of_intraE_contributors;
	unsigned char   gridsize_x;
	unsigned char   gridsize_y;
	unsigned char   gridsize_z;
	unsigned char	g1;
	unsigned int	g2;
	unsigned int 	g3;
Leonardo Solis's avatar
Leonardo Solis committed
26
	float  		grid_spacing;
lvs's avatar
lvs committed
27
28
29
	unsigned int    rotbondlist_length;
	float  		coeff_elec;
	float  		coeff_desolv;
Leonardo Solis's avatar
Leonardo Solis committed
30
31
	unsigned int 	num_of_energy_evals;
	unsigned int 	num_of_generations;
lvs's avatar
lvs committed
32
	unsigned int    pop_size;
33
	unsigned char   num_of_genes;
lvs's avatar
lvs committed
34
35
36
37
38
	float  		tournament_rate;
	float  		crossover_rate;
	float  		mutation_rate;
	float  		abs_max_dmov;
	float  		abs_max_dang;
Leonardo Solis's avatar
Leonardo Solis committed
39
	float  		lsearch_rate;
Leonardo Solis's avatar
Leonardo Solis committed
40
	float 		smooth;
lvs's avatar
lvs committed
41
42
43
44
45
46
47
48
49
	unsigned int 	num_of_lsentities;
	float  		rho_lower_bound;
	float  		base_dmov_mul_sqrt3;
	float  		base_dang_mul_sqrt3;
	unsigned int 	cons_limit;
	unsigned int 	max_num_of_iters;
	float  		qasp;
} Dockparameters;

50
// Aligning struc explictly to XILINX_MEMALIGN to avoid additional memcpy() calls
51
#define XILINX_MEMALIGN 4096
lvs's avatar
lvs committed
52
53
54

typedef struct
{
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
       	float 		atom_charges_const	     [MAX_NUM_OF_ATOMS]                    	__attribute__ ((aligned (XILINX_MEMALIGN)));
       	char  		atom_types_const  	     [MAX_NUM_OF_ATOMS]                    	__attribute__ ((aligned (XILINX_MEMALIGN)));
	cl_char3  	intraE_contributors_const    [MAX_INTRAE_CONTRIBUTORS]  		__attribute__ ((aligned (XILINX_MEMALIGN)));
        float 		reqm_const 		     [ATYPE_NUM]				__attribute__ ((aligned (XILINX_MEMALIGN)));
        float 		reqm_hbond_const 	     [ATYPE_NUM]			      	__attribute__ ((aligned (XILINX_MEMALIGN)));
        unsigned int 	atom1_types_reqm_const 	     [ATYPE_NUM]	      			__attribute__ ((aligned (XILINX_MEMALIGN)));
        unsigned int	atom2_types_reqm_const 	     [ATYPE_NUM]	      			__attribute__ ((aligned (XILINX_MEMALIGN)));
       	float     	VWpars_AC_const              [MAX_NUM_OF_ATYPES*MAX_NUM_OF_ATYPES] 	__attribute__ ((aligned (XILINX_MEMALIGN)));
       	float     	VWpars_BD_const              [MAX_NUM_OF_ATYPES*MAX_NUM_OF_ATYPES] 	__attribute__ ((aligned (XILINX_MEMALIGN)));
      	float     	dspars_S_const               [MAX_NUM_OF_ATYPES]                   	__attribute__ ((aligned (XILINX_MEMALIGN)));
       	float     	dspars_V_const               [MAX_NUM_OF_ATYPES]                   	__attribute__ ((aligned (XILINX_MEMALIGN)));
       	int       	rotlist_const                [MAX_NUM_OF_ROTATIONS]                	__attribute__ ((aligned (XILINX_MEMALIGN)));
      	cl_float3 	ref_coords_const             [MAX_NUM_OF_ATOMS]                  	__attribute__ ((aligned (XILINX_MEMALIGN)));
       	cl_float3 	rotbonds_moving_vectors_const[MAX_NUM_OF_ROTBONDS]  			__attribute__ ((aligned (XILINX_MEMALIGN)));
       	cl_float3 	rotbonds_unit_vectors_const  [MAX_NUM_OF_ROTBONDS]  			__attribute__ ((aligned (XILINX_MEMALIGN)));
	cl_float4 	ref_orientation_quats_const  [MAX_NUM_OF_RUNS]      			__attribute__ ((aligned (XILINX_MEMALIGN)));
lvs's avatar
lvs committed
71
72
} kernelconstant_static;

73
int prepare_conststatic_fields_for_fpga(Liganddata* 	       myligand_reference,
74
75
				 	Dockpars*   	       mypars,
				 	float*      	       cpu_ref_ori_angles,
lvs's avatar
lvs committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
				 	kernelconstant_static* KerConstStatic);

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);

int gen_rotlist(Liganddata* myligand,
		int         rotlist[MAX_NUM_OF_ROTATIONS]);

#endif /* CALCENERGY_H_ */