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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "gromacs/simd/math_x86_sse2_double.h"
48 #include "kernelutil_x86_sse2_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_sse2_double
52 * Electrostatics interaction: None
53 * VdW interaction: LennardJones
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_sse2_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 int vdwjidx0A,vdwjidx0B;
83 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
84 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
89 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
90 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
91 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
92 real rswitch_scalar,d_scalar;
93 __m128d dummy_mask,cutoff_mask;
94 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
95 __m128d one = _mm_set1_pd(1.0);
96 __m128d two = _mm_set1_pd(2.0);
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
108 nvdwtype = fr->ntype;
110 vdwtype = mdatoms->typeA;
112 rcutoff_scalar = fr->rvdw;
113 rcutoff = _mm_set1_pd(rcutoff_scalar);
114 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
116 rswitch_scalar = fr->rvdw_switch;
117 rswitch = _mm_set1_pd(rswitch_scalar);
118 /* Setup switch parameters */
119 d_scalar = rcutoff_scalar-rswitch_scalar;
120 d = _mm_set1_pd(d_scalar);
121 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
122 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
123 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
124 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
125 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
126 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
128 /* Avoid stupid compiler warnings */
136 /* Start outer loop over neighborlists */
137 for(iidx=0; iidx<nri; iidx++)
139 /* Load shift vector for this list */
140 i_shift_offset = DIM*shiftidx[iidx];
142 /* Load limits for loop over neighbors */
143 j_index_start = jindex[iidx];
144 j_index_end = jindex[iidx+1];
146 /* Get outer coordinate index */
148 i_coord_offset = DIM*inr;
150 /* Load i particle coords and add shift vector */
151 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
153 fix0 = _mm_setzero_pd();
154 fiy0 = _mm_setzero_pd();
155 fiz0 = _mm_setzero_pd();
157 /* Load parameters for i particles */
158 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
160 /* Reset potential sums */
161 vvdwsum = _mm_setzero_pd();
163 /* Start inner kernel loop */
164 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
167 /* Get j neighbor index, and coordinate index */
170 j_coord_offsetA = DIM*jnrA;
171 j_coord_offsetB = DIM*jnrB;
173 /* load j atom coordinates */
174 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
177 /* Calculate displacement vector */
178 dx00 = _mm_sub_pd(ix0,jx0);
179 dy00 = _mm_sub_pd(iy0,jy0);
180 dz00 = _mm_sub_pd(iz0,jz0);
182 /* Calculate squared distance and things based on it */
183 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
185 rinv00 = gmx_mm_invsqrt_pd(rsq00);
187 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
189 /* Load parameters for j particles */
190 vdwjidx0A = 2*vdwtype[jnrA+0];
191 vdwjidx0B = 2*vdwtype[jnrB+0];
193 /**************************
194 * CALCULATE INTERACTIONS *
195 **************************/
197 if (gmx_mm_any_lt(rsq00,rcutoff2))
200 r00 = _mm_mul_pd(rsq00,rinv00);
202 /* Compute parameters for interactions between i and j atoms */
203 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
204 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
206 /* LENNARD-JONES DISPERSION/REPULSION */
208 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
209 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
210 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
211 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
212 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
214 d = _mm_sub_pd(r00,rswitch);
215 d = _mm_max_pd(d,_mm_setzero_pd());
216 d2 = _mm_mul_pd(d,d);
217 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)))))));
219 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
221 /* Evaluate switch function */
222 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
223 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
224 vvdw = _mm_mul_pd(vvdw,sw);
225 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
227 /* Update potential sum for this i atom from the interaction with this j atom. */
228 vvdw = _mm_and_pd(vvdw,cutoff_mask);
229 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
233 fscal = _mm_and_pd(fscal,cutoff_mask);
235 /* Calculate temporary vectorial force */
236 tx = _mm_mul_pd(fscal,dx00);
237 ty = _mm_mul_pd(fscal,dy00);
238 tz = _mm_mul_pd(fscal,dz00);
240 /* Update vectorial force */
241 fix0 = _mm_add_pd(fix0,tx);
242 fiy0 = _mm_add_pd(fiy0,ty);
243 fiz0 = _mm_add_pd(fiz0,tz);
245 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
249 /* Inner loop uses 59 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_sub_pd( _mm_mul_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_add_pd(swV3,_mm_mul_pd(d,_mm_add_pd(swV4,_mm_mul_pd(d,swV5)))))));
302 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
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_sub_pd( _mm_mul_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 /* Calculate temporary vectorial force */
322 tx = _mm_mul_pd(fscal,dx00);
323 ty = _mm_mul_pd(fscal,dy00);
324 tz = _mm_mul_pd(fscal,dz00);
326 /* Update vectorial force */
327 fix0 = _mm_add_pd(fix0,tx);
328 fiy0 = _mm_add_pd(fiy0,ty);
329 fiz0 = _mm_add_pd(fiz0,tz);
331 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
335 /* Inner loop uses 59 flops */
338 /* End of innermost loop */
340 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
341 f+i_coord_offset,fshift+i_shift_offset);
344 /* Update potential energies */
345 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
347 /* Increment number of inner iterations */
348 inneriter += j_index_end - j_index_start;
350 /* Outer loop uses 7 flops */
353 /* Increment number of outer iterations */
356 /* Update outer/inner flops */
358 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*59);
361 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse2_double
362 * Electrostatics interaction: None
363 * VdW interaction: LennardJones
364 * Geometry: Particle-Particle
365 * Calculate force/pot: Force
368 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_sse2_double
369 (t_nblist * gmx_restrict nlist,
370 rvec * gmx_restrict xx,
371 rvec * gmx_restrict ff,
372 t_forcerec * gmx_restrict fr,
373 t_mdatoms * gmx_restrict mdatoms,
374 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
375 t_nrnb * gmx_restrict nrnb)
377 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
378 * just 0 for non-waters.
379 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
380 * jnr indices corresponding to data put in the four positions in the SIMD register.
382 int i_shift_offset,i_coord_offset,outeriter,inneriter;
383 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
385 int j_coord_offsetA,j_coord_offsetB;
386 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
388 real *shiftvec,*fshift,*x,*f;
389 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
391 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
392 int vdwjidx0A,vdwjidx0B;
393 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
394 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
396 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
399 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
400 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
401 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
402 real rswitch_scalar,d_scalar;
403 __m128d dummy_mask,cutoff_mask;
404 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
405 __m128d one = _mm_set1_pd(1.0);
406 __m128d two = _mm_set1_pd(2.0);
412 jindex = nlist->jindex;
414 shiftidx = nlist->shift;
416 shiftvec = fr->shift_vec[0];
417 fshift = fr->fshift[0];
418 nvdwtype = fr->ntype;
420 vdwtype = mdatoms->typeA;
422 rcutoff_scalar = fr->rvdw;
423 rcutoff = _mm_set1_pd(rcutoff_scalar);
424 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
426 rswitch_scalar = fr->rvdw_switch;
427 rswitch = _mm_set1_pd(rswitch_scalar);
428 /* Setup switch parameters */
429 d_scalar = rcutoff_scalar-rswitch_scalar;
430 d = _mm_set1_pd(d_scalar);
431 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
432 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
433 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
434 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
435 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
436 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
438 /* Avoid stupid compiler warnings */
446 /* Start outer loop over neighborlists */
447 for(iidx=0; iidx<nri; iidx++)
449 /* Load shift vector for this list */
450 i_shift_offset = DIM*shiftidx[iidx];
452 /* Load limits for loop over neighbors */
453 j_index_start = jindex[iidx];
454 j_index_end = jindex[iidx+1];
456 /* Get outer coordinate index */
458 i_coord_offset = DIM*inr;
460 /* Load i particle coords and add shift vector */
461 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
463 fix0 = _mm_setzero_pd();
464 fiy0 = _mm_setzero_pd();
465 fiz0 = _mm_setzero_pd();
467 /* Load parameters for i particles */
468 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
470 /* Start inner kernel loop */
471 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
474 /* Get j neighbor index, and coordinate index */
477 j_coord_offsetA = DIM*jnrA;
478 j_coord_offsetB = DIM*jnrB;
480 /* load j atom coordinates */
481 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
484 /* Calculate displacement vector */
485 dx00 = _mm_sub_pd(ix0,jx0);
486 dy00 = _mm_sub_pd(iy0,jy0);
487 dz00 = _mm_sub_pd(iz0,jz0);
489 /* Calculate squared distance and things based on it */
490 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
492 rinv00 = gmx_mm_invsqrt_pd(rsq00);
494 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
496 /* Load parameters for j particles */
497 vdwjidx0A = 2*vdwtype[jnrA+0];
498 vdwjidx0B = 2*vdwtype[jnrB+0];
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
504 if (gmx_mm_any_lt(rsq00,rcutoff2))
507 r00 = _mm_mul_pd(rsq00,rinv00);
509 /* Compute parameters for interactions between i and j atoms */
510 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
511 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
513 /* LENNARD-JONES DISPERSION/REPULSION */
515 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
516 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
517 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
518 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
519 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
521 d = _mm_sub_pd(r00,rswitch);
522 d = _mm_max_pd(d,_mm_setzero_pd());
523 d2 = _mm_mul_pd(d,d);
524 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)))))));
526 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
528 /* Evaluate switch function */
529 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
530 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
531 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
535 fscal = _mm_and_pd(fscal,cutoff_mask);
537 /* Calculate temporary vectorial force */
538 tx = _mm_mul_pd(fscal,dx00);
539 ty = _mm_mul_pd(fscal,dy00);
540 tz = _mm_mul_pd(fscal,dz00);
542 /* Update vectorial force */
543 fix0 = _mm_add_pd(fix0,tx);
544 fiy0 = _mm_add_pd(fiy0,ty);
545 fiz0 = _mm_add_pd(fiz0,tz);
547 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
551 /* Inner loop uses 56 flops */
558 j_coord_offsetA = DIM*jnrA;
560 /* load j atom coordinates */
561 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
564 /* Calculate displacement vector */
565 dx00 = _mm_sub_pd(ix0,jx0);
566 dy00 = _mm_sub_pd(iy0,jy0);
567 dz00 = _mm_sub_pd(iz0,jz0);
569 /* Calculate squared distance and things based on it */
570 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
572 rinv00 = gmx_mm_invsqrt_pd(rsq00);
574 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
576 /* Load parameters for j particles */
577 vdwjidx0A = 2*vdwtype[jnrA+0];
579 /**************************
580 * CALCULATE INTERACTIONS *
581 **************************/
583 if (gmx_mm_any_lt(rsq00,rcutoff2))
586 r00 = _mm_mul_pd(rsq00,rinv00);
588 /* Compute parameters for interactions between i and j atoms */
589 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
591 /* LENNARD-JONES DISPERSION/REPULSION */
593 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
594 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
595 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
596 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
597 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
599 d = _mm_sub_pd(r00,rswitch);
600 d = _mm_max_pd(d,_mm_setzero_pd());
601 d2 = _mm_mul_pd(d,d);
602 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)))))));
604 dsw = _mm_mul_pd(d2,_mm_add_pd(swF2,_mm_mul_pd(d,_mm_add_pd(swF3,_mm_mul_pd(d,swF4)))));
606 /* Evaluate switch function */
607 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
608 fvdw = _mm_sub_pd( _mm_mul_pd(fvdw,sw) , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
609 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
613 fscal = _mm_and_pd(fscal,cutoff_mask);
615 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
617 /* Calculate temporary vectorial force */
618 tx = _mm_mul_pd(fscal,dx00);
619 ty = _mm_mul_pd(fscal,dy00);
620 tz = _mm_mul_pd(fscal,dz00);
622 /* Update vectorial force */
623 fix0 = _mm_add_pd(fix0,tx);
624 fiy0 = _mm_add_pd(fiy0,ty);
625 fiz0 = _mm_add_pd(fiz0,tz);
627 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
631 /* Inner loop uses 56 flops */
634 /* End of innermost loop */
636 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
637 f+i_coord_offset,fshift+i_shift_offset);
639 /* Increment number of inner iterations */
640 inneriter += j_index_end - j_index_start;
642 /* Outer loop uses 6 flops */
645 /* Increment number of outer iterations */
648 /* Update outer/inner flops */
650 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*56);