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 avx_128_fma_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_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_avx_128_fma_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_avx_128_fma_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_msub_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_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
219 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
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_msub_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 /* Update vectorial force */
236 fix0 = _mm_macc_pd(dx00,fscal,fix0);
237 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
238 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
240 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
241 _mm_mul_pd(dx00,fscal),
242 _mm_mul_pd(dy00,fscal),
243 _mm_mul_pd(dz00,fscal));
247 /* Inner loop uses 62 flops */
254 j_coord_offsetA = DIM*jnrA;
256 /* load j atom coordinates */
257 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
260 /* Calculate displacement vector */
261 dx00 = _mm_sub_pd(ix0,jx0);
262 dy00 = _mm_sub_pd(iy0,jy0);
263 dz00 = _mm_sub_pd(iz0,jz0);
265 /* Calculate squared distance and things based on it */
266 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
268 rinv00 = gmx_mm_invsqrt_pd(rsq00);
270 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
272 /* Load parameters for j particles */
273 vdwjidx0A = 2*vdwtype[jnrA+0];
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 if (gmx_mm_any_lt(rsq00,rcutoff2))
282 r00 = _mm_mul_pd(rsq00,rinv00);
284 /* Compute parameters for interactions between i and j atoms */
285 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
287 /* LENNARD-JONES DISPERSION/REPULSION */
289 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
290 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
291 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
292 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
293 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
295 d = _mm_sub_pd(r00,rswitch);
296 d = _mm_max_pd(d,_mm_setzero_pd());
297 d2 = _mm_mul_pd(d,d);
298 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
300 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
302 /* Evaluate switch function */
303 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
304 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
305 vvdw = _mm_mul_pd(vvdw,sw);
306 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
308 /* Update potential sum for this i atom from the interaction with this j atom. */
309 vvdw = _mm_and_pd(vvdw,cutoff_mask);
310 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
311 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
315 fscal = _mm_and_pd(fscal,cutoff_mask);
317 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
319 /* Update vectorial force */
320 fix0 = _mm_macc_pd(dx00,fscal,fix0);
321 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
322 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
324 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
325 _mm_mul_pd(dx00,fscal),
326 _mm_mul_pd(dy00,fscal),
327 _mm_mul_pd(dz00,fscal));
331 /* Inner loop uses 62 flops */
334 /* End of innermost loop */
336 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
337 f+i_coord_offset,fshift+i_shift_offset);
340 /* Update potential energies */
341 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
343 /* Increment number of inner iterations */
344 inneriter += j_index_end - j_index_start;
346 /* Outer loop uses 7 flops */
349 /* Increment number of outer iterations */
352 /* Update outer/inner flops */
354 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*62);
357 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
358 * Electrostatics interaction: None
359 * VdW interaction: LennardJones
360 * Geometry: Particle-Particle
361 * Calculate force/pot: Force
364 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
365 (t_nblist * gmx_restrict nlist,
366 rvec * gmx_restrict xx,
367 rvec * gmx_restrict ff,
368 t_forcerec * gmx_restrict fr,
369 t_mdatoms * gmx_restrict mdatoms,
370 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
371 t_nrnb * gmx_restrict nrnb)
373 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
374 * just 0 for non-waters.
375 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
376 * jnr indices corresponding to data put in the four positions in the SIMD register.
378 int i_shift_offset,i_coord_offset,outeriter,inneriter;
379 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
381 int j_coord_offsetA,j_coord_offsetB;
382 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
384 real *shiftvec,*fshift,*x,*f;
385 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
387 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
388 int vdwjidx0A,vdwjidx0B;
389 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
390 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
392 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
395 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
396 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
397 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
398 real rswitch_scalar,d_scalar;
399 __m128d dummy_mask,cutoff_mask;
400 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
401 __m128d one = _mm_set1_pd(1.0);
402 __m128d two = _mm_set1_pd(2.0);
408 jindex = nlist->jindex;
410 shiftidx = nlist->shift;
412 shiftvec = fr->shift_vec[0];
413 fshift = fr->fshift[0];
414 nvdwtype = fr->ntype;
416 vdwtype = mdatoms->typeA;
418 rcutoff_scalar = fr->rvdw;
419 rcutoff = _mm_set1_pd(rcutoff_scalar);
420 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
422 rswitch_scalar = fr->rvdw_switch;
423 rswitch = _mm_set1_pd(rswitch_scalar);
424 /* Setup switch parameters */
425 d_scalar = rcutoff_scalar-rswitch_scalar;
426 d = _mm_set1_pd(d_scalar);
427 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
428 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
429 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
430 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
431 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
432 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
434 /* Avoid stupid compiler warnings */
442 /* Start outer loop over neighborlists */
443 for(iidx=0; iidx<nri; iidx++)
445 /* Load shift vector for this list */
446 i_shift_offset = DIM*shiftidx[iidx];
448 /* Load limits for loop over neighbors */
449 j_index_start = jindex[iidx];
450 j_index_end = jindex[iidx+1];
452 /* Get outer coordinate index */
454 i_coord_offset = DIM*inr;
456 /* Load i particle coords and add shift vector */
457 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
459 fix0 = _mm_setzero_pd();
460 fiy0 = _mm_setzero_pd();
461 fiz0 = _mm_setzero_pd();
463 /* Load parameters for i particles */
464 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
466 /* Start inner kernel loop */
467 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
470 /* Get j neighbor index, and coordinate index */
473 j_coord_offsetA = DIM*jnrA;
474 j_coord_offsetB = DIM*jnrB;
476 /* load j atom coordinates */
477 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
480 /* Calculate displacement vector */
481 dx00 = _mm_sub_pd(ix0,jx0);
482 dy00 = _mm_sub_pd(iy0,jy0);
483 dz00 = _mm_sub_pd(iz0,jz0);
485 /* Calculate squared distance and things based on it */
486 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
488 rinv00 = gmx_mm_invsqrt_pd(rsq00);
490 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
492 /* Load parameters for j particles */
493 vdwjidx0A = 2*vdwtype[jnrA+0];
494 vdwjidx0B = 2*vdwtype[jnrB+0];
496 /**************************
497 * CALCULATE INTERACTIONS *
498 **************************/
500 if (gmx_mm_any_lt(rsq00,rcutoff2))
503 r00 = _mm_mul_pd(rsq00,rinv00);
505 /* Compute parameters for interactions between i and j atoms */
506 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
507 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
509 /* LENNARD-JONES DISPERSION/REPULSION */
511 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
512 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
513 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
514 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
515 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
517 d = _mm_sub_pd(r00,rswitch);
518 d = _mm_max_pd(d,_mm_setzero_pd());
519 d2 = _mm_mul_pd(d,d);
520 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
522 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
524 /* Evaluate switch function */
525 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
526 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
527 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
531 fscal = _mm_and_pd(fscal,cutoff_mask);
533 /* Update vectorial force */
534 fix0 = _mm_macc_pd(dx00,fscal,fix0);
535 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
536 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
538 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
539 _mm_mul_pd(dx00,fscal),
540 _mm_mul_pd(dy00,fscal),
541 _mm_mul_pd(dz00,fscal));
545 /* Inner loop uses 59 flops */
552 j_coord_offsetA = DIM*jnrA;
554 /* load j atom coordinates */
555 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
558 /* Calculate displacement vector */
559 dx00 = _mm_sub_pd(ix0,jx0);
560 dy00 = _mm_sub_pd(iy0,jy0);
561 dz00 = _mm_sub_pd(iz0,jz0);
563 /* Calculate squared distance and things based on it */
564 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
566 rinv00 = gmx_mm_invsqrt_pd(rsq00);
568 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
570 /* Load parameters for j particles */
571 vdwjidx0A = 2*vdwtype[jnrA+0];
573 /**************************
574 * CALCULATE INTERACTIONS *
575 **************************/
577 if (gmx_mm_any_lt(rsq00,rcutoff2))
580 r00 = _mm_mul_pd(rsq00,rinv00);
582 /* Compute parameters for interactions between i and j atoms */
583 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
585 /* LENNARD-JONES DISPERSION/REPULSION */
587 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
588 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
589 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
590 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
591 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
593 d = _mm_sub_pd(r00,rswitch);
594 d = _mm_max_pd(d,_mm_setzero_pd());
595 d2 = _mm_mul_pd(d,d);
596 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
598 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
600 /* Evaluate switch function */
601 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
602 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
603 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
607 fscal = _mm_and_pd(fscal,cutoff_mask);
609 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
611 /* Update vectorial force */
612 fix0 = _mm_macc_pd(dx00,fscal,fix0);
613 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
614 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
616 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
617 _mm_mul_pd(dx00,fscal),
618 _mm_mul_pd(dy00,fscal),
619 _mm_mul_pd(dz00,fscal));
623 /* Inner loop uses 59 flops */
626 /* End of innermost loop */
628 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
629 f+i_coord_offset,fshift+i_shift_offset);
631 /* Increment number of inner iterations */
632 inneriter += j_index_end - j_index_start;
634 /* Outer loop uses 6 flops */
637 /* Increment number of outer iterations */
640 /* Update outer/inner flops */
642 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*59);