2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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 sse2_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "gromacs/simd/math_x86_sse2_double.h"
50 #include "kernelutil_x86_sse2_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_sse2_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_sse2_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_sub_pd( _mm_mul_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_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
221 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
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_sub_pd( _mm_mul_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 /* Calculate temporary vectorial force */
238 tx = _mm_mul_pd(fscal,dx00);
239 ty = _mm_mul_pd(fscal,dy00);
240 tz = _mm_mul_pd(fscal,dz00);
242 /* Update vectorial force */
243 fix0 = _mm_add_pd(fix0,tx);
244 fiy0 = _mm_add_pd(fiy0,ty);
245 fiz0 = _mm_add_pd(fiz0,tz);
247 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
251 /* Inner loop uses 59 flops */
258 j_coord_offsetA = DIM*jnrA;
260 /* load j atom coordinates */
261 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
264 /* Calculate displacement vector */
265 dx00 = _mm_sub_pd(ix0,jx0);
266 dy00 = _mm_sub_pd(iy0,jy0);
267 dz00 = _mm_sub_pd(iz0,jz0);
269 /* Calculate squared distance and things based on it */
270 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
272 rinv00 = gmx_mm_invsqrt_pd(rsq00);
274 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
276 /* Load parameters for j particles */
277 vdwjidx0A = 2*vdwtype[jnrA+0];
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
283 if (gmx_mm_any_lt(rsq00,rcutoff2))
286 r00 = _mm_mul_pd(rsq00,rinv00);
288 /* Compute parameters for interactions between i and j atoms */
289 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
291 /* LENNARD-JONES DISPERSION/REPULSION */
293 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
294 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
295 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
296 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
297 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
299 d = _mm_sub_pd(r00,rswitch);
300 d = _mm_max_pd(d,_mm_setzero_pd());
301 d2 = _mm_mul_pd(d,d);
302 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
304 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
306 /* Evaluate switch function */
307 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
308 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
309 vvdw = _mm_mul_pd(vvdw,sw);
310 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
312 /* Update potential sum for this i atom from the interaction with this j atom. */
313 vvdw = _mm_and_pd(vvdw,cutoff_mask);
314 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
315 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
319 fscal = _mm_and_pd(fscal,cutoff_mask);
321 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
323 /* Calculate temporary vectorial force */
324 tx = _mm_mul_pd(fscal,dx00);
325 ty = _mm_mul_pd(fscal,dy00);
326 tz = _mm_mul_pd(fscal,dz00);
328 /* Update vectorial force */
329 fix0 = _mm_add_pd(fix0,tx);
330 fiy0 = _mm_add_pd(fiy0,ty);
331 fiz0 = _mm_add_pd(fiz0,tz);
333 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
337 /* Inner loop uses 59 flops */
340 /* End of innermost loop */
342 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
343 f+i_coord_offset,fshift+i_shift_offset);
346 /* Update potential energies */
347 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
349 /* Increment number of inner iterations */
350 inneriter += j_index_end - j_index_start;
352 /* Outer loop uses 7 flops */
355 /* Increment number of outer iterations */
358 /* Update outer/inner flops */
360 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*59);
363 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse2_double
364 * Electrostatics interaction: None
365 * VdW interaction: LennardJones
366 * Geometry: Particle-Particle
367 * Calculate force/pot: Force
370 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse2_double
371 (t_nblist * gmx_restrict nlist,
372 rvec * gmx_restrict xx,
373 rvec * gmx_restrict ff,
374 t_forcerec * gmx_restrict fr,
375 t_mdatoms * gmx_restrict mdatoms,
376 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
377 t_nrnb * gmx_restrict nrnb)
379 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
380 * just 0 for non-waters.
381 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
382 * jnr indices corresponding to data put in the four positions in the SIMD register.
384 int i_shift_offset,i_coord_offset,outeriter,inneriter;
385 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
387 int j_coord_offsetA,j_coord_offsetB;
388 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
390 real *shiftvec,*fshift,*x,*f;
391 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
393 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
394 int vdwjidx0A,vdwjidx0B;
395 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
396 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
398 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
401 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
402 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
403 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
404 real rswitch_scalar,d_scalar;
405 __m128d dummy_mask,cutoff_mask;
406 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
407 __m128d one = _mm_set1_pd(1.0);
408 __m128d two = _mm_set1_pd(2.0);
414 jindex = nlist->jindex;
416 shiftidx = nlist->shift;
418 shiftvec = fr->shift_vec[0];
419 fshift = fr->fshift[0];
420 nvdwtype = fr->ntype;
422 vdwtype = mdatoms->typeA;
424 rcutoff_scalar = fr->rvdw;
425 rcutoff = _mm_set1_pd(rcutoff_scalar);
426 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
428 rswitch_scalar = fr->rvdw_switch;
429 rswitch = _mm_set1_pd(rswitch_scalar);
430 /* Setup switch parameters */
431 d_scalar = rcutoff_scalar-rswitch_scalar;
432 d = _mm_set1_pd(d_scalar);
433 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
434 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
435 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
436 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
437 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
438 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
440 /* Avoid stupid compiler warnings */
448 /* Start outer loop over neighborlists */
449 for(iidx=0; iidx<nri; iidx++)
451 /* Load shift vector for this list */
452 i_shift_offset = DIM*shiftidx[iidx];
454 /* Load limits for loop over neighbors */
455 j_index_start = jindex[iidx];
456 j_index_end = jindex[iidx+1];
458 /* Get outer coordinate index */
460 i_coord_offset = DIM*inr;
462 /* Load i particle coords and add shift vector */
463 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
465 fix0 = _mm_setzero_pd();
466 fiy0 = _mm_setzero_pd();
467 fiz0 = _mm_setzero_pd();
469 /* Load parameters for i particles */
470 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
472 /* Start inner kernel loop */
473 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
476 /* Get j neighbor index, and coordinate index */
479 j_coord_offsetA = DIM*jnrA;
480 j_coord_offsetB = DIM*jnrB;
482 /* load j atom coordinates */
483 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
486 /* Calculate displacement vector */
487 dx00 = _mm_sub_pd(ix0,jx0);
488 dy00 = _mm_sub_pd(iy0,jy0);
489 dz00 = _mm_sub_pd(iz0,jz0);
491 /* Calculate squared distance and things based on it */
492 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
494 rinv00 = gmx_mm_invsqrt_pd(rsq00);
496 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
498 /* Load parameters for j particles */
499 vdwjidx0A = 2*vdwtype[jnrA+0];
500 vdwjidx0B = 2*vdwtype[jnrB+0];
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
506 if (gmx_mm_any_lt(rsq00,rcutoff2))
509 r00 = _mm_mul_pd(rsq00,rinv00);
511 /* Compute parameters for interactions between i and j atoms */
512 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
513 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
515 /* LENNARD-JONES DISPERSION/REPULSION */
517 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
518 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
519 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
520 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
521 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
523 d = _mm_sub_pd(r00,rswitch);
524 d = _mm_max_pd(d,_mm_setzero_pd());
525 d2 = _mm_mul_pd(d,d);
526 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
528 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
530 /* Evaluate switch function */
531 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
532 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
533 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
537 fscal = _mm_and_pd(fscal,cutoff_mask);
539 /* Calculate temporary vectorial force */
540 tx = _mm_mul_pd(fscal,dx00);
541 ty = _mm_mul_pd(fscal,dy00);
542 tz = _mm_mul_pd(fscal,dz00);
544 /* Update vectorial force */
545 fix0 = _mm_add_pd(fix0,tx);
546 fiy0 = _mm_add_pd(fiy0,ty);
547 fiz0 = _mm_add_pd(fiz0,tz);
549 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
553 /* Inner loop uses 56 flops */
560 j_coord_offsetA = DIM*jnrA;
562 /* load j atom coordinates */
563 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
566 /* Calculate displacement vector */
567 dx00 = _mm_sub_pd(ix0,jx0);
568 dy00 = _mm_sub_pd(iy0,jy0);
569 dz00 = _mm_sub_pd(iz0,jz0);
571 /* Calculate squared distance and things based on it */
572 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
574 rinv00 = gmx_mm_invsqrt_pd(rsq00);
576 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
578 /* Load parameters for j particles */
579 vdwjidx0A = 2*vdwtype[jnrA+0];
581 /**************************
582 * CALCULATE INTERACTIONS *
583 **************************/
585 if (gmx_mm_any_lt(rsq00,rcutoff2))
588 r00 = _mm_mul_pd(rsq00,rinv00);
590 /* Compute parameters for interactions between i and j atoms */
591 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
593 /* LENNARD-JONES DISPERSION/REPULSION */
595 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
596 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
597 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
598 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
599 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
601 d = _mm_sub_pd(r00,rswitch);
602 d = _mm_max_pd(d,_mm_setzero_pd());
603 d2 = _mm_mul_pd(d,d);
604 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
606 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
608 /* Evaluate switch function */
609 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
610 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
611 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
615 fscal = _mm_and_pd(fscal,cutoff_mask);
617 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
619 /* Calculate temporary vectorial force */
620 tx = _mm_mul_pd(fscal,dx00);
621 ty = _mm_mul_pd(fscal,dy00);
622 tz = _mm_mul_pd(fscal,dz00);
624 /* Update vectorial force */
625 fix0 = _mm_add_pd(fix0,tx);
626 fiy0 = _mm_add_pd(fiy0,ty);
627 fiz0 = _mm_add_pd(fiz0,tz);
629 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
633 /* Inner loop uses 56 flops */
636 /* End of innermost loop */
638 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
639 f+i_coord_offset,fshift+i_shift_offset);
641 /* Increment number of inner iterations */
642 inneriter += j_index_end - j_index_start;
644 /* Outer loop uses 6 flops */
647 /* Increment number of outer iterations */
650 /* Update outer/inner flops */
652 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*56);