2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: None
55 * VdW interaction: LennardJones
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_avx_128_fma_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 int vdwjidx0A,vdwjidx0B;
85 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
86 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
91 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
92 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
93 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
94 real rswitch_scalar,d_scalar;
95 __m128d dummy_mask,cutoff_mask;
96 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
97 __m128d one = _mm_set1_pd(1.0);
98 __m128d two = _mm_set1_pd(2.0);
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 rcutoff_scalar = fr->rvdw;
115 rcutoff = _mm_set1_pd(rcutoff_scalar);
116 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
118 rswitch_scalar = fr->rvdw_switch;
119 rswitch = _mm_set1_pd(rswitch_scalar);
120 /* Setup switch parameters */
121 d_scalar = rcutoff_scalar-rswitch_scalar;
122 d = _mm_set1_pd(d_scalar);
123 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
124 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
125 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
126 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
127 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
128 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
130 /* Avoid stupid compiler warnings */
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
155 fix0 = _mm_setzero_pd();
156 fiy0 = _mm_setzero_pd();
157 fiz0 = _mm_setzero_pd();
159 /* Load parameters for i particles */
160 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
162 /* Reset potential sums */
163 vvdwsum = _mm_setzero_pd();
165 /* Start inner kernel loop */
166 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
169 /* Get j neighbor index, and coordinate index */
172 j_coord_offsetA = DIM*jnrA;
173 j_coord_offsetB = DIM*jnrB;
175 /* load j atom coordinates */
176 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
179 /* Calculate displacement vector */
180 dx00 = _mm_sub_pd(ix0,jx0);
181 dy00 = _mm_sub_pd(iy0,jy0);
182 dz00 = _mm_sub_pd(iz0,jz0);
184 /* Calculate squared distance and things based on it */
185 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
187 rinv00 = gmx_mm_invsqrt_pd(rsq00);
189 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
191 /* Load parameters for j particles */
192 vdwjidx0A = 2*vdwtype[jnrA+0];
193 vdwjidx0B = 2*vdwtype[jnrB+0];
195 /**************************
196 * CALCULATE INTERACTIONS *
197 **************************/
199 if (gmx_mm_any_lt(rsq00,rcutoff2))
202 r00 = _mm_mul_pd(rsq00,rinv00);
204 /* Compute parameters for interactions between i and j atoms */
205 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
206 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
208 /* LENNARD-JONES DISPERSION/REPULSION */
210 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
211 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
212 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
213 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
214 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
216 d = _mm_sub_pd(r00,rswitch);
217 d = _mm_max_pd(d,_mm_setzero_pd());
218 d2 = _mm_mul_pd(d,d);
219 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
221 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
223 /* Evaluate switch function */
224 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
225 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
226 vvdw = _mm_mul_pd(vvdw,sw);
227 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
229 /* Update potential sum for this i atom from the interaction with this j atom. */
230 vvdw = _mm_and_pd(vvdw,cutoff_mask);
231 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
235 fscal = _mm_and_pd(fscal,cutoff_mask);
237 /* Update vectorial force */
238 fix0 = _mm_macc_pd(dx00,fscal,fix0);
239 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
240 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
242 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
243 _mm_mul_pd(dx00,fscal),
244 _mm_mul_pd(dy00,fscal),
245 _mm_mul_pd(dz00,fscal));
249 /* Inner loop uses 62 flops */
256 j_coord_offsetA = DIM*jnrA;
258 /* load j atom coordinates */
259 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
262 /* Calculate displacement vector */
263 dx00 = _mm_sub_pd(ix0,jx0);
264 dy00 = _mm_sub_pd(iy0,jy0);
265 dz00 = _mm_sub_pd(iz0,jz0);
267 /* Calculate squared distance and things based on it */
268 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
270 rinv00 = gmx_mm_invsqrt_pd(rsq00);
272 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
274 /* Load parameters for j particles */
275 vdwjidx0A = 2*vdwtype[jnrA+0];
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
281 if (gmx_mm_any_lt(rsq00,rcutoff2))
284 r00 = _mm_mul_pd(rsq00,rinv00);
286 /* Compute parameters for interactions between i and j atoms */
287 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
289 /* LENNARD-JONES DISPERSION/REPULSION */
291 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
292 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
293 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
294 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
295 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
297 d = _mm_sub_pd(r00,rswitch);
298 d = _mm_max_pd(d,_mm_setzero_pd());
299 d2 = _mm_mul_pd(d,d);
300 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
302 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
304 /* Evaluate switch function */
305 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
306 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
307 vvdw = _mm_mul_pd(vvdw,sw);
308 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
310 /* Update potential sum for this i atom from the interaction with this j atom. */
311 vvdw = _mm_and_pd(vvdw,cutoff_mask);
312 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
313 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
317 fscal = _mm_and_pd(fscal,cutoff_mask);
319 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
321 /* Update vectorial force */
322 fix0 = _mm_macc_pd(dx00,fscal,fix0);
323 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
324 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
326 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
327 _mm_mul_pd(dx00,fscal),
328 _mm_mul_pd(dy00,fscal),
329 _mm_mul_pd(dz00,fscal));
333 /* Inner loop uses 62 flops */
336 /* End of innermost loop */
338 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
339 f+i_coord_offset,fshift+i_shift_offset);
342 /* Update potential energies */
343 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
345 /* Increment number of inner iterations */
346 inneriter += j_index_end - j_index_start;
348 /* Outer loop uses 7 flops */
351 /* Increment number of outer iterations */
354 /* Update outer/inner flops */
356 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*62);
359 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
360 * Electrostatics interaction: None
361 * VdW interaction: LennardJones
362 * Geometry: Particle-Particle
363 * Calculate force/pot: Force
366 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
367 (t_nblist * gmx_restrict nlist,
368 rvec * gmx_restrict xx,
369 rvec * gmx_restrict ff,
370 t_forcerec * gmx_restrict fr,
371 t_mdatoms * gmx_restrict mdatoms,
372 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
373 t_nrnb * gmx_restrict nrnb)
375 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
376 * just 0 for non-waters.
377 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
378 * jnr indices corresponding to data put in the four positions in the SIMD register.
380 int i_shift_offset,i_coord_offset,outeriter,inneriter;
381 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
383 int j_coord_offsetA,j_coord_offsetB;
384 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
386 real *shiftvec,*fshift,*x,*f;
387 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
389 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
390 int vdwjidx0A,vdwjidx0B;
391 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
392 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
394 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
397 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
398 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
399 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
400 real rswitch_scalar,d_scalar;
401 __m128d dummy_mask,cutoff_mask;
402 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
403 __m128d one = _mm_set1_pd(1.0);
404 __m128d two = _mm_set1_pd(2.0);
410 jindex = nlist->jindex;
412 shiftidx = nlist->shift;
414 shiftvec = fr->shift_vec[0];
415 fshift = fr->fshift[0];
416 nvdwtype = fr->ntype;
418 vdwtype = mdatoms->typeA;
420 rcutoff_scalar = fr->rvdw;
421 rcutoff = _mm_set1_pd(rcutoff_scalar);
422 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
424 rswitch_scalar = fr->rvdw_switch;
425 rswitch = _mm_set1_pd(rswitch_scalar);
426 /* Setup switch parameters */
427 d_scalar = rcutoff_scalar-rswitch_scalar;
428 d = _mm_set1_pd(d_scalar);
429 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
430 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
431 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
432 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
433 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
434 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
436 /* Avoid stupid compiler warnings */
444 /* Start outer loop over neighborlists */
445 for(iidx=0; iidx<nri; iidx++)
447 /* Load shift vector for this list */
448 i_shift_offset = DIM*shiftidx[iidx];
450 /* Load limits for loop over neighbors */
451 j_index_start = jindex[iidx];
452 j_index_end = jindex[iidx+1];
454 /* Get outer coordinate index */
456 i_coord_offset = DIM*inr;
458 /* Load i particle coords and add shift vector */
459 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
461 fix0 = _mm_setzero_pd();
462 fiy0 = _mm_setzero_pd();
463 fiz0 = _mm_setzero_pd();
465 /* Load parameters for i particles */
466 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
468 /* Start inner kernel loop */
469 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
472 /* Get j neighbor index, and coordinate index */
475 j_coord_offsetA = DIM*jnrA;
476 j_coord_offsetB = DIM*jnrB;
478 /* load j atom coordinates */
479 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
482 /* Calculate displacement vector */
483 dx00 = _mm_sub_pd(ix0,jx0);
484 dy00 = _mm_sub_pd(iy0,jy0);
485 dz00 = _mm_sub_pd(iz0,jz0);
487 /* Calculate squared distance and things based on it */
488 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
490 rinv00 = gmx_mm_invsqrt_pd(rsq00);
492 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
494 /* Load parameters for j particles */
495 vdwjidx0A = 2*vdwtype[jnrA+0];
496 vdwjidx0B = 2*vdwtype[jnrB+0];
498 /**************************
499 * CALCULATE INTERACTIONS *
500 **************************/
502 if (gmx_mm_any_lt(rsq00,rcutoff2))
505 r00 = _mm_mul_pd(rsq00,rinv00);
507 /* Compute parameters for interactions between i and j atoms */
508 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
509 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
511 /* LENNARD-JONES DISPERSION/REPULSION */
513 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
514 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
515 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
516 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
517 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
519 d = _mm_sub_pd(r00,rswitch);
520 d = _mm_max_pd(d,_mm_setzero_pd());
521 d2 = _mm_mul_pd(d,d);
522 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
524 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
526 /* Evaluate switch function */
527 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
528 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
529 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
533 fscal = _mm_and_pd(fscal,cutoff_mask);
535 /* Update vectorial force */
536 fix0 = _mm_macc_pd(dx00,fscal,fix0);
537 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
538 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
540 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
541 _mm_mul_pd(dx00,fscal),
542 _mm_mul_pd(dy00,fscal),
543 _mm_mul_pd(dz00,fscal));
547 /* Inner loop uses 59 flops */
554 j_coord_offsetA = DIM*jnrA;
556 /* load j atom coordinates */
557 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
560 /* Calculate displacement vector */
561 dx00 = _mm_sub_pd(ix0,jx0);
562 dy00 = _mm_sub_pd(iy0,jy0);
563 dz00 = _mm_sub_pd(iz0,jz0);
565 /* Calculate squared distance and things based on it */
566 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
568 rinv00 = gmx_mm_invsqrt_pd(rsq00);
570 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
572 /* Load parameters for j particles */
573 vdwjidx0A = 2*vdwtype[jnrA+0];
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
579 if (gmx_mm_any_lt(rsq00,rcutoff2))
582 r00 = _mm_mul_pd(rsq00,rinv00);
584 /* Compute parameters for interactions between i and j atoms */
585 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
587 /* LENNARD-JONES DISPERSION/REPULSION */
589 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
590 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
591 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
592 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
593 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
595 d = _mm_sub_pd(r00,rswitch);
596 d = _mm_max_pd(d,_mm_setzero_pd());
597 d2 = _mm_mul_pd(d,d);
598 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
600 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
602 /* Evaluate switch function */
603 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
604 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
605 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
609 fscal = _mm_and_pd(fscal,cutoff_mask);
611 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
613 /* Update vectorial force */
614 fix0 = _mm_macc_pd(dx00,fscal,fix0);
615 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
616 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
618 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
619 _mm_mul_pd(dx00,fscal),
620 _mm_mul_pd(dy00,fscal),
621 _mm_mul_pd(dz00,fscal));
625 /* Inner loop uses 59 flops */
628 /* End of innermost loop */
630 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
631 f+i_coord_offset,fshift+i_shift_offset);
633 /* Increment number of inner iterations */
634 inneriter += j_index_end - j_index_start;
636 /* Outer loop uses 6 flops */
639 /* Increment number of outer iterations */
642 /* Update outer/inner flops */
644 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*59);