R3P3T

Untitled

Jan 12th, 2021 (edited)
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. __global__ void solvation (int atoms_r, int atoms_l, int nlig, float *d_rec_x, float *d_rec_y, float *d_rec_z, float *d_lig_x, float *d_lig_y, float *d_lig_z, int* d_rectype, int* d_ligtype, float *d_ql ,float *d_qr, float *d_energy, struct autodock_param_t *d_a_params, int nconformations) {
  2.  
  3.   float dist, temp_desolv = 0, miatomo[3], e_desolv;
  4.   int ind1, ind2;
  5.   int total;
  6.  
  7.   float difx, dify, difz, solv_asp_1, solv_asp_2, solv_vol_1, solv_vol_2, solv_qasp_1, solv_qasp_2;
  8.   float mod2x, mod2y, mod2z;
  9.  
  10.   unsigned int i = blockIdx.x + blockDim.x + threadIdx.x;
  11.   int conformacion = i / nlig;
  12.   int atomo = i % nlig;
  13.   int tid = threadIdx.x;
  14.  
  15.   e_desolv = 0;
  16.   ind1 = d_ligtype[atomo];
  17.   miatomo[0] = *(d_lig_x + conformacion*nlig + atomo);
  18.   miatomo[1] = *(d_lig_y + conformacion*nlig + atomo);
  19.   miatomo[2] = *(d_lig_z + conformacion*nlig + atomo);
  20.   solv_asp_1 = d_a_params[ind1].asp;
  21.   solv_vol_1 = d_a_params[ind1].vol;
  22.  
  23.   for(int j = 0; j < atoms_l; j++){
  24.  
  25.     ind2 = d_rectype[j];
  26.     solv_asp_2 = d_a_params[ind2].asp;
  27.     solv_vol_2 = d[atomo]ms[ind2].vol;
  28.     difx = (d_rec_x[j]) - miatomo[0];
  29.     dify = (d_rec_y[j]) - miatomo[1];
  30.     difz = (d_rec_z[j]) - miatomo[2];
  31.     mod2x = difx * difx;
  32.     mod2y = dify * dify;
  33.     mod2z = difz * difz;
  34.     difx = mod2x + mod2y + mod2z; {
  35.     e_desolv = ((solv_asp_1 * solv_vol_2) + (QASP * fabs(d_ql[atomo]) * solv_vol_2) + (solv_asp_2 * solv_vol_1) + (QASP * fabs(d_qr[j]) * solv_vol_1) * exp(-difx/(2*G_D_2)));
  36.     printf("%f\n",e_desolv);
  37.    }
  38.    
  39.    d_energy[i] = e_desolv;
  40. }
  41.  
  42.  
  43. void forces_GPU_AU (int atoms_r, int atoms_l, int nlig, float *rec_x, float *rec_y, float *rec_z, float *lig_x, float *lig_y, float *lig_z, int* rectype, int* ligtype, float *ql ,float *qr, float *energy, struct autodock_param_t *a_params, int nconformations){
  44.  
  45.   float *d_rec_x, *d_rec_y, *d_rec_z, *d_lig_x, *d_lig_y, *d_lig_z, *d_ql, *d_qr, *d_energy, aux=0;
  46.   int *d_rectype, *d_ligtype,i;
  47.   struct autodock_param_t *d_a_params;
  48.  
  49.   cudaSetDevice(0);
  50.   cudaMalloc((void**)&d_rec_x, sizeof(rec_x));
  51.   cudaMalloc((void**)&d_rec_y, sizeof(rec_y));
  52.   cudaMalloc((void**)&d_rec_z, sizeof(rec_z));
  53.   cudaMalloc((void**)&d_lig_x, sizeof(lig_x));
  54.   cudaMalloc((void**)&d_lig_y, sizeof(lig_y));
  55.   cudaMalloc((void**)&d_lig_z, sizeof(lig_z));
  56.   cudaMalloc((void**)&d_ql, sizeof(ql));
  57.   cudaMalloc((void**)&d_qr, sizeof(qr));
  58.   cudaMalloc((void**)&d_energy, sizeof(energy));
  59.   cudaMalloc((void**)&d_rectype, sizeof(rectype));
  60.   cudaMalloc((void**)&d_ligtype, sizeof(ligtype));
  61.   cudaMalloc((void**)&d_a_params, sizeof(a_params));
  62.  
  63.   cudaMemcpy(d_rec_x,rec_x,sizeof(rec_x),cudaMemcpyHostToDevice);
  64.   cudaMemcpy(d_rec_y,rec_y,sizeof(rec_y),cudaMemcpyHostToDevice);
  65.   cudaMemcpy(d_rec_z,rec_z,sizeof(rec_z),cudaMemcpyHostToDevice);
  66.   cudaMemcpy(d_lig_x,lig_x,sizeof(lig_x),cudaMemcpyHostToDevice);
  67.   cudaMemcpy(d_lig_y,lig_y,sizeof(lig_y),cudaMemcpyHostToDevice);
  68.   cudaMemcpy(d_lig_z,lig_z,sizeof(lig_z),cudaMemcpyHostToDevice);
  69.   cudaMemcpy(d_ql,ql,sizeof(ql),cudaMemcpyHostToDevice);
  70.   cudaMemcpy(d_qr,qr,sizeof(qr),cudaMemcpyHostToDevice);
  71.   cudaMemcpy(d_energy,energy,sizeof(energy),cudaMemcpyHostToDevice);
  72.   cudaMemcpy(d_rectype,rectype,sizeof(rectype),cudaMemcpyHostToDevice);
  73.   cudaMemcpy(d_ligtype,ligtype,sizeof(ligtype),cudaMemcpyHostToDevice);
  74.   cudaMemcpy(d_a_params,a_params,sizeof(a_params),cudaMemcpyHostToDevice);
  75.  
  76.   //Definir numero de hilos y bloques
  77.   dim3 thread (tam_block);
  78.   dim3 block ((nconformations*nlig/tam_block)+1);
  79.  
  80.   //Anadir parametros
  81.   solvation <<< block,thread>>> (atoms_r,atoms_l, nlig, d_rec_x,d_rec_y,d_rec_z,d_lig_x,d_lig_y,d_lig_z,d_rectype,d_ligtype,d_ql,d_qr,d_energy,d_a_params, nconformations);
  82.  
  83.   cudaMemcpy(energy,d_energy,sizeof(energy),cudaMemcpyDeviceToHost);
  84.   //for(i = 0; i < (nconformations*nlig) ; i++){
  85.     // aux += energy[i];
  86.   //}
  87.   //printf("aux = %f",aux);
  88. }
  89.  
RAW Paste Data