2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017,2018, 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_VdwLJSh_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_VdwLJSh_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 rcutoff_scalar = fr->ic->rvdw;
110 rcutoff = _mm_set1_pd(rcutoff_scalar);
111 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
113 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
114 rvdw = _mm_set1_pd(fr->ic->rvdw);
116 /* Avoid stupid compiler warnings */
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
141 fix0 = _mm_setzero_pd();
142 fiy0 = _mm_setzero_pd();
143 fiz0 = _mm_setzero_pd();
145 /* Load parameters for i particles */
146 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
148 /* Reset potential sums */
149 vvdwsum = _mm_setzero_pd();
151 /* Start inner kernel loop */
152 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
155 /* Get j neighbor index, and coordinate index */
158 j_coord_offsetA = DIM*jnrA;
159 j_coord_offsetB = DIM*jnrB;
161 /* load j atom coordinates */
162 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
165 /* Calculate displacement vector */
166 dx00 = _mm_sub_pd(ix0,jx0);
167 dy00 = _mm_sub_pd(iy0,jy0);
168 dz00 = _mm_sub_pd(iz0,jz0);
170 /* Calculate squared distance and things based on it */
171 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
173 rinvsq00 = avx128fma_inv_d(rsq00);
175 /* Load parameters for j particles */
176 vdwjidx0A = 2*vdwtype[jnrA+0];
177 vdwjidx0B = 2*vdwtype[jnrB+0];
179 /**************************
180 * CALCULATE INTERACTIONS *
181 **************************/
183 if (gmx_mm_any_lt(rsq00,rcutoff2))
186 /* Compute parameters for interactions between i and j atoms */
187 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
188 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
190 /* LENNARD-JONES DISPERSION/REPULSION */
192 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
193 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
194 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
195 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
196 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
197 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
199 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
201 /* Update potential sum for this i atom from the interaction with this j atom. */
202 vvdw = _mm_and_pd(vvdw,cutoff_mask);
203 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
207 fscal = _mm_and_pd(fscal,cutoff_mask);
209 /* Update vectorial force */
210 fix0 = _mm_macc_pd(dx00,fscal,fix0);
211 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
212 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
214 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
215 _mm_mul_pd(dx00,fscal),
216 _mm_mul_pd(dy00,fscal),
217 _mm_mul_pd(dz00,fscal));
221 /* Inner loop uses 44 flops */
228 j_coord_offsetA = DIM*jnrA;
230 /* load j atom coordinates */
231 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
234 /* Calculate displacement vector */
235 dx00 = _mm_sub_pd(ix0,jx0);
236 dy00 = _mm_sub_pd(iy0,jy0);
237 dz00 = _mm_sub_pd(iz0,jz0);
239 /* Calculate squared distance and things based on it */
240 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
242 rinvsq00 = avx128fma_inv_d(rsq00);
244 /* Load parameters for j particles */
245 vdwjidx0A = 2*vdwtype[jnrA+0];
247 /**************************
248 * CALCULATE INTERACTIONS *
249 **************************/
251 if (gmx_mm_any_lt(rsq00,rcutoff2))
254 /* Compute parameters for interactions between i and j atoms */
255 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
257 /* LENNARD-JONES DISPERSION/REPULSION */
259 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
260 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
261 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
262 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
263 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
264 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
266 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
268 /* Update potential sum for this i atom from the interaction with this j atom. */
269 vvdw = _mm_and_pd(vvdw,cutoff_mask);
270 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
271 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
275 fscal = _mm_and_pd(fscal,cutoff_mask);
277 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
279 /* Update vectorial force */
280 fix0 = _mm_macc_pd(dx00,fscal,fix0);
281 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
282 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
284 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
285 _mm_mul_pd(dx00,fscal),
286 _mm_mul_pd(dy00,fscal),
287 _mm_mul_pd(dz00,fscal));
291 /* Inner loop uses 44 flops */
294 /* End of innermost loop */
296 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
297 f+i_coord_offset,fshift+i_shift_offset);
300 /* Update potential energies */
301 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
303 /* Increment number of inner iterations */
304 inneriter += j_index_end - j_index_start;
306 /* Outer loop uses 7 flops */
309 /* Increment number of outer iterations */
312 /* Update outer/inner flops */
314 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*44);
317 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_128_fma_double
318 * Electrostatics interaction: None
319 * VdW interaction: LennardJones
320 * Geometry: Particle-Particle
321 * Calculate force/pot: Force
324 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_128_fma_double
325 (t_nblist * gmx_restrict nlist,
326 rvec * gmx_restrict xx,
327 rvec * gmx_restrict ff,
328 struct t_forcerec * gmx_restrict fr,
329 t_mdatoms * gmx_restrict mdatoms,
330 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
331 t_nrnb * gmx_restrict nrnb)
333 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
334 * just 0 for non-waters.
335 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
336 * jnr indices corresponding to data put in the four positions in the SIMD register.
338 int i_shift_offset,i_coord_offset,outeriter,inneriter;
339 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
341 int j_coord_offsetA,j_coord_offsetB;
342 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
344 real *shiftvec,*fshift,*x,*f;
345 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
347 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
348 int vdwjidx0A,vdwjidx0B;
349 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
350 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
352 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
355 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
356 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
357 __m128d dummy_mask,cutoff_mask;
358 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
359 __m128d one = _mm_set1_pd(1.0);
360 __m128d two = _mm_set1_pd(2.0);
366 jindex = nlist->jindex;
368 shiftidx = nlist->shift;
370 shiftvec = fr->shift_vec[0];
371 fshift = fr->fshift[0];
372 nvdwtype = fr->ntype;
374 vdwtype = mdatoms->typeA;
376 rcutoff_scalar = fr->ic->rvdw;
377 rcutoff = _mm_set1_pd(rcutoff_scalar);
378 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
380 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
381 rvdw = _mm_set1_pd(fr->ic->rvdw);
383 /* Avoid stupid compiler warnings */
391 /* Start outer loop over neighborlists */
392 for(iidx=0; iidx<nri; iidx++)
394 /* Load shift vector for this list */
395 i_shift_offset = DIM*shiftidx[iidx];
397 /* Load limits for loop over neighbors */
398 j_index_start = jindex[iidx];
399 j_index_end = jindex[iidx+1];
401 /* Get outer coordinate index */
403 i_coord_offset = DIM*inr;
405 /* Load i particle coords and add shift vector */
406 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
408 fix0 = _mm_setzero_pd();
409 fiy0 = _mm_setzero_pd();
410 fiz0 = _mm_setzero_pd();
412 /* Load parameters for i particles */
413 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
415 /* Start inner kernel loop */
416 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
419 /* Get j neighbor index, and coordinate index */
422 j_coord_offsetA = DIM*jnrA;
423 j_coord_offsetB = DIM*jnrB;
425 /* load j atom coordinates */
426 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
429 /* Calculate displacement vector */
430 dx00 = _mm_sub_pd(ix0,jx0);
431 dy00 = _mm_sub_pd(iy0,jy0);
432 dz00 = _mm_sub_pd(iz0,jz0);
434 /* Calculate squared distance and things based on it */
435 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
437 rinvsq00 = avx128fma_inv_d(rsq00);
439 /* Load parameters for j particles */
440 vdwjidx0A = 2*vdwtype[jnrA+0];
441 vdwjidx0B = 2*vdwtype[jnrB+0];
443 /**************************
444 * CALCULATE INTERACTIONS *
445 **************************/
447 if (gmx_mm_any_lt(rsq00,rcutoff2))
450 /* Compute parameters for interactions between i and j atoms */
451 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
452 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
454 /* LENNARD-JONES DISPERSION/REPULSION */
456 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
457 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
459 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
463 fscal = _mm_and_pd(fscal,cutoff_mask);
465 /* Update vectorial force */
466 fix0 = _mm_macc_pd(dx00,fscal,fix0);
467 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
468 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
470 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
471 _mm_mul_pd(dx00,fscal),
472 _mm_mul_pd(dy00,fscal),
473 _mm_mul_pd(dz00,fscal));
477 /* Inner loop uses 33 flops */
484 j_coord_offsetA = DIM*jnrA;
486 /* load j atom coordinates */
487 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
490 /* Calculate displacement vector */
491 dx00 = _mm_sub_pd(ix0,jx0);
492 dy00 = _mm_sub_pd(iy0,jy0);
493 dz00 = _mm_sub_pd(iz0,jz0);
495 /* Calculate squared distance and things based on it */
496 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
498 rinvsq00 = avx128fma_inv_d(rsq00);
500 /* Load parameters for j particles */
501 vdwjidx0A = 2*vdwtype[jnrA+0];
503 /**************************
504 * CALCULATE INTERACTIONS *
505 **************************/
507 if (gmx_mm_any_lt(rsq00,rcutoff2))
510 /* Compute parameters for interactions between i and j atoms */
511 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
513 /* LENNARD-JONES DISPERSION/REPULSION */
515 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
516 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
518 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
522 fscal = _mm_and_pd(fscal,cutoff_mask);
524 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
526 /* Update vectorial force */
527 fix0 = _mm_macc_pd(dx00,fscal,fix0);
528 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
529 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
531 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
532 _mm_mul_pd(dx00,fscal),
533 _mm_mul_pd(dy00,fscal),
534 _mm_mul_pd(dz00,fscal));
538 /* Inner loop uses 33 flops */
541 /* End of innermost loop */
543 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
544 f+i_coord_offset,fshift+i_shift_offset);
546 /* Increment number of inner iterations */
547 inneriter += j_index_end - j_index_start;
549 /* Outer loop uses 6 flops */
552 /* Increment number of outer iterations */
555 /* Update outer/inner flops */
557 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*33);