// ************************************************************************** // eam.cu // ------------------- // Trung Dac Nguyen, W. Michael Brown (ORNL) // // Device code for acceleration of the eam pair style // // __________________________________________________________________________ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // // begin : // email : brownw@ornl.gov nguyentd@ornl.gov // *************************************************************************** #if defined(NV_KERNEL) || defined(USE_HIP) #include "lal_aux_fun1.h" #ifndef _DOUBLE_DOUBLE _texture( pos_tex,float4); _texture( fp_tex,float); _texture( rhor_sp1_tex,float4); _texture( rhor_sp2_tex,float4); _texture( frho_sp1_tex,float4); _texture( frho_sp2_tex,float4); _texture( z2r_sp1_tex,float4); _texture( z2r_sp2_tex,float4); #else _texture( pos_tex,int4); _texture( fp_tex,int2); _texture( rhor_sp1_tex,int4); _texture( rhor_sp2_tex,int4); _texture( frho_sp1_tex,int4); _texture( frho_sp2_tex,int4); _texture( z2r_sp1_tex,int4); _texture( z2r_sp2_tex,int4); #endif #if (__CUDACC_VER_MAJOR__ >= 11) #define fp_tex fp_ #define rhor_sp1_tex rhor_spline1 #define rhor_sp2_tex rhor_spline2 #define frho_sp1_tex frho_spline1 #define frho_sp2_tex frho_spline2 #define z2r_sp1_tex z2r_spline1 #define z2r_sp2_tex z2r_spline2 #endif #else #define pos_tex x_ #define fp_tex fp_ #define rhor_sp1_tex rhor_spline1 #define rhor_sp2_tex rhor_spline2 #define frho_sp1_tex frho_spline1 #define frho_sp2_tex frho_spline2 #define z2r_sp1_tex z2r_spline1 #define z2r_sp2_tex z2r_spline2 #endif #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) #if (SHUFFLE_AVAIL == 0) #define local_allocate_store_energy_fp() \ __local acctyp red_acc[BLOCK_PAIR]; #define store_energy_fp(rho,energy,ii,inum,tid,t_per_atom,offset, \ eflag,vflag,engv,rdrho,nrho,i,rhomax,tfrho) \ if (t_per_atom>1) { \ red_acc[tid]=rho; \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \ simdsync(); \ if (offset < s) \ red_acc[tid] += red_acc[tid+s]; \ } \ rho=red_acc[tid]; \ } \ if (offset==0 && ii rhomax) energy += fp*(rho-rhomax); \ engv[ii]=energy; \ } \ } #define local_allocate_store_answers_eam() \ __local acctyp red_acc[6][BLOCK_PAIR]; #define store_answers_eam(f, energy, virial, ii, inum, tid, t_per_atom, \ offset, elag, vflag, ans, engv) \ if (t_per_atom>1) { \ red_acc[0][tid]=f.x; \ red_acc[1][tid]=f.y; \ red_acc[2][tid]=f.z; \ red_acc[3][tid]=energy; \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \ simdsync(); \ if (offset < s) { \ for (int r=0; r<4; r++) \ red_acc[r][tid] += red_acc[r][tid+s]; \ } \ } \ f.x=red_acc[0][tid]; \ f.y=red_acc[1][tid]; \ f.z=red_acc[2][tid]; \ energy=red_acc[3][tid]; \ if (EVFLAG && vflag) { \ simdsync(); \ for (int r=0; r<6; r++) \ red_acc[r][tid]=virial[r]; \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \ simdsync(); \ if (offset < s) { \ for (int r=0; r<6; r++) \ red_acc[r][tid] += red_acc[r][tid+s]; \ } \ } \ for (int r=0; r<6; r++) \ virial[r]=red_acc[r][tid]; \ } \ } \ if (offset==0 && ii1) { \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) \ rho += shfl_down(rho, s, t_per_atom); \ } \ if (offset==0 && ii rhomax) energy += fp*(rho-rhomax); \ engv[ii]=energy; \ } \ } #define local_allocate_store_answers_eam() #define store_answers_eam(f, energy, virial, ii, inum, tid, t_per_atom, \ offset, eflag, vflag, ans, engv) \ if (t_per_atom>1) { \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \ f.x += shfl_down(f.x, s, t_per_atom); \ f.y += shfl_down(f.y, s, t_per_atom); \ f.z += shfl_down(f.z, s, t_per_atom); \ if (EVFLAG) energy += shfl_down(energy, s, t_per_atom); \ } \ if (EVFLAG && vflag) { \ for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \ for (int r=0; r<6; r++) \ virial[r] += shfl_down(virial[r], s, t_per_atom); \ } \ } \ } \ if (offset==0 && ii