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_VdwLJSw_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_VdwLJSw_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 rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
91 real rswitch_scalar,d_scalar;
92 __m128d dummy_mask,cutoff_mask;
93 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
94 __m128d one = _mm_set1_pd(1.0);
95 __m128d two = _mm_set1_pd(2.0);
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
107 nvdwtype = fr->ntype;
109 vdwtype = mdatoms->typeA;
111 rcutoff_scalar = fr->ic->rvdw;
112 rcutoff = _mm_set1_pd(rcutoff_scalar);
113 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
115 rswitch_scalar = fr->ic->rvdw_switch;
116 rswitch = _mm_set1_pd(rswitch_scalar);
117 /* Setup switch parameters */
118 d_scalar = rcutoff_scalar-rswitch_scalar;
119 d = _mm_set1_pd(d_scalar);
120 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
121 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
122 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
123 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
124 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
125 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
127 /* Avoid stupid compiler warnings */
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
141 /* Load limits for loop over neighbors */
142 j_index_start = jindex[iidx];
143 j_index_end = jindex[iidx+1];
145 /* Get outer coordinate index */
147 i_coord_offset = DIM*inr;
149 /* Load i particle coords and add shift vector */
150 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
152 fix0 = _mm_setzero_pd();
153 fiy0 = _mm_setzero_pd();
154 fiz0 = _mm_setzero_pd();
156 /* Load parameters for i particles */
157 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
159 /* Reset potential sums */
160 vvdwsum = _mm_setzero_pd();
162 /* Start inner kernel loop */
163 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
166 /* Get j neighbor index, and coordinate index */
169 j_coord_offsetA = DIM*jnrA;
170 j_coord_offsetB = DIM*jnrB;
172 /* load j atom coordinates */
173 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
176 /* Calculate displacement vector */
177 dx00 = _mm_sub_pd(ix0,jx0);
178 dy00 = _mm_sub_pd(iy0,jy0);
179 dz00 = _mm_sub_pd(iz0,jz0);
181 /* Calculate squared distance and things based on it */
182 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
184 rinv00 = avx128fma_invsqrt_d(rsq00);
186 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
188 /* Load parameters for j particles */
189 vdwjidx0A = 2*vdwtype[jnrA+0];
190 vdwjidx0B = 2*vdwtype[jnrB+0];
192 /**************************
193 * CALCULATE INTERACTIONS *
194 **************************/
196 if (gmx_mm_any_lt(rsq00,rcutoff2))
199 r00 = _mm_mul_pd(rsq00,rinv00);
201 /* Compute parameters for interactions between i and j atoms */
202 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
203 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
205 /* LENNARD-JONES DISPERSION/REPULSION */
207 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
208 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
209 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
210 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
211 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
213 d = _mm_sub_pd(r00,rswitch);
214 d = _mm_max_pd(d,_mm_setzero_pd());
215 d2 = _mm_mul_pd(d,d);
216 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
218 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
220 /* Evaluate switch function */
221 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
222 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
223 vvdw = _mm_mul_pd(vvdw,sw);
224 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
226 /* Update potential sum for this i atom from the interaction with this j atom. */
227 vvdw = _mm_and_pd(vvdw,cutoff_mask);
228 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
232 fscal = _mm_and_pd(fscal,cutoff_mask);
234 /* Update vectorial force */
235 fix0 = _mm_macc_pd(dx00,fscal,fix0);
236 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
237 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
239 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
240 _mm_mul_pd(dx00,fscal),
241 _mm_mul_pd(dy00,fscal),
242 _mm_mul_pd(dz00,fscal));
246 /* Inner loop uses 62 flops */
253 j_coord_offsetA = DIM*jnrA;
255 /* load j atom coordinates */
256 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
259 /* Calculate displacement vector */
260 dx00 = _mm_sub_pd(ix0,jx0);
261 dy00 = _mm_sub_pd(iy0,jy0);
262 dz00 = _mm_sub_pd(iz0,jz0);
264 /* Calculate squared distance and things based on it */
265 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
267 rinv00 = avx128fma_invsqrt_d(rsq00);
269 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
271 /* Load parameters for j particles */
272 vdwjidx0A = 2*vdwtype[jnrA+0];
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 if (gmx_mm_any_lt(rsq00,rcutoff2))
281 r00 = _mm_mul_pd(rsq00,rinv00);
283 /* Compute parameters for interactions between i and j atoms */
284 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
286 /* LENNARD-JONES DISPERSION/REPULSION */
288 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
289 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
290 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
291 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
292 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
294 d = _mm_sub_pd(r00,rswitch);
295 d = _mm_max_pd(d,_mm_setzero_pd());
296 d2 = _mm_mul_pd(d,d);
297 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
299 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
301 /* Evaluate switch function */
302 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
303 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
304 vvdw = _mm_mul_pd(vvdw,sw);
305 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
307 /* Update potential sum for this i atom from the interaction with this j atom. */
308 vvdw = _mm_and_pd(vvdw,cutoff_mask);
309 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
310 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
314 fscal = _mm_and_pd(fscal,cutoff_mask);
316 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
318 /* Update vectorial force */
319 fix0 = _mm_macc_pd(dx00,fscal,fix0);
320 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
321 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
323 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
324 _mm_mul_pd(dx00,fscal),
325 _mm_mul_pd(dy00,fscal),
326 _mm_mul_pd(dz00,fscal));
330 /* Inner loop uses 62 flops */
333 /* End of innermost loop */
335 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
336 f+i_coord_offset,fshift+i_shift_offset);
339 /* Update potential energies */
340 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
342 /* Increment number of inner iterations */
343 inneriter += j_index_end - j_index_start;
345 /* Outer loop uses 7 flops */
348 /* Increment number of outer iterations */
351 /* Update outer/inner flops */
353 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*62);
356 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
357 * Electrostatics interaction: None
358 * VdW interaction: LennardJones
359 * Geometry: Particle-Particle
360 * Calculate force/pot: Force
363 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
364 (t_nblist * gmx_restrict nlist,
365 rvec * gmx_restrict xx,
366 rvec * gmx_restrict ff,
367 struct t_forcerec * gmx_restrict fr,
368 t_mdatoms * gmx_restrict mdatoms,
369 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
370 t_nrnb * gmx_restrict nrnb)
372 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
373 * just 0 for non-waters.
374 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
375 * jnr indices corresponding to data put in the four positions in the SIMD register.
377 int i_shift_offset,i_coord_offset,outeriter,inneriter;
378 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
380 int j_coord_offsetA,j_coord_offsetB;
381 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
383 real *shiftvec,*fshift,*x,*f;
384 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
386 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
387 int vdwjidx0A,vdwjidx0B;
388 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
389 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
391 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
394 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
395 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
396 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
397 real rswitch_scalar,d_scalar;
398 __m128d dummy_mask,cutoff_mask;
399 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
400 __m128d one = _mm_set1_pd(1.0);
401 __m128d two = _mm_set1_pd(2.0);
407 jindex = nlist->jindex;
409 shiftidx = nlist->shift;
411 shiftvec = fr->shift_vec[0];
412 fshift = fr->fshift[0];
413 nvdwtype = fr->ntype;
415 vdwtype = mdatoms->typeA;
417 rcutoff_scalar = fr->ic->rvdw;
418 rcutoff = _mm_set1_pd(rcutoff_scalar);
419 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
421 rswitch_scalar = fr->ic->rvdw_switch;
422 rswitch = _mm_set1_pd(rswitch_scalar);
423 /* Setup switch parameters */
424 d_scalar = rcutoff_scalar-rswitch_scalar;
425 d = _mm_set1_pd(d_scalar);
426 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
427 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
428 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
429 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
430 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
431 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
433 /* Avoid stupid compiler warnings */
441 /* Start outer loop over neighborlists */
442 for(iidx=0; iidx<nri; iidx++)
444 /* Load shift vector for this list */
445 i_shift_offset = DIM*shiftidx[iidx];
447 /* Load limits for loop over neighbors */
448 j_index_start = jindex[iidx];
449 j_index_end = jindex[iidx+1];
451 /* Get outer coordinate index */
453 i_coord_offset = DIM*inr;
455 /* Load i particle coords and add shift vector */
456 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
458 fix0 = _mm_setzero_pd();
459 fiy0 = _mm_setzero_pd();
460 fiz0 = _mm_setzero_pd();
462 /* Load parameters for i particles */
463 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
465 /* Start inner kernel loop */
466 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
469 /* Get j neighbor index, and coordinate index */
472 j_coord_offsetA = DIM*jnrA;
473 j_coord_offsetB = DIM*jnrB;
475 /* load j atom coordinates */
476 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
479 /* Calculate displacement vector */
480 dx00 = _mm_sub_pd(ix0,jx0);
481 dy00 = _mm_sub_pd(iy0,jy0);
482 dz00 = _mm_sub_pd(iz0,jz0);
484 /* Calculate squared distance and things based on it */
485 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
487 rinv00 = avx128fma_invsqrt_d(rsq00);
489 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
491 /* Load parameters for j particles */
492 vdwjidx0A = 2*vdwtype[jnrA+0];
493 vdwjidx0B = 2*vdwtype[jnrB+0];
495 /**************************
496 * CALCULATE INTERACTIONS *
497 **************************/
499 if (gmx_mm_any_lt(rsq00,rcutoff2))
502 r00 = _mm_mul_pd(rsq00,rinv00);
504 /* Compute parameters for interactions between i and j atoms */
505 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
506 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
508 /* LENNARD-JONES DISPERSION/REPULSION */
510 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
511 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
512 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
513 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
514 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
516 d = _mm_sub_pd(r00,rswitch);
517 d = _mm_max_pd(d,_mm_setzero_pd());
518 d2 = _mm_mul_pd(d,d);
519 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
521 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
523 /* Evaluate switch function */
524 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
525 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
526 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
530 fscal = _mm_and_pd(fscal,cutoff_mask);
532 /* Update vectorial force */
533 fix0 = _mm_macc_pd(dx00,fscal,fix0);
534 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
535 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
537 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
538 _mm_mul_pd(dx00,fscal),
539 _mm_mul_pd(dy00,fscal),
540 _mm_mul_pd(dz00,fscal));
544 /* Inner loop uses 59 flops */
551 j_coord_offsetA = DIM*jnrA;
553 /* load j atom coordinates */
554 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
557 /* Calculate displacement vector */
558 dx00 = _mm_sub_pd(ix0,jx0);
559 dy00 = _mm_sub_pd(iy0,jy0);
560 dz00 = _mm_sub_pd(iz0,jz0);
562 /* Calculate squared distance and things based on it */
563 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
565 rinv00 = avx128fma_invsqrt_d(rsq00);
567 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
569 /* Load parameters for j particles */
570 vdwjidx0A = 2*vdwtype[jnrA+0];
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
576 if (gmx_mm_any_lt(rsq00,rcutoff2))
579 r00 = _mm_mul_pd(rsq00,rinv00);
581 /* Compute parameters for interactions between i and j atoms */
582 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
584 /* LENNARD-JONES DISPERSION/REPULSION */
586 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
587 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
588 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
589 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
590 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
592 d = _mm_sub_pd(r00,rswitch);
593 d = _mm_max_pd(d,_mm_setzero_pd());
594 d2 = _mm_mul_pd(d,d);
595 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
597 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
599 /* Evaluate switch function */
600 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
601 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
602 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
606 fscal = _mm_and_pd(fscal,cutoff_mask);
608 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
610 /* Update vectorial force */
611 fix0 = _mm_macc_pd(dx00,fscal,fix0);
612 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
613 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
615 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
616 _mm_mul_pd(dx00,fscal),
617 _mm_mul_pd(dy00,fscal),
618 _mm_mul_pd(dz00,fscal));
622 /* Inner loop uses 59 flops */
625 /* End of innermost loop */
627 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
628 f+i_coord_offset,fshift+i_shift_offset);
630 /* Increment number of inner iterations */
631 inneriter += j_index_end - j_index_start;
633 /* Outer loop uses 6 flops */
636 /* Increment number of outer iterations */
639 /* Update outer/inner flops */
641 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*59);