2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_double
51 * Electrostatics interaction: None
52 * VdW interaction: LennardJones
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81 int vdwjidx0A,vdwjidx0B;
82 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
85 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
88 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
89 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
90 __m128d dummy_mask,cutoff_mask;
91 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
92 __m128d one = _mm_set1_pd(1.0);
93 __m128d two = _mm_set1_pd(2.0);
99 jindex = nlist->jindex;
101 shiftidx = nlist->shift;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 /* Avoid stupid compiler warnings */
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
123 /* Load limits for loop over neighbors */
124 j_index_start = jindex[iidx];
125 j_index_end = jindex[iidx+1];
127 /* Get outer coordinate index */
129 i_coord_offset = DIM*inr;
131 /* Load i particle coords and add shift vector */
132 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
134 fix0 = _mm_setzero_pd();
135 fiy0 = _mm_setzero_pd();
136 fiz0 = _mm_setzero_pd();
138 /* Load parameters for i particles */
139 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141 /* Reset potential sums */
142 vvdwsum = _mm_setzero_pd();
144 /* Start inner kernel loop */
145 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
148 /* Get j neighbor index, and coordinate index */
151 j_coord_offsetA = DIM*jnrA;
152 j_coord_offsetB = DIM*jnrB;
154 /* load j atom coordinates */
155 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
158 /* Calculate displacement vector */
159 dx00 = _mm_sub_pd(ix0,jx0);
160 dy00 = _mm_sub_pd(iy0,jy0);
161 dz00 = _mm_sub_pd(iz0,jz0);
163 /* Calculate squared distance and things based on it */
164 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
166 rinvsq00 = avx128fma_inv_d(rsq00);
168 /* Load parameters for j particles */
169 vdwjidx0A = 2*vdwtype[jnrA+0];
170 vdwjidx0B = 2*vdwtype[jnrB+0];
172 /**************************
173 * CALCULATE INTERACTIONS *
174 **************************/
176 /* Compute parameters for interactions between i and j atoms */
177 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
178 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
180 /* LENNARD-JONES DISPERSION/REPULSION */
182 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
183 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
184 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
185 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
186 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
188 /* Update potential sum for this i atom from the interaction with this j atom. */
189 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
193 /* Update vectorial force */
194 fix0 = _mm_macc_pd(dx00,fscal,fix0);
195 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
196 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
198 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
199 _mm_mul_pd(dx00,fscal),
200 _mm_mul_pd(dy00,fscal),
201 _mm_mul_pd(dz00,fscal));
203 /* Inner loop uses 35 flops */
210 j_coord_offsetA = DIM*jnrA;
212 /* load j atom coordinates */
213 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
216 /* Calculate displacement vector */
217 dx00 = _mm_sub_pd(ix0,jx0);
218 dy00 = _mm_sub_pd(iy0,jy0);
219 dz00 = _mm_sub_pd(iz0,jz0);
221 /* Calculate squared distance and things based on it */
222 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
224 rinvsq00 = avx128fma_inv_d(rsq00);
226 /* Load parameters for j particles */
227 vdwjidx0A = 2*vdwtype[jnrA+0];
229 /**************************
230 * CALCULATE INTERACTIONS *
231 **************************/
233 /* Compute parameters for interactions between i and j atoms */
234 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
236 /* LENNARD-JONES DISPERSION/REPULSION */
238 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
239 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
240 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
241 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
242 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
244 /* Update potential sum for this i atom from the interaction with this j atom. */
245 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
246 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
250 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
252 /* Update vectorial force */
253 fix0 = _mm_macc_pd(dx00,fscal,fix0);
254 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
255 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
257 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
258 _mm_mul_pd(dx00,fscal),
259 _mm_mul_pd(dy00,fscal),
260 _mm_mul_pd(dz00,fscal));
262 /* Inner loop uses 35 flops */
265 /* End of innermost loop */
267 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
268 f+i_coord_offset,fshift+i_shift_offset);
271 /* Update potential energies */
272 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
274 /* Increment number of inner iterations */
275 inneriter += j_index_end - j_index_start;
277 /* Outer loop uses 7 flops */
280 /* Increment number of outer iterations */
283 /* Update outer/inner flops */
285 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*35);
288 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double
289 * Electrostatics interaction: None
290 * VdW interaction: LennardJones
291 * Geometry: Particle-Particle
292 * Calculate force/pot: Force
295 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double
296 (t_nblist * gmx_restrict nlist,
297 rvec * gmx_restrict xx,
298 rvec * gmx_restrict ff,
299 struct t_forcerec * gmx_restrict fr,
300 t_mdatoms * gmx_restrict mdatoms,
301 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
302 t_nrnb * gmx_restrict nrnb)
304 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
305 * just 0 for non-waters.
306 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
307 * jnr indices corresponding to data put in the four positions in the SIMD register.
309 int i_shift_offset,i_coord_offset,outeriter,inneriter;
310 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
312 int j_coord_offsetA,j_coord_offsetB;
313 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
315 real *shiftvec,*fshift,*x,*f;
316 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
318 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
319 int vdwjidx0A,vdwjidx0B;
320 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
321 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
323 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
326 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
327 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
328 __m128d dummy_mask,cutoff_mask;
329 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
330 __m128d one = _mm_set1_pd(1.0);
331 __m128d two = _mm_set1_pd(2.0);
337 jindex = nlist->jindex;
339 shiftidx = nlist->shift;
341 shiftvec = fr->shift_vec[0];
342 fshift = fr->fshift[0];
343 nvdwtype = fr->ntype;
345 vdwtype = mdatoms->typeA;
347 /* Avoid stupid compiler warnings */
355 /* Start outer loop over neighborlists */
356 for(iidx=0; iidx<nri; iidx++)
358 /* Load shift vector for this list */
359 i_shift_offset = DIM*shiftidx[iidx];
361 /* Load limits for loop over neighbors */
362 j_index_start = jindex[iidx];
363 j_index_end = jindex[iidx+1];
365 /* Get outer coordinate index */
367 i_coord_offset = DIM*inr;
369 /* Load i particle coords and add shift vector */
370 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
372 fix0 = _mm_setzero_pd();
373 fiy0 = _mm_setzero_pd();
374 fiz0 = _mm_setzero_pd();
376 /* Load parameters for i particles */
377 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
379 /* Start inner kernel loop */
380 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
383 /* Get j neighbor index, and coordinate index */
386 j_coord_offsetA = DIM*jnrA;
387 j_coord_offsetB = DIM*jnrB;
389 /* load j atom coordinates */
390 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
393 /* Calculate displacement vector */
394 dx00 = _mm_sub_pd(ix0,jx0);
395 dy00 = _mm_sub_pd(iy0,jy0);
396 dz00 = _mm_sub_pd(iz0,jz0);
398 /* Calculate squared distance and things based on it */
399 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
401 rinvsq00 = avx128fma_inv_d(rsq00);
403 /* Load parameters for j particles */
404 vdwjidx0A = 2*vdwtype[jnrA+0];
405 vdwjidx0B = 2*vdwtype[jnrB+0];
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
411 /* Compute parameters for interactions between i and j atoms */
412 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
413 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
415 /* LENNARD-JONES DISPERSION/REPULSION */
417 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
418 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
422 /* Update vectorial force */
423 fix0 = _mm_macc_pd(dx00,fscal,fix0);
424 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
425 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
427 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
428 _mm_mul_pd(dx00,fscal),
429 _mm_mul_pd(dy00,fscal),
430 _mm_mul_pd(dz00,fscal));
432 /* Inner loop uses 30 flops */
439 j_coord_offsetA = DIM*jnrA;
441 /* load j atom coordinates */
442 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
445 /* Calculate displacement vector */
446 dx00 = _mm_sub_pd(ix0,jx0);
447 dy00 = _mm_sub_pd(iy0,jy0);
448 dz00 = _mm_sub_pd(iz0,jz0);
450 /* Calculate squared distance and things based on it */
451 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
453 rinvsq00 = avx128fma_inv_d(rsq00);
455 /* Load parameters for j particles */
456 vdwjidx0A = 2*vdwtype[jnrA+0];
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
462 /* Compute parameters for interactions between i and j atoms */
463 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
465 /* LENNARD-JONES DISPERSION/REPULSION */
467 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
468 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
472 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
474 /* Update vectorial force */
475 fix0 = _mm_macc_pd(dx00,fscal,fix0);
476 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
477 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
479 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
480 _mm_mul_pd(dx00,fscal),
481 _mm_mul_pd(dy00,fscal),
482 _mm_mul_pd(dz00,fscal));
484 /* Inner loop uses 30 flops */
487 /* End of innermost loop */
489 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
490 f+i_coord_offset,fshift+i_shift_offset);
492 /* Increment number of inner iterations */
493 inneriter += j_index_end - j_index_start;
495 /* Outer loop uses 6 flops */
498 /* Increment number of outer iterations */
501 /* Update outer/inner flops */
503 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);