calcenergy.h 4.03 KB
Newer Older
lvs's avatar
lvs committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef CALCENERGY_H_
#define CALCENERGY_H_

#include <math.h>
#include <stdio.h>

#include "defines.h"
#include "miscellaneous.h"
#include "processligand.h"
#include "getparameters.h"

// This struct is passed to the GPU global functions (OpenCL kernels) as input.
// Its members are parameters related to the ligand, the grid
// and the genetic algorithm, or they are pointers of GPU (ADM FPGA) memory areas
// 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
29
	float  		grid_spacing;
lvs's avatar
lvs committed
30
31
32
	unsigned int    rotbondlist_length;
	float  		coeff_elec;
	float  		coeff_desolv;
Leonardo Solis's avatar
Leonardo Solis committed
33
34
	unsigned int 	num_of_energy_evals;
	unsigned int 	num_of_generations;
lvs's avatar
lvs committed
35
	unsigned int    pop_size;
36
	unsigned char   num_of_genes;
lvs's avatar
lvs committed
37
38
39
40
41
	float  		tournament_rate;
	float  		crossover_rate;
	float  		mutation_rate;
	float  		abs_max_dmov;
	float  		abs_max_dang;
Leonardo Solis's avatar
Leonardo Solis committed
42
	float  		lsearch_rate;
Leonardo Solis's avatar
Leonardo Solis committed
43
	float 		smooth;
lvs's avatar
lvs committed
44
45
46
47
48
49
50
51
52
	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;

53
#include "xcl2.hpp"
54
#define XILINX_MEMALIGN 4096
lvs's avatar
lvs committed
55

56
// Aligning struc to XILINX_MEMALIGN to avoid additional memcpy() calls
lvs's avatar
lvs committed
57
58
typedef struct
{
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
       	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
75
76
77
} kernelconstant_static;

int prepare_conststatic_fields_for_gpu(Liganddata* 	       myligand_reference,
78
79
				 	Dockpars*   	       mypars,
				 	float*      	       cpu_ref_ori_angles,
lvs's avatar
lvs committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
				 	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_ */