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 sse4_1_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse4_1_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_sse4_1_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_sse4_1_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 = sse41_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_sub_pd( _mm_mul_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_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
218 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
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_sub_pd( _mm_mul_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 /* Calculate temporary vectorial force */
235 tx = _mm_mul_pd(fscal,dx00);
236 ty = _mm_mul_pd(fscal,dy00);
237 tz = _mm_mul_pd(fscal,dz00);
239 /* Update vectorial force */
240 fix0 = _mm_add_pd(fix0,tx);
241 fiy0 = _mm_add_pd(fiy0,ty);
242 fiz0 = _mm_add_pd(fiz0,tz);
244 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
248 /* Inner loop uses 59 flops */
255 j_coord_offsetA = DIM*jnrA;
257 /* load j atom coordinates */
258 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
261 /* Calculate displacement vector */
262 dx00 = _mm_sub_pd(ix0,jx0);
263 dy00 = _mm_sub_pd(iy0,jy0);
264 dz00 = _mm_sub_pd(iz0,jz0);
266 /* Calculate squared distance and things based on it */
267 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
269 rinv00 = sse41_invsqrt_d(rsq00);
271 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
273 /* Load parameters for j particles */
274 vdwjidx0A = 2*vdwtype[jnrA+0];
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
280 if (gmx_mm_any_lt(rsq00,rcutoff2))
283 r00 = _mm_mul_pd(rsq00,rinv00);
285 /* Compute parameters for interactions between i and j atoms */
286 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
288 /* LENNARD-JONES DISPERSION/REPULSION */
290 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
291 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
292 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
293 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
294 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
296 d = _mm_sub_pd(r00,rswitch);
297 d = _mm_max_pd(d,_mm_setzero_pd());
298 d2 = _mm_mul_pd(d,d);
299 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)))))));
301 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
303 /* Evaluate switch function */
304 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
305 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
306 vvdw = _mm_mul_pd(vvdw,sw);
307 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
309 /* Update potential sum for this i atom from the interaction with this j atom. */
310 vvdw = _mm_and_pd(vvdw,cutoff_mask);
311 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
312 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
316 fscal = _mm_and_pd(fscal,cutoff_mask);
318 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
320 /* Calculate temporary vectorial force */
321 tx = _mm_mul_pd(fscal,dx00);
322 ty = _mm_mul_pd(fscal,dy00);
323 tz = _mm_mul_pd(fscal,dz00);
325 /* Update vectorial force */
326 fix0 = _mm_add_pd(fix0,tx);
327 fiy0 = _mm_add_pd(fiy0,ty);
328 fiz0 = _mm_add_pd(fiz0,tz);
330 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
334 /* Inner loop uses 59 flops */
337 /* End of innermost loop */
339 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
340 f+i_coord_offset,fshift+i_shift_offset);
343 /* Update potential energies */
344 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
346 /* Increment number of inner iterations */
347 inneriter += j_index_end - j_index_start;
349 /* Outer loop uses 7 flops */
352 /* Increment number of outer iterations */
355 /* Update outer/inner flops */
357 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*59);
360 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse4_1_double
361 * Electrostatics interaction: None
362 * VdW interaction: LennardJones
363 * Geometry: Particle-Particle
364 * Calculate force/pot: Force
367 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse4_1_double
368 (t_nblist * gmx_restrict nlist,
369 rvec * gmx_restrict xx,
370 rvec * gmx_restrict ff,
371 struct t_forcerec * gmx_restrict fr,
372 t_mdatoms * gmx_restrict mdatoms,
373 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
374 t_nrnb * gmx_restrict nrnb)
376 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
377 * just 0 for non-waters.
378 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
379 * jnr indices corresponding to data put in the four positions in the SIMD register.
381 int i_shift_offset,i_coord_offset,outeriter,inneriter;
382 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
384 int j_coord_offsetA,j_coord_offsetB;
385 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
387 real *shiftvec,*fshift,*x,*f;
388 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
390 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
391 int vdwjidx0A,vdwjidx0B;
392 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
393 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
395 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
398 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
399 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
400 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
401 real rswitch_scalar,d_scalar;
402 __m128d dummy_mask,cutoff_mask;
403 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
404 __m128d one = _mm_set1_pd(1.0);
405 __m128d two = _mm_set1_pd(2.0);
411 jindex = nlist->jindex;
413 shiftidx = nlist->shift;
415 shiftvec = fr->shift_vec[0];
416 fshift = fr->fshift[0];
417 nvdwtype = fr->ntype;
419 vdwtype = mdatoms->typeA;
421 rcutoff_scalar = fr->ic->rvdw;
422 rcutoff = _mm_set1_pd(rcutoff_scalar);
423 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
425 rswitch_scalar = fr->ic->rvdw_switch;
426 rswitch = _mm_set1_pd(rswitch_scalar);
427 /* Setup switch parameters */
428 d_scalar = rcutoff_scalar-rswitch_scalar;
429 d = _mm_set1_pd(d_scalar);
430 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
431 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
432 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
433 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
434 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
435 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
437 /* Avoid stupid compiler warnings */
445 /* Start outer loop over neighborlists */
446 for(iidx=0; iidx<nri; iidx++)
448 /* Load shift vector for this list */
449 i_shift_offset = DIM*shiftidx[iidx];
451 /* Load limits for loop over neighbors */
452 j_index_start = jindex[iidx];
453 j_index_end = jindex[iidx+1];
455 /* Get outer coordinate index */
457 i_coord_offset = DIM*inr;
459 /* Load i particle coords and add shift vector */
460 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
462 fix0 = _mm_setzero_pd();
463 fiy0 = _mm_setzero_pd();
464 fiz0 = _mm_setzero_pd();
466 /* Load parameters for i particles */
467 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
469 /* Start inner kernel loop */
470 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
473 /* Get j neighbor index, and coordinate index */
476 j_coord_offsetA = DIM*jnrA;
477 j_coord_offsetB = DIM*jnrB;
479 /* load j atom coordinates */
480 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
483 /* Calculate displacement vector */
484 dx00 = _mm_sub_pd(ix0,jx0);
485 dy00 = _mm_sub_pd(iy0,jy0);
486 dz00 = _mm_sub_pd(iz0,jz0);
488 /* Calculate squared distance and things based on it */
489 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
491 rinv00 = sse41_invsqrt_d(rsq00);
493 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
495 /* Load parameters for j particles */
496 vdwjidx0A = 2*vdwtype[jnrA+0];
497 vdwjidx0B = 2*vdwtype[jnrB+0];
499 /**************************
500 * CALCULATE INTERACTIONS *
501 **************************/
503 if (gmx_mm_any_lt(rsq00,rcutoff2))
506 r00 = _mm_mul_pd(rsq00,rinv00);
508 /* Compute parameters for interactions between i and j atoms */
509 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
510 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
512 /* LENNARD-JONES DISPERSION/REPULSION */
514 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
515 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
516 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
517 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
518 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
520 d = _mm_sub_pd(r00,rswitch);
521 d = _mm_max_pd(d,_mm_setzero_pd());
522 d2 = _mm_mul_pd(d,d);
523 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)))))));
525 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
527 /* Evaluate switch function */
528 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
529 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
530 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
534 fscal = _mm_and_pd(fscal,cutoff_mask);
536 /* Calculate temporary vectorial force */
537 tx = _mm_mul_pd(fscal,dx00);
538 ty = _mm_mul_pd(fscal,dy00);
539 tz = _mm_mul_pd(fscal,dz00);
541 /* Update vectorial force */
542 fix0 = _mm_add_pd(fix0,tx);
543 fiy0 = _mm_add_pd(fiy0,ty);
544 fiz0 = _mm_add_pd(fiz0,tz);
546 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
550 /* Inner loop uses 56 flops */
557 j_coord_offsetA = DIM*jnrA;
559 /* load j atom coordinates */
560 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
563 /* Calculate displacement vector */
564 dx00 = _mm_sub_pd(ix0,jx0);
565 dy00 = _mm_sub_pd(iy0,jy0);
566 dz00 = _mm_sub_pd(iz0,jz0);
568 /* Calculate squared distance and things based on it */
569 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
571 rinv00 = sse41_invsqrt_d(rsq00);
573 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
575 /* Load parameters for j particles */
576 vdwjidx0A = 2*vdwtype[jnrA+0];
578 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
582 if (gmx_mm_any_lt(rsq00,rcutoff2))
585 r00 = _mm_mul_pd(rsq00,rinv00);
587 /* Compute parameters for interactions between i and j atoms */
588 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
590 /* LENNARD-JONES DISPERSION/REPULSION */
592 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
593 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
594 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
595 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
596 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
598 d = _mm_sub_pd(r00,rswitch);
599 d = _mm_max_pd(d,_mm_setzero_pd());
600 d2 = _mm_mul_pd(d,d);
601 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)))))));
603 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
605 /* Evaluate switch function */
606 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
607 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
608 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
612 fscal = _mm_and_pd(fscal,cutoff_mask);
614 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
616 /* Calculate temporary vectorial force */
617 tx = _mm_mul_pd(fscal,dx00);
618 ty = _mm_mul_pd(fscal,dy00);
619 tz = _mm_mul_pd(fscal,dz00);
621 /* Update vectorial force */
622 fix0 = _mm_add_pd(fix0,tx);
623 fiy0 = _mm_add_pd(fiy0,ty);
624 fiz0 = _mm_add_pd(fiz0,tz);
626 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
630 /* Inner loop uses 56 flops */
633 /* End of innermost loop */
635 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
636 f+i_coord_offset,fshift+i_shift_offset);
638 /* Increment number of inner iterations */
639 inneriter += j_index_end - j_index_start;
641 /* Outer loop uses 6 flops */
644 /* Increment number of outer iterations */
647 /* Update outer/inner flops */
649 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*56);