/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: Mike Brown (ORNL), brownw@ornl.gov ------------------------------------------------------------------------- */ #ifndef GB_GPU_KERNEL_LJ #define GB_GPU_KERNEL_LJ #ifdef NV_KERNEL #include "gb_gpu_extra.h" #endif __kernel void kernel_sphere_gb(__global numtyp4 *x_,__global numtyp4 *q, __global numtyp4* shape,__global numtyp4* well, __global numtyp *gum, __global numtyp2* sig_eps, const int ntypes, __global numtyp *lshape, __global int *dev_nbor, const int stride, __global acctyp4 *ans, __global acctyp *engv, __global int *err_flag, const int eflag, const int vflag,const int start, const int inum, const int nall) { __local numtyp sp_lj[4]; // ii indexes the two interacting particles in gi int ii=THREAD_ID_X; if (ii<4) sp_lj[ii]=gum[ii+3]; ii+=mul24((int)BLOCK_ID_X,(int)BLOCK_SIZE_X)+start; __syncthreads(); if (ii0) energy+=u_r*temp2; numtyp temp1 = -eta*u_r*factor_lj; if (vflag>0) { r12[0]*=-1; r12[1]*=-1; r12[2]*=-1; numtyp ft=temp1*dchi[0]-temp2*dUr[0]; f.x+=ft; virial[0]+=r12[0]*ft; ft=temp1*dchi[1]-temp2*dUr[1]; f.y+=ft; virial[1]+=r12[1]*ft; virial[3]+=r12[0]*ft; ft=temp1*dchi[2]-temp2*dUr[2]; f.z+=ft; virial[2]+=r12[2]*ft; virial[4]+=r12[0]*ft; virial[5]+=r12[1]*ft; } else { f.x+=temp1*dchi[0]-temp2*dUr[0]; f.y+=temp1*dchi[1]-temp2*dUr[1]; f.z+=temp1*dchi[2]-temp2*dUr[2]; } } // for nbor // Store answers __global acctyp *ap1=engv+ii; if (eflag>0) { *ap1=energy; ap1+=inum; } if (vflag>0) { for (int i=0; i<6; i++) { *ap1=virial[i]; ap1+=inum; } } ans[ii]=f; } // if ii } __kernel void kernel_lj(__global numtyp4 *x_, __global numtyp4 *lj1, __global numtyp4* lj3, const int lj_types, __global numtyp *gum, const int stride, __global int *dev_ij, __global acctyp4 *ans, __global acctyp *engv, __global int *err_flag, const int eflag, const int vflag, const int start, const int inum, const int nall) { __local numtyp sp_lj[4]; // ii indexes the two interacting particles in gi int ii=THREAD_ID_X; if (ii<4) sp_lj[ii]=gum[ii+3]; ii+=mul24((int)BLOCK_ID_X,(int)BLOCK_SIZE_X)+start; __syncthreads(); if (ii0) { numtyp e=r6inv*(lj3[ii].x*r6inv-lj3[ii].y); energy+=factor_lj*(e-lj3[ii].z); } if (vflag>0) { virial[0] += delx*delx*force; virial[1] += dely*dely*force; virial[2] += delz*delz*force; virial[3] += delx*dely*force; virial[4] += delx*delz*force; virial[5] += dely*delz*force; } } } // for nbor // Store answers __global acctyp *ap1=engv+ii; if (eflag>0) { *ap1+=energy; ap1+=inum; } if (vflag>0) { for (int i=0; i<6; i++) { *ap1+=virial[i]; ap1+=inum; } } acctyp4 old=ans[ii]; old.x+=f.x; old.y+=f.y; old.z+=f.z; ans[ii]=old; } // if ii } __kernel void kernel_lj_fast(__global numtyp4 *x_, __global numtyp4 *lj1_in, __global numtyp4* lj3_in, __global numtyp *gum, const int stride, __global int *dev_ij, __global acctyp4 *ans, __global acctyp *engv, __global int *err_flag, const int eflag,const int vflag, const int start, const int inum, const int nall) { // ii indexes the two interacting particles in gi int ii=THREAD_ID_X; __local numtyp sp_lj[4]; __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; if (ii<4) sp_lj[ii]=gum[ii+3]; if (ii0) lj3[ii]=lj3_in[ii]; } ii+=mul24((int)BLOCK_ID_X,(int)BLOCK_SIZE_X)+start; __syncthreads(); if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; virial[1] += dely*dely*force; virial[2] += delz*delz*force; virial[3] += delx*dely*force; virial[4] += delx*delz*force; virial[5] += dely*delz*force; } } } // for nbor // Store answers __global acctyp *ap1=engv+ii; if (eflag>0) { *ap1+=energy; ap1+=inum; } if (vflag>0) { for (int i=0; i<6; i++) { *ap1+=virial[i]; ap1+=inum; } } acctyp4 old=ans[ii]; old.x+=f.x; old.y+=f.y; old.z+=f.z; ans[ii]=old; } // if ii } #endif